X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fdomobject.js;h=f10db99bb1adfffbf6a0b5da0d04ee4f5807a288;hb=8665a7c6c60586526e32e8941fe2896739b6ebfb;hp=6962fdb58081adf72e43012fece812aec2e637c6;hpb=c6e377a02b54abc07129d72b632763c727476a15;p=ckeditor.git diff --git a/_source/core/dom/domobject.js b/_source/core/dom/domobject.js index 6962fdb..f10db99 100644 --- a/_source/core/dom/domobject.js +++ b/_source/core/dom/domobject.js @@ -115,6 +115,26 @@ CKEDITOR.dom.domObject.prototype = (function() delete nativeListeners[ eventName ]; } } + }, + + /** + * Removes any listener set on this object. + * To avoid memory leaks we must assure that there are no + * references left after the object is no longer needed. + */ + removeAllListeners : function() + { + var nativeListeners = this.getCustomData( '_cke_nativeListeners' ); + for ( var eventName in nativeListeners ) + { + var listener = nativeListeners[ eventName ]; + if ( this.$.removeEventListener ) + this.$.removeEventListener( eventName, listener, false ); + else if ( this.$.detachEvent ) + this.$.detachEvent( 'on' + eventName, listener ); + + delete nativeListeners[ eventName ]; + } } }; })(); @@ -123,6 +143,11 @@ CKEDITOR.dom.domObject.prototype = (function() { var customData = {}; + CKEDITOR.on( 'reset', function() + { + customData = {}; + }); + /** * Determines whether the specified object is equal to the current object. * @name CKEDITOR.dom.domObject.prototype.equals @@ -197,6 +222,22 @@ CKEDITOR.dom.domObject.prototype = (function() }; /** + * Removes any data stored on this object. + * To avoid memory leaks we must assure that there are no + * references left after the object is no longer needed. + * @name CKEDITOR.dom.domObject.prototype.clearCustomData + * @function + */ + domObjectProto.clearCustomData = function() + { + // Clear all event listeners + this.removeAllListeners(); + + var expandoNumber = this.$._cke_expando; + expandoNumber && delete customData[ expandoNumber ]; + }; + + /** * @name CKEDITOR.dom.domObject.prototype.getCustomData */ domObjectProto.getUniqueId = function()