Ticket #4690: 4690_3.patch

File 4690_3.patch, 2.0 KB (added by Frederico Caldeira Knabben, 14 years ago)
  • _source/core/htmlparser/fragment.js

     
    264264
    265265                parser.onTagClose = function( tagName )
    266266                {
    267                         var index = 0,
    268                                 pendingAdd = [],
     267                        // Check if there is any pending tag to be closed.
     268                        for ( var i = pendingInline.length - 1 ; i >= 0 ; i-- )
     269                        {
     270                                // If found, just remove it from the list.
     271                                if ( tagName == pendingInline[ i ].name )
     272                                {
     273                                        pendingInline.splice( i, 1 );
     274                                        return;
     275                                }
     276                        }
     277
     278                        var pendingAdd = [],
    269279                                candidate = currentNode;
    270280
    271281                        while ( candidate.type && candidate.name != tagName )
     
    273283                                // If this is an inline element, add it to the pending list, so
    274284                                // it will continue after the closing tag.
    275285                                if ( !candidate._.isBlockLike )
    276                                 {
    277286                                        pendingInline.unshift( candidate );
    278287
    279                                         // Increase the index, so it will not get checked again in
    280                                         // the pending list check that follows.
    281                                         index++;
    282                                 }
    283 
    284288                                // This node should be added to it's parent at this point. But,
    285289                                // it should happen only if the closing tag is really closing
    286290                                // one of the nodes. So, for now, we just cache it.
     
    310314                                if ( candidate == currentNode )
    311315                                        currentNode = currentNode.parent;
    312316                        }
    313                         // The tag is not actually closing anything, thus we need invalidate
    314                         // the pending elements.(#3862)
    315                         else
    316                         {
    317                                 pendingInline.splice( 0, index );
    318                                 index = 0;
    319                         }
    320 
    321                         // Check if there is any pending tag to be closed.
    322                         for ( ; index < pendingInline.length ; index++ )
    323                         {
    324                                 // If found, just remove it from the list.
    325                                 if ( tagName == pendingInline[ index ].name )
    326                                 {
    327                                         pendingInline.splice( index, 1 );
    328 
    329                                         // Decrease the index so we continue from the next one.
    330                                         index--;
    331                                 }
    332                         }
    333317                };
    334318
    335319                parser.onText = function( text )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy