Permalink
Browse files

Optimize element purging. (RStankov, Andrew Dupont)

  • Loading branch information...
1 parent d9aee20 commit 9a752d70d97a095202c764ded3fb2086007102db @savetheclocktower savetheclocktower committed May 12, 2010
Showing with 6 additions and 5 deletions.
  1. +2 −0 CHANGELOG
  2. +4 −5 src/dom/dom.js
View
@@ -1,3 +1,5 @@
+* Optimize element purging. (RStankov, Andrew Dupont)
+
* Add `Element.purge` for cleaning up event listeners and element storage keys on elements that will be removed from the page. Make `Element.update` perform similar cleanup automatically. (Andrew Dupont, Tobie Langel)
* The second argument to Event.Handler callbacks is the target element when no selector is present, or the matching element when a selector is present. Callbacks are always bound to the original element. (sam)
View
@@ -192,11 +192,10 @@ Element.cache = { };
// Performs cleanup on an element before it is removed from the page.
// See `Element#purge`.
function purgeElement(element) {
- // Must go first because it relies on Element.Storage.
- Element.stopObserving(element);
-
var uid = element._prototypeUID;
if (uid) {
+ // Must go first because it relies on Element.Storage.
+ Element.stopObserving(element);
element._prototypeUID = void 0;
delete Element.Storage[uid];
}
@@ -573,7 +572,7 @@ Element.Methods = {
// Purge the element's existing contents of all storage keys and
// event listeners, since said content will be replaced no matter
// what.
- var descendants = Element.select(element, '*'),
+ var descendants = element.getElementsByTagName('*'),
i = descendants.length;
while (i--) purgeElement(descendants[i]);
@@ -3824,7 +3823,7 @@ Element.addMethods({
if (!(element = $(element))) return;
purgeElement(element);
- var descendants = Element.select(element, '*'),
+ var descendants = element.getElementsByTagName('*'),
i = descendants.length;
while (i--) purgeElement(descendants[i]);

0 comments on commit 9a752d7

Please sign in to comment.