Ticket #8226: 8226_4.patch

File 8226_4.patch, 3.4 KB (added by Garry Yao, 13 years ago)
  • _source/core/dom/element.js

     
    14791479                                }
    14801480                        }
    14811481
    1482                         return $ && new CKEDITOR.dom.document( $.contentWindow.document );
     1482                        return $ && $.contentWindow && new CKEDITOR.dom.document( $.contentWindow.document );
    14831483                },
    14841484
    14851485                /**
     
    15801580                        return this.$.childNodes.length;
    15811581                },
    15821582
     1583                /**
     1584                 *  Whether this element is not yet presented in the DOM tree.
     1585                 */
     1586                isOffline : function()
     1587                {
     1588                        var root = this.getDocument().getDocumentElement();
     1589                        return !root.contains( this );
     1590                },
     1591
    15831592                disableContextMenu : function()
    15841593                {
    15851594                        this.on( 'contextmenu', function( event )
  • _source/themes/default/theme.js

     
    188188                                toolbarSpace && toolbarSpace.getParent().getParent()[ func ]( 'cke_mixed_dir_content' );
    189189                        });
    190190
     191                        editor.on( 'destroy', function()
     192                        {
     193                                var container = editor.container,
     194                                        element = editor.element;
     195                                container && container.clearCustomData();
     196                                element.clearCustomData();
     197                        });
     198
    191199                        editor.fireOnce( 'themeLoaded' );
    192200                        editor.fireOnce( 'uiReady' );
    193201                },
     
    267275                                element = editor.element;
    268276
    269277                        if ( container )
    270                         {
    271                                 container.clearCustomData();
    272278                                container.remove();
    273                         }
    274279
    275280                        if ( element )
    276281                        {
    277                                 element.clearCustomData();
    278282                                editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE && element.show();
    279283                                delete editor.element;
    280284                        }
  • _source/core/editor.js

     
    465465                                                || getNewName();
    466466
    467467                        if ( this.name in CKEDITOR.instances )
    468                                 throw '[CKEDITOR.editor] The instance "' + this.name + '" already exists.';
     468                        {
     469                                var previous = CKEDITOR.instances[ this.name ];
    469470
     471                                // Destroy detached editor silently.
     472                                if ( previous.checkDetached() )
     473                                        previous.destroy( false );
     474                                else
     475                                        throw '[CKEDITOR.editor] The instance "' + previous.name + '" already exists.';
     476                        }
     477
    470478                        /**
    471479                         * A unique random string assigned to each editor instance on the page.
    472480                         * @name CKEDITOR.editor.prototype.id
     
    562570                 */
    563571                destroy : function( noUpdate )
    564572                {
    565                         if ( !noUpdate )
    566                                 this.updateElement();
    567573
     574                        var notDetached = !this.checkDetached();
     575                        notDetached && this.updateElement();
    568576                        this.fire( 'destroy' );
    569                         this.theme && this.theme.destroy( this );
     577                        notDetached && this.theme && this.theme.destroy( this );
    570578
    571579                        CKEDITOR.remove( this );
    572580                        CKEDITOR.fire( 'instanceDestroyed', null, this );
     
    865873                                else
    866874                                        element.setHtml( data );
    867875                        }
     876                },
     877
     878                /**
     879                 * Check whether the editor UI has been removed from DOM thus
     880                 * the editor instance is considered to be obsoleted.
     881                 * @since 3.6.2
     882                 * @example
     883                 * editor.container.remove();
     884                 * alert( editor.checkDetached() );
     885                 */
     886                checkDetached : function()
     887                {
     888                        this.element.isOffline() || this.container && this.container.isOffline();
    868889                }
    869890        });
    870891
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy