From 8b7dea70d5b9821baac636e337b4781d03c0cff6 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Wed, 16 Jun 2010 18:18:01 +0200 Subject: [PATCH] Port purge() from 1.7. --- horde/js/prototype.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/horde/js/prototype.js b/horde/js/prototype.js index 90a583f4c..5b539235c 100644 --- a/horde/js/prototype.js +++ b/horde/js/prototype.js @@ -1787,6 +1787,15 @@ if (!Node.ELEMENT_NODE) { Element.cache = { }; Element.idCounter = 1; +function purgeElement(element) { + var uid = element._prototypeUID; + if (uid) { + Element.stopObserving(element); + element._prototypeUID = void 0; + delete Element.Storage[uid]; + } +} + Element.Methods = { visible: function(element) { return $(element).style.display != 'none'; @@ -1861,6 +1870,10 @@ Element.Methods = { function update(element, content) { element = $(element); + var descendants = element.getElementsByTagName('*'), + i = descendants.length; + while (i--) purgeElement(descendants[i]); + if (content && content.toElement) content = content.toElement(); @@ -3150,6 +3163,18 @@ Element.addMethods({ } } return Element.extend(clone); + }, + + purge: function(element) { + if (!(element = $(element))) return; + purgeElement(element); + + var descendants = element.getElementsByTagName('*'), + i = descendants.length; + + while (i--) purgeElement(descendants[i]); + + return null; } }); /* Portions of the Selector class are derived from Jack Slocum's DomQuery, -- 2.11.0