JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.1
[ckeditor.git] / _source / core / htmlparser / fragment.js
index 244e298..f94f4e9 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -108,9 +108,9 @@ CKEDITOR.htmlParser.fragment = function()
                        }\r
                }\r
 \r
-               function sendPendingBRs()\r
+               function sendPendingBRs( brsToIgnore )\r
                {\r
-                       while ( pendingBRs.length )\r
+                       while ( pendingBRs.length - ( brsToIgnore || 0 ) > 0 )\r
                                currentNode.add( pendingBRs.shift() );\r
                }\r
 \r
@@ -118,20 +118,19 @@ CKEDITOR.htmlParser.fragment = function()
                {\r
                        target = target || currentNode || fragment;\r
 \r
-                       // If the target is the fragment and this element can't go inside\r
+                       // If the target is the fragment and this inline element can't go inside\r
                        // body (if fixForBody).\r
                        if ( fixForBody && !target.type )\r
                        {\r
                                var elementName, realElementName;\r
                                if ( element.attributes\r
                                         && ( realElementName =\r
-                                                 element.attributes[ '_cke_real_element_type' ] ) )\r
+                                                 element.attributes[ 'data-cke-real-element-type' ] ) )\r
                                        elementName = realElementName;\r
                                else\r
                                        elementName =  element.name;\r
-                               if ( elementName\r
-                                               && !( elementName in CKEDITOR.dtd.$body )\r
-                                               && !( elementName in CKEDITOR.dtd.$nonBodyContent )  )\r
+\r
+                               if ( elementName && elementName in CKEDITOR.dtd.$inline )\r
                                {\r
                                        var savedCurrent = currentNode;\r
 \r
@@ -237,6 +236,12 @@ CKEDITOR.htmlParser.fragment = function()
                                {\r
                                        addElement( currentNode, currentNode.parent );\r
                                }\r
+                               else if ( tagName in CKEDITOR.dtd.$listItem )\r
+                               {\r
+                                       parser.onTagOpen( 'ul', {} );\r
+                                       addPoint = currentNode;\r
+                                       reApply = true;\r
+                               }\r
                                else\r
                                {\r
                                        if ( nonBreakingBlocks[ currentName ] )\r
@@ -386,13 +391,16 @@ CKEDITOR.htmlParser.fragment = function()
 \r
                parser.onComment = function( comment )\r
                {\r
+                       sendPendingBRs();\r
+                       checkPending();\r
                        currentNode.add( new CKEDITOR.htmlParser.comment( comment ) );\r
                };\r
 \r
                // Parse it.\r
                parser.parse( fragmentHtml );\r
 \r
-               sendPendingBRs();\r
+               // Send all pending BRs except one, which we consider a unwanted bogus. (#5293)\r
+               sendPendingBRs( !CKEDITOR.env.ie && 1 );\r
 \r
                // Close all pending nodes.\r
                while ( currentNode.type )\r