[BUGFIX] RTE: JS errors on unload 57/35557/2
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 18 Dec 2014 03:38:13 +0000 (22:38 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 18 Dec 2014 03:40:34 +0000 (04:40 +0100)
Cleanup the cleanup operations.

Releases: master
Resolves: #63971
Change-Id: I81706a18cdbd39f13d78fdf9738720682ab56d71
Reviewed-on: http://review.typo3.org/35557
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/Editor/Iframe.js
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/Editor/StatusBar.js
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/Editor/TextAreaContainer.js
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/Editor/Toolbar.js
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/Toolbar/Button.js
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/Toolbar/ToolbarText.js

index c802103..7fa46ae 100644 (file)
@@ -776,7 +776,6 @@ define('TYPO3/CMS/Rtehtmlarea/HTMLArea/Editor/Iframe',
                        Event.off(this.document.documentElement);
                        // Cleaning references to DOM in order to avoid IE memory leaks
                        this.document = null;
-                       delete this.el;
                        this.el = null;
                }
        };
index 63eac85..20c2c87 100644 (file)
@@ -350,12 +350,12 @@ define('TYPO3/CMS/Rtehtmlarea/HTMLArea/Editor/StatusBar',
                 */
                onBeforeDestroy: function() {
                        this.clear();
+                       var node;
                        while (node = this.el.firstChild) {
                                this.el.removeChild(node);
                        }
                        this.statusBarTree = null;
                        this.statusBarWordCount = null;
-                       delete this.el;
                        this.el = null;
                }
        };
index 588502f..e7c7e9a 100644 (file)
@@ -96,6 +96,7 @@ define('TYPO3/CMS/Rtehtmlarea/HTMLArea/Editor/TextAreaContainer',
                onBeforeDestroy: function() {
                        this.originalParent.appendChild(this.textArea);
                        Event.off(this);
+                       this.el = null;
                }
        };
 
index 3a56a1b..1f154c2 100644 (file)
@@ -277,19 +277,21 @@ define('TYPO3/CMS/Rtehtmlarea/HTMLArea/Editor/Toolbar',
                 */
                onBeforeDestroy: function () {
                        Event.off(this);
-                       while (node = this.el.firstChild) {
-                               this.el.removeChild(node);
-                       }
                        for (var itemId in this.items) {
                                if (typeof this.items[itemId].destroy === 'function') {
                                        try {
                                                this.items[itemId].destroy();
                                        } catch (e) {}
                                }
-                               if (typeof this.items[itemId].onBeforeDestroy === 'function') {
+                               if (typeof this.items[itemId].onBeforeDestroy === 'function' && this.items[itemId].xtype !== 'htmlareacombo') {
                                        this.items[itemId].onBeforeDestroy();
                                }
                        }
+                       var node;
+                       while (node = this.el.firstChild) {
+                               this.el.removeChild(node);
+                       }
+                       this.el = null;
                }
        };
 
index 30b1bba..55670fb 100644 (file)
@@ -236,12 +236,14 @@ define('TYPO3/CMS/Rtehtmlarea/HTMLArea/Toolbar/Button',
                 */
                onBeforeDestroy: function () {
                        Event.off(this);
-                       Event.off(this.el);
-                       while (node = this.el.firstChild) {
-                               this.el.removeChild(node);
+                       if (this.el) {
+                               Event.off(this.el);
+                               var node;
+                               while (node = this.el.firstChild) {
+                                       this.el.removeChild(node);
+                               }
+                               this.el = null;
                        }
-                       delete this.e;
-                       this.el = null;
                }
        };
 
index dad39e4..b84dc28 100644 (file)
@@ -104,6 +104,19 @@ define('TYPO3/CMS/Rtehtmlarea/HTMLArea/Toolbar/ToolbarText',
                        } else {
                                Dom.removeClass(this.el, this.disabledClass);
                        }
+               },
+
+               /**
+                * Cleanup (called by toolbar onBeforeDestroy)
+                */
+               onBeforeDestroy: function () {
+                       if (this.el) {
+                               var node;
+                               while (node = this.el.firstChild) {
+                                       this.el.removeChild(node);
+                               }
+                               this.el = null;
+                       }
                }
        };