<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,5 @@
+* Add event cleanup on Element#update and Element#replace so that replaced content does not leak memory. (jddalton, Andrew Dupont)
+
 * Loop through all elements and remove all handlers on page unload. IE needs this in order to prevent memory leaks. (kangax, jddalton, Andrew Dupont)
 
 * Fix issue where IE fails to GC when the page is navigated away from before it's done loading. (jddalton, Andrew Dupont)</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -877,6 +877,27 @@ else if (Prototype.Browser.IE) {
       onchange:    v._getEv
     });
   })(Element._attributeTranslations.read.values);
+
+  // Wrap Element#update and Element#replace to clean up event handlers on 
+  // newly-removed elements. Prevents memory leaks in IE.  
+  Element._purgeObservers = function(element, includeRoot) {
+    Element.select(element, '*').each(Event.stopObserving);
+    if (includeRoot === true) Event.stopObserving(element);
+  };
+    
+  Element.Methods.update = Element.Methods.update.wrap(
+    function(proceed, element, contents) {
+      Element._purgeObservers(element, false);
+      return proceed(element, contents);
+    }
+  );
+  
+  Element.Methods.replace = Element.Methods.replace.wrap(
+    function(proceed, element, contents) {
+      Element._purgeObservers(element, true);
+      return proceed(element, contents);
+    }
+  );  
 }
 
 else if (Prototype.Browser.Gecko &amp;&amp; /rv:1\.8\.0/.test(navigator.userAgent)) {</diff>
      <filename>src/dom.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>35cea73bfeab45d0231dbcbb4aa088ed250140a3</id>
    </parent>
  </parents>
  <author>
    <name>Andrew Dupont</name>
    <email>prototype@andrewdupont.net</email>
  </author>
  <url>http://github.com/sstephenson/prototype/commit/3d27a63da0e72807c6bb83e73ffa4359ee9e6465</url>
  <id>3d27a63da0e72807c6bb83e73ffa4359ee9e6465</id>
  <committed-date>2008-04-18T08:06:53-07:00</committed-date>
  <authored-date>2008-04-18T08:06:53-07:00</authored-date>
  <message>Add event cleanup on Element#update and Element#replace so that replaced content does not leak memory. [#28 state:resolved]</message>
  <tree>ce2b3824f5cf47584826d8780284a191cde5ed71</tree>
  <committer>
    <name>Andrew Dupont</name>
    <email>prototype@andrewdupont.net</email>
  </committer>
</commit>
