X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fcore%2Fhtmlparser%2Ffragment.js;h=66bb3be0e9f8d848f29e8744e630a5aca630a400;hp=fd16218699ccc1cc282de1037f953371227cd120;hb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d;hpb=8761695d9b70afe75905deaac88f78c1f8aeb32d diff --git a/_source/core/htmlparser/fragment.js b/_source/core/htmlparser/fragment.js index fd16218..66bb3be 100644 --- a/_source/core/htmlparser/fragment.js +++ b/_source/core/htmlparser/fragment.js @@ -264,8 +264,18 @@ CKEDITOR.htmlParser.fragment = function() parser.onTagClose = function( tagName ) { - var index = 0, - pendingAdd = [], + // Check if there is any pending tag to be closed. + for ( var i = pendingInline.length - 1 ; i >= 0 ; i-- ) + { + // If found, just remove it from the list. + if ( tagName == pendingInline[ i ].name ) + { + pendingInline.splice( i, 1 ); + return; + } + } + + var pendingAdd = [], candidate = currentNode; while ( candidate.type && candidate.name != tagName ) @@ -273,14 +283,8 @@ CKEDITOR.htmlParser.fragment = function() // If this is an inline element, add it to the pending list, so // it will continue after the closing tag. if ( !candidate._.isBlockLike ) - { pendingInline.unshift( candidate ); - // Increase the index, so it will not get checked again in - // the pending list check that follows. - index++; - } - // This node should be added to it's parent at this point. But, // it should happen only if the closing tag is really closing // one of the nodes. So, for now, we just cache it. @@ -292,7 +296,7 @@ CKEDITOR.htmlParser.fragment = function() if ( candidate.type ) { // Add all elements that have been found in the above loop. - for ( var i = 0 ; i < pendingAdd.length ; i++ ) + for ( i = 0 ; i < pendingAdd.length ; i++ ) { var node = pendingAdd[ i ]; addElement( node, node.parent ); @@ -310,26 +314,6 @@ CKEDITOR.htmlParser.fragment = function() if ( candidate == currentNode ) currentNode = currentNode.parent; } - // The tag is not actually closing anything, thus we need invalidate - // the pending elements.(#3862) - else - { - pendingInline.splice( 0, index ); - index = 0; - } - - // Check if there is any pending tag to be closed. - for ( ; index < pendingInline.length ; index++ ) - { - // If found, just remove it from the list. - if ( tagName == pendingInline[ index ].name ) - { - pendingInline.splice( index, 1 ); - - // Decrease the index so we continue from the next one. - index--; - } - } }; parser.onText = function( text )