Ticket #4555: 4555_2.patch

File 4555_2.patch, 6.3 KB (added by Alfonso Martínez de Lizarrondo, 14 years ago)

Improved patch

  • _source/core/dom/domobject.js

     
    115115                                        delete nativeListeners[ eventName ];
    116116                                }
    117117                        }
     118                },
     119
     120                /** @ignore */
     121                removeAllListeners : function()
     122                {
     123                        // Call the original implementation.
     124                        CKEDITOR.event.prototype.removeAllListeners.apply( this );
     125
     126                        var nativeListeners = this.getCustomData( '_cke_nativeListeners' );
     127                        for( eventName in nativeListeners)
     128                        {
     129                                var listener = nativeListeners[ eventName ];
     130                                if ( this.$.removeEventListener )
     131                                        this.$.removeEventListener( eventName, listener, false );
     132                                else if ( this.$.detachEvent )
     133                                        this.$.detachEvent( 'on' + eventName, listener );
     134
     135                                delete nativeListeners[ eventName ];
     136                        }
    118137                }
    119138        };
    120139})();
     
    197216        };
    198217
    199218        /**
     219         * @name CKEDITOR.dom.domObject.prototype.clearCustomData
     220         */
     221        domObjectProto.clearCustomData = function()
     222        {
     223                var expandoNumber = this.$._cke_expando;
     224                expandoNumber && delete customData[ expandoNumber ];
     225        };
     226
     227        /**
    200228         * @name CKEDITOR.dom.domObject.prototype.getCustomData
    201229         */
    202230        domObjectProto.getUniqueId = function()
  • _source/core/editor.js

     
    468468                        if ( !noUpdate )
    469469                                this.updateElement();
    470470
     471                        if ( this.mode )
     472                        {
     473                                var holderElement = this.getThemeSpace( 'contents' ),
     474                                        currentMode = this._.modes[ editor.mode ] ;
     475                                currentMode.unload( holderElement );
     476                                this.mode = '';
     477                        }
     478
    471479                        this.theme.destroy( this );
    472                         this.fire( 'destroy' );
     480                        delete this.focusManager._.editor;
     481                        delete this.ui._.editor;
     482
     483                        if (CKEDITOR.ui.button)
     484                        {
     485                                var globalItems = CKEDITOR.ui.button._.instances;
     486                                for(var index in globalItems)
     487                                {
     488                                        button = globalItems[index];
     489                                        if (button && button.editor == this)
     490                                                globalItems[index] = null;
     491                                }
     492                        }
     493
     494                        var commands = this._.commands;
     495                        for (var command in commands)
     496                        {
     497                                var o = commands[command];
     498                                o.removeAllListeners();
     499
     500                                for (var items in o.uiItems)
     501                                {
     502                                        if (o.uiItems._)
     503                                                delete o.uiItems._.editor
     504                                }
     505
     506                                delete commands[command];
     507                        }
     508
     509                        this.fireOnce( 'destroy' );
     510                        this.removeAllListeners();
     511
    473512                        CKEDITOR.remove( this );
    474513                        CKEDITOR.fire( 'instanceDestroyed', null, this );
    475514                },
  • _source/core/event.js

     
    314314                                        var index = event.getListenerIndex( listenerFunction );
    315315                                        if ( index >= 0 )
    316316                                                event.listeners.splice( index, 1 );
     317                                        // Clear the event if there are no more listeners
     318                                        if (event.listeners.length==0)
     319                                                delete getPrivate( this )[ eventName ]
    317320                                }
    318321                        },
    319322
     323                        removeAllListeners : function()
     324                        {
     325                                var events = getPrivate( this );
     326                                for(e in events)
     327                                {
     328                                        delete events[ e ];
     329                                }
     330                        },
    320331                        /**
    321332                         * Checks if there is any listener registered to a given event.
    322333                         * @param {String} eventName The event name.
  • _source/plugins/button/plugin.js

     
    9292
    9393                var clickFn = CKEDITOR.tools.addFunction( instance.execute, instance );
    9494
     95                editor.on( 'destroy', function () {
     96                                CKEDITOR.tools.removeFunction( clickFn );
     97                                delete instance.editor;
     98                                delete instance.execute;
     99                                delete instance.toolbar;
     100                                delete instance.button;
     101                        } );
     102
    95103                var index = CKEDITOR.ui.button._.instances.push( instance ) - 1;
    96104
    97105                var classes = '';
  • _source/plugins/toolbar/plugin.js

     
    283283                                                                {
    284284                                                                        editor.execCommand( 'toolbarCollapse' );
    285285                                                                } );
     286                                                        editor.on( 'destroy', function () {
     287                                                                        CKEDITOR.tools.removeFunction( collapserFn );
     288                                                                } );
    286289
    287290                                                        var collapserId = 'cke_' + CKEDITOR.tools.getNextNumber();
    288291
  • _source/plugins/wysiwygarea/plugin.js

     
    690690
    691691                                                        unload : function( holderElement )
    692692                                                        {
     693                                                                var htmlElement = editor.document.getDocumentElement()
     694                                                                htmlElement.removeAllListeners();
     695                                                                htmlElement.clearCustomData();
     696
     697                                                                editor.window.removeAllListeners();
     698                                                                editor.window.clearCustomData();
     699
     700                                                                editor.document.removeAllListeners();
     701                                                                editor.document.clearCustomData();
     702
    693703                                                                editor.window = editor.document = iframe = mainElement = isPendingFocus = null;
    694704
    695705                                                                editor.fire( 'contentDomUnload' );
     
    758768                                                        editor.focus();
    759769                                                } );
    760770                                } );
     771                                editor.on( 'destroy', function()
     772                                {
     773                                        ieFocusGrabber.removeAllListeners();
     774                                        ieFocusGrabber.clearCustomData();
     775                                        ieFocusGrabber.remove()
     776                                        ieFocusGrabber = null;
     777                                } );
    761778                        }
    762779                }
    763780        });
  • _source/themes/default/theme.js

     
    229229                destroy : function( editor )
    230230                {
    231231                        var container = editor.container;
     232                        container.removeAllListeners();
     233                        container.clearCustomData();
    232234
    233235                        /*
    234236                         * IE BUG: Removing the editor DOM elements while the selection is inside
     
    254256
    255257                        if ( container )
    256258                                container.remove();
     259                        delete editor.container;
    257260
    258261                        if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
    259                         {
    260262                                editor.element.show();
    261                                 delete editor.element;
    262                         }
     263
     264                        delete editor.element;
    263265                }
    264266        };
    265267})() );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy