Ticket #7894: 7894_2.patch

File 7894_2.patch, 1.6 KB (added by Garry Yao, 13 years ago)
  • _source/core/htmlparser/fragment.js

     
    4949        // Dtd of the fragment element, basically it accept anything except for intermediate structure, e.g. orphan <li>.
    5050        var rootDtd = CKEDITOR.tools.extend( {}, { html: 1 }, CKEDITOR.dtd.html, CKEDITOR.dtd.body, CKEDITOR.dtd.head, { style:1,script:1 } );
    5151
     52        function isRemoveEmpty( node )
     53        {
     54                // Empty link is to be removed when empty but not anchor. (#7894)
     55                return node.name == 'a' && node.attributes.href
     56                        || CKEDITOR.dtd.$removeEmpty[ node.name ];
     57        }
     58
    5259        /**
    5360         * Creates a {@link CKEDITOR.htmlParser.fragment} from an HTML string.
    5461         * @param {String} fragmentHtml The HTML to be parsed, filling the fragment.
     
    104111                                                pendingInline.splice( i, 1 );
    105112                                                i--;
    106113                                        }
    107                                 }
    108                         }
    109                 }
     114                                        else
     115                                        {
     116                                                // Some element of the same type cannot be nested, flat them,
     117                                                // e.g. <a href="#">foo<a href="#">bar</a></a>. (#7894)
     118                                                if ( pendingName == currentNode.name )
     119                                                        addElement( currentNode, currentNode.parent, 1 ), i--;
     120                                        }
     121                                }
     122                        }
     123                }
    110124
    111125                function sendPendingBRs()
    112126                {
     
    200214                        element.isOptionalClose = tagName in optionalCloseTags || optionalClose;
    201215
    202216                        // This is a tag to be removed if empty, so do not add it immediately.
    203                         if ( CKEDITOR.dtd.$removeEmpty[ tagName ] )
     217                        if ( isRemoveEmpty( element ) )
    204218                        {
    205219                                pendingInline.push( element );
    206220                                return;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy