Ticket #8344: 8344.patch

File 8344.patch, 2.8 KB (added by Frederico Caldeira Knabben, 13 years ago)
  • _source/core/htmlparser/element.js

     
    157157                },
    158158
    159159                /**
     160                 * Whether the provided element is identical this one. An identical element
     161                 * has the same name and attributes.
     162                 * @param {CKEDITOR.htmlParser.element} otherElement The element to be compared.
     163                 * @returns {Boolean} 'true' if the elements are identical.
     164                 */
     165                isIdentical : function( otherElement )
     166                {
     167                        if ( !otherElement.name || otherElement.name != this.name )
     168                                return false;
     169
     170                        var attribsA = this.attributes,
     171                                attribsB = otherElement.attributes,
     172                                lenA = 0,
     173                                lenB = 0;
     174
     175                        // Check if all attributes available on A are defined on B.
     176                        for ( var att in attribsA )
     177                        {
     178                                if ( attribsA[ att ] !== attribsB[ att ] )
     179                                        return false;
     180                               
     181                                // Count the number of attribs on A.
     182                                lenA++;
     183                        }
     184
     185                        // Count the number of attribs on B.
     186                        for ( att in attribsB )
     187                                lenB++;
     188
     189                        return lenA == lenB;
     190                },
     191
     192                /**
    160193                 * Writes the element HTML to a CKEDITOR.htmlWriter.
    161194                 * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
    162195                 * @example
  • _source/core/htmlparser/fragment.js

     
    9292                                                pendingDtd = CKEDITOR.dtd[ pendingName ],
    9393                                                currentDtd = currentNode.name && CKEDITOR.dtd[ currentNode.name ];
    9494
     95                                        if ( pendingElement.ignore )
     96                                                continue;
     97
    9598                                        if ( ( !currentDtd || currentDtd[ pendingName ] ) && ( !newTagName || !pendingDtd || pendingDtd[ newTagName ] || !CKEDITOR.dtd[ newTagName ] ) )
    9699                                        {
    97100                                                if ( !pendingBRsSent )
     
    218221                        // This is a tag to be removed if empty, so do not add it immediately.
    219222                        if ( isRemoveEmpty( element ) )
    220223                        {
     224                                // The element must be marked to be ignored if there is already another
     225                                // identical element to be used. (#8322)
     226                                for ( var i = 0 ; i < pendingInline.length ; i++ )
     227                                {
     228                                        if ( element.isIdentical( pendingInline[i] ) )
     229                                        {
     230                                                element.ignore = 1;
     231                                                break;
     232                                        }
     233                                }
     234
     235                                if ( !element.ignore )
     236                                {
     237                                        // The element must be marked to be ignored if there is already an
     238                                        // identical element on the parents tree. (#8322)
     239                                        var parent = currentNode;
     240                                        while ( parent )
     241                                        {
     242                                                if ( element.isIdentical( parent ) )
     243                                                        element.ignore = 1;
     244                                                parent = parent.parent;
     245                                        }
     246                                }
     247
    221248                                pendingInline.push( element );
    222249                                return;
    223250                        }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy