JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.1
[ckeditor.git] / _source / core / htmlparser / fragment.js
index 3dfc788..bfa5cc5 100644 (file)
@@ -41,6 +41,9 @@ CKEDITOR.htmlParser.fragment = function()
        // parser fixing.\r
        var nonBreakingBlocks = CKEDITOR.tools.extend( { table:1,ul:1,ol:1,dl:1 }, CKEDITOR.dtd.table, CKEDITOR.dtd.ul, CKEDITOR.dtd.ol, CKEDITOR.dtd.dl );\r
 \r
+       // IE < 8 don't output the close tag on definition list items. (#6975)\r
+       var optionalCloseTags = CKEDITOR.env.ie && CKEDITOR.env.version < 8 ? { dd : 1, dt :1 } : {};\r
+\r
        var listBlocks = { ol:1, ul:1 };\r
 \r
        // Dtd of the fragment element, basically it accept anything except for intermediate structure, e.g. orphan <li>.\r
@@ -193,7 +196,8 @@ CKEDITOR.htmlParser.fragment = function()
                        if ( element.isUnknown && selfClosing )\r
                                element.isEmpty = true;\r
 \r
-                       element.isOptionalClose = optionalClose;\r
+                       // Check for optional closed elements, including browser quirks and manually opened blocks.\r
+                       element.isOptionalClose = tagName in optionalCloseTags || optionalClose;\r
 \r
                        // This is a tag to be removed if empty, so do not add it immediately.\r
                        if ( CKEDITOR.dtd.$removeEmpty[ tagName ] )\r
@@ -420,13 +424,14 @@ CKEDITOR.htmlParser.fragment = function()
                 *              following types: {@link CKEDITOR.htmlParser.element},\r
                 *              {@link CKEDITOR.htmlParser.text} and\r
                 *              {@link CKEDITOR.htmlParser.comment}.\r
+                *      @param {Number} [index] From where the insertion happens.\r
                 * @example\r
                 */\r
-               add : function( node )\r
+               add : function( node, index )\r
                {\r
-                       var len = this.children.length,\r
-                               previous = len > 0 && this.children[ len - 1 ] || null;\r
+                       isNaN( index ) && ( index = this.children.length );\r
 \r
+                       var previous = index > 0 ? this.children[ index - 1 ] : null;\r
                        if ( previous )\r
                        {\r
                                // If the block to be appended is following text, trim spaces at\r
@@ -451,7 +456,7 @@ CKEDITOR.htmlParser.fragment = function()
                        node.previous = previous;\r
                        node.parent = this;\r
 \r
-                       this.children.push( node );\r
+                       this.children.splice( index, 0, node );\r
 \r
                        this._.hasInlineStarted = node.type == CKEDITOR.NODE_TEXT || ( node.type == CKEDITOR.NODE_ELEMENT && !node._.isBlockLike );\r
                },\r