JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.0.2
[ckeditor.git] / _source / core / htmlparser / fragment.js
index fd16218..66bb3be 100644 (file)
@@ -264,8 +264,18 @@ CKEDITOR.htmlParser.fragment = function()
 \r
                parser.onTagClose = function( tagName )\r
                {\r
-                       var index = 0,\r
-                               pendingAdd = [],\r
+                       // Check if there is any pending tag to be closed.\r
+                       for ( var i = pendingInline.length - 1 ; i >= 0 ; i-- )\r
+                       {\r
+                               // If found, just remove it from the list.\r
+                               if ( tagName == pendingInline[ i ].name )\r
+                               {\r
+                                       pendingInline.splice( i, 1 );\r
+                                       return;\r
+                               }\r
+                       }\r
+\r
+                       var pendingAdd = [],\r
                                candidate = currentNode;\r
 \r
                        while ( candidate.type && candidate.name != tagName )\r
@@ -273,14 +283,8 @@ CKEDITOR.htmlParser.fragment = function()
                                // If this is an inline element, add it to the pending list, so\r
                                // it will continue after the closing tag.\r
                                if ( !candidate._.isBlockLike )\r
-                               {\r
                                        pendingInline.unshift( candidate );\r
 \r
-                                       // Increase the index, so it will not get checked again in\r
-                                       // the pending list check that follows.\r
-                                       index++;\r
-                               }\r
-\r
                                // This node should be added to it's parent at this point. But,\r
                                // it should happen only if the closing tag is really closing\r
                                // one of the nodes. So, for now, we just cache it.\r
@@ -292,7 +296,7 @@ CKEDITOR.htmlParser.fragment = function()
                        if ( candidate.type )\r
                        {\r
                                // Add all elements that have been found in the above loop.\r
-                               for ( var i = 0 ; i < pendingAdd.length ; i++ )\r
+                               for ( i = 0 ; i < pendingAdd.length ; i++ )\r
                                {\r
                                        var node = pendingAdd[ i ];\r
                                        addElement( node, node.parent );\r
@@ -310,26 +314,6 @@ CKEDITOR.htmlParser.fragment = function()
                                if ( candidate == currentNode )\r
                                        currentNode = currentNode.parent;\r
                        }\r
-                       // The tag is not actually closing anything, thus we need invalidate\r
-                       // the pending elements.(#3862)\r
-                       else\r
-                       {\r
-                               pendingInline.splice( 0, index );\r
-                               index = 0;\r
-                       }\r
-\r
-                       // Check if there is any pending tag to be closed.\r
-                       for ( ; index < pendingInline.length ; index++ )\r
-                       {\r
-                               // If found, just remove it from the list.\r
-                               if ( tagName == pendingInline[ index ].name )\r
-                               {\r
-                                       pendingInline.splice( index, 1 );\r
-\r
-                                       // Decrease the index so we continue from the next one.\r
-                                       index--;\r
-                               }\r
-                       }\r
                };\r
 \r
                parser.onText = function( text )\r