[richfaces-svn-commits] JBoss Rich Faces SVN: r5056 - trunk/framework/impl/src/main/javascript/prototype.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Thu Dec 27 22:36:53 EST 2007
Author: nbelaevski
Date: 2007-12-27 22:36:53 -0500 (Thu, 27 Dec 2007)
New Revision: 5056
Modified:
trunk/framework/impl/src/main/javascript/prototype/patches.js
Log:
http://jira.jboss.com/jira/browse/RF-1567
Modified: trunk/framework/impl/src/main/javascript/prototype/patches.js
===================================================================
--- trunk/framework/impl/src/main/javascript/prototype/patches.js 2007-12-28 01:54:55 UTC (rev 5055)
+++ trunk/framework/impl/src/main/javascript/prototype/patches.js 2007-12-28 03:36:53 UTC (rev 5056)
@@ -71,38 +71,53 @@
});
}
+Event.destroyEventCache = function(node) {
+ var eventID = node._eventID;
+ if (eventID) {
+ var cache = Event.cache[eventID];
+
+ for (var eventName in cache) {
+ var wrappers = cache[eventName];
+
+ wrappers.each(function(wrapper) {
+ if (node.removeEventListener) {
+ node.removeEventListener(eventName, wrapper, false);
+ } else {
+ node.detachEvent("on" + eventName, wrapper);
+ }
+ });
+
+ cache[eventName] = null;
+ }
+
+ delete Event.cache[eventID];
+ }
+}
+
Event.unloadElementsCache = function(oldNode) {
- //refer to window.unload handling conditions in prototype script
- if (!window.attachEvent) return;
-
- if (!oldNode) return;
+ if (oldNode) {
+ Event.destroyEventCache(oldNode);
+
+ //node.all is quicker than recursive traversing
+ //window doesn't have "all" attribute
+ var all = oldNode.all;
+
+ if (all) {
+ var counter = 0;
+ var length = all.length;
+
+ for (var counter = 0; counter < length; counter++ ) {
+ Event.destroyEventCache(all[counter]);
+ }
+ } else {
+ var node = oldNode.firstChild;
+ while (node) {
+ Event.unloadElementsCache(node);
+ node = node.nextSibling;
+ }
+ }
+ }
- var node = oldNode;
- //node.all is quicker than recursive traversing
- //window doesn't have "all" attribute
- var all = node.all || {};
- var counter = 0;
-
- do {
- var eventID = node._eventID;
- if (eventID) {
- var cache = Event.cache[eventID];
-
- for (var eventName in cache) {
- var wrappers = cache[eventName];
-
- wrappers.each(function(wrapper) {
- node.detachEvent("on" + eventName, wrapper);
- });
-
- cache[eventName] = null;
- }
-
- delete Event.cache[eventID];
- }
-
- node = all[counter++];
- } while (node);
};
//
More information about the richfaces-svn-commits
mailing list