Ticket #6751: 6751.patch

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

     
    127127                                {
    128128                                        var writer = new CKEDITOR.htmlParser.basicWriter();
    129129                                        CKEDITOR.htmlParser.fragment.prototype.writeChildrenHtml.call( element, writer, filter );
    130                                         element.children = new CKEDITOR.htmlParser.fragment.fromHtml( writer.getHtml() ).children;
     130                                        element.children = new CKEDITOR.htmlParser.fragment.fromHtml( writer.getHtml(), 0, element.clone() ).children;
    131131                                        isChildrenFiltered = 1;
    132132                                }
    133133                        };
  • _source/core/htmlparser/fragment.js

     
    5252         * Creates a {@link CKEDITOR.htmlParser.fragment} from an HTML string.
    5353         * @param {String} fragmentHtml The HTML to be parsed, filling the fragment.
    5454         * @param {Number} [fixForBody=false] Wrap body with specified element if needed.
     55         * @param {CKEDITOR.htmlParser.element} contextNode Parse the html as the content of this element.
    5556         * @returns CKEDITOR.htmlParser.fragment The fragment created.
    5657         * @example
    5758         * var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<b>Sample</b> Text' );
    5859         * alert( fragment.children[0].name );  "b"
    5960         * alert( fragment.children[1].value );  " Text"
    6061         */
    61         CKEDITOR.htmlParser.fragment.fromHtml = function( fragmentHtml, fixForBody )
     62        CKEDITOR.htmlParser.fragment.fromHtml = function( fragmentHtml, fixForBody, contextNode )
    6263        {
    6364                var parser = new CKEDITOR.htmlParser(),
    64                         html = [],
    65                         fragment = new CKEDITOR.htmlParser.fragment(),
     65                        fragment = contextNode || new CKEDITOR.htmlParser.fragment(),
    6666                        pendingInline = [],
    6767                        pendingBRs = [],
    6868                        currentNode = fragment,
     
    308308                                newPendingInline = [],
    309309                                candidate = currentNode;
    310310
    311                         while ( candidate.type && candidate.name != tagName )
     311                        while ( candidate != fragment && candidate.name != tagName )
    312312                        {
    313313                                // If this is an inline element, add it to the pending list, if we're
    314314                                // really closing one of the parents element later, they will continue
     
    324324                                candidate = candidate.parent;
    325325                        }
    326326
    327                         if ( candidate.type )
     327                        if ( candidate != fragment )
    328328                        {
    329329                                // Add all elements that have been found in the above loop.
    330330                                for ( i = 0 ; i < pendingAdd.length ; i++ )
     
    403403                sendPendingBRs( !CKEDITOR.env.ie && 1 );
    404404
    405405                // Close all pending nodes.
    406                 while ( currentNode.type )
     406                while ( currentNode != fragment )
    407407                {
    408408                        var parent = currentNode.parent,
    409409                                node = currentNode;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy