Ticket #7494: 7494_3.patch

File 7494_3.patch, 3.1 KB (added by Garry Yao, 13 years ago)
  • _source/core/htmlparser/element.js

     
    5050                isEmpty = !!dtd.$empty[ name ];
    5151
    5252        this.isEmpty    = isEmpty;
     53        // Indicate there's no explicit close tag on this element.
     54        this.isOptionalClose    = false;
     55        // Indicate there's no explicit close tag on this element.
     56        this.isOptionalClose    = false;
    5357        this.isUnknown  = !dtd[ name ];
    5458
    5559        /** @private */
  • _source/core/htmlparser/fragment.js

     
    184184                                currentNode = moveCurrent ? target : savedCurrent;
    185185                }
    186186
    187                 parser.onTagOpen = function( tagName, attributes, selfClosing )
     187                parser.onTagOpen = function( tagName, attributes, selfClosing, optionalClose )
    188188                {
    189189                        var element = new CKEDITOR.htmlParser.element( tagName, attributes );
    190190
     
    193193                        if ( element.isUnknown && selfClosing )
    194194                                element.isEmpty = true;
    195195
     196                        element.isOptionalClose = optionalClose;
     197
    196198                        // This is a tag to be removed if empty, so do not add it immediately.
    197199                        if ( CKEDITOR.dtd.$removeEmpty[ tagName ] )
    198200                        {
     
    224226                                // If the element cannot be child of the current element.
    225227                                if ( !element.isUnknown && !currentNode.isUnknown && !currentDtd[ tagName ] )
    226228                                {
     229                                        // Current node doesn't have a close tag, time for a close
     230                                        // as this element isn't fit in. (#7497)
     231                                        if ( currentNode.isOptionalClose )
     232                                                parser.onTagClose( currentName );
    227233                                        // Fixing malformed nested lists by moving it into a previous list item. (#3828)
    228                                         if ( tagName in listBlocks
     234                                        else if ( tagName in listBlocks
    229235                                                && currentName in listBlocks )
    230236                                        {
    231237                                                var children = currentNode.children,
     
    235241                                                if ( !( lastChild && lastChild.name == 'li' ) )
    236242                                                        addElement( ( lastChild = new CKEDITOR.htmlParser.element( 'li' ) ), currentNode );
    237243
     244                                                !element.returnPoint && ( element.returnPoint = currentNode );
    238245                                                currentNode = lastChild;
    239246                                        }
    240247                                        // Establish new list root for orphan list items.
    241248                                        else if ( tagName in CKEDITOR.dtd.$listItem && currentName != tagName )
    242                                                 parser.onTagOpen( tagName == 'li' ? 'ul' : 'dl', {} );
     249                                                parser.onTagOpen( tagName == 'li' ? 'ul' : 'dl', {}, 0, 1 );
    243250                                        // We're inside a structural block like table and list, AND the incoming element
    244251                                        // is not of the same type (e.g. <td>td1<td>td2</td>), we simply add this new one before it,
    245252                                        // and most importantly, return back to here once this element is added,
     
    369376                                 && ( !currentNode.type || currentNode.name == 'body' )
    370377                                 && CKEDITOR.tools.trim( text ) )
    371378                        {
    372                                 this.onTagOpen( fixForBody, {} );
     379                                this.onTagOpen( fixForBody, {}, 0, 1 );
    373380                        }
    374381
    375382                        // Shrinking consequential spaces into one single for all elements
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy