Author: nbelaevski
Date: 2007-12-10 09:36:07 -0500 (Mon, 10 Dec 2007)
New Revision: 4652
Modified:
branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
branches/3.1.x/framework/impl/src/main/javascript/prototype/patches.js
Log:
http://jira.jboss.com/jira/browse/RF-1567
Modified: branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-12-10
14:28:48 UTC (rev 4651)
+++ branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-12-10
14:36:07 UTC (rev 4652)
@@ -333,6 +333,12 @@
LOG.debug("Replace content of node by replaceChild()");
anchor.replaceChild(importednode,oldnode);
}
+
+ // Remove unload prototype events for a removed elements.
+ if ((typeof Event != "undefined") && (typeof
Event.unloadElementsCache == "function")) {
+ Event.unloadElementsCache(oldnode);
+ }
+
// re-execute all script fragments in imported subtree...
// TODO - opera 8 run scripts at replace content stage.
if(!A4J.AJAX._scriptEvaluated){
@@ -847,9 +853,10 @@
window.document.documentElement.appendChild(node);
}
}
- if (typeof Event != "undefined" && typeof
Event.unloadElementsCache == "function") {
- Event.unloadElementsCache();
- }
+ //TODO - unloading cached observers?
+ //if (typeof Event != "undefined" && typeof
Event.unloadElementsCache == "function") {
+ //Event.unloadElementsCache();
+ //}
} else {
LOG.error("Error parsing
response",Sarissa.getParseErrorText(oDomDoc));
}
@@ -884,11 +891,6 @@
*/
A4J.AJAX.finishRequest = function(request){
var options = request.options;
- // Remove unload prototype events for a removed elements.
- if ((typeof Event != "undefined") && (typeof
Event.unloadElementsCache == "function")) {
- Event.unloadElementsCache();
- }
-
// we can set listener for complete request - for example,
// it can shedule next request for update page.
var oncomplete = request.getElementById('org.ajax4jsf.oncomplete');
Modified: branches/3.1.x/framework/impl/src/main/javascript/prototype/patches.js
===================================================================
--- branches/3.1.x/framework/impl/src/main/javascript/prototype/patches.js 2007-12-10
14:28:48 UTC (rev 4651)
+++ branches/3.1.x/framework/impl/src/main/javascript/prototype/patches.js 2007-12-10
14:36:07 UTC (rev 4652)
@@ -62,19 +62,32 @@
}
};
-Event.unloadElementsCache = function() {
- if (!Event.observers) return;
- //refer to window.unload handling conditions in prototype script
- if (!Prototype.Browser.IE) return;
+Event.unloadElementsCache = function(oldNode) {
+ //refer to window.unload handling conditions in prototype script
+ if (!window.attachEvent) return;
+
+ if (!oldNode) return;
- var observers = Event.observers;
- for (var i = observers.length - 1; i >= 0; i--) {
- var observer = observers[i];
- var elt = observer[0];
-
- if (Element.isUninitialized(elt)) {
- Event.stopObserving.apply(Event, observer);
- observers.splice(i, 1);
+ if (oldNode) {
+ if (oldNode._eventID) {
+ var cache = Event.cache[oldNode._eventID];
+
+ for (var eventName in cache) {
+ cache[eventName] = null;
+ }
+
+ delete Event.cache[oldNode._eventID];
}
+
+ var firstNode = oldNode.firstChild;
+ if (firstNode) {
+ Event.unloadElementsCache(firstNode);
+
+ var nextNode = firstNode.nextSibling;
+ while (nextNode) {
+ Event.unloadElementsCache(nextNode);
+ nextNode = nextNode.nextSibling;
+ }
+ }
}
};
\ No newline at end of file