X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fcore%2Fhtmlparser%2Ffragment.js;h=bfa5cc57925c31bcd800e086e33f45a154e07f5c;hp=3dfc7880acadc3ecf0f3e543eb874f766dcedf6a;hb=f0610347140239143439a511ee2bd48cb784f470;hpb=4e70ea24db840898be8cc21c950363a52a2a6aba diff --git a/_source/core/htmlparser/fragment.js b/_source/core/htmlparser/fragment.js index 3dfc788..bfa5cc5 100644 --- a/_source/core/htmlparser/fragment.js +++ b/_source/core/htmlparser/fragment.js @@ -41,6 +41,9 @@ CKEDITOR.htmlParser.fragment = function() // parser fixing. 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 ); + // IE < 8 don't output the close tag on definition list items. (#6975) + var optionalCloseTags = CKEDITOR.env.ie && CKEDITOR.env.version < 8 ? { dd : 1, dt :1 } : {}; + var listBlocks = { ol:1, ul:1 }; // Dtd of the fragment element, basically it accept anything except for intermediate structure, e.g. orphan
  • . @@ -193,7 +196,8 @@ CKEDITOR.htmlParser.fragment = function() if ( element.isUnknown && selfClosing ) element.isEmpty = true; - element.isOptionalClose = optionalClose; + // Check for optional closed elements, including browser quirks and manually opened blocks. + element.isOptionalClose = tagName in optionalCloseTags || optionalClose; // This is a tag to be removed if empty, so do not add it immediately. if ( CKEDITOR.dtd.$removeEmpty[ tagName ] ) @@ -420,13 +424,14 @@ CKEDITOR.htmlParser.fragment = function() * following types: {@link CKEDITOR.htmlParser.element}, * {@link CKEDITOR.htmlParser.text} and * {@link CKEDITOR.htmlParser.comment}. + * @param {Number} [index] From where the insertion happens. * @example */ - add : function( node ) + add : function( node, index ) { - var len = this.children.length, - previous = len > 0 && this.children[ len - 1 ] || null; + isNaN( index ) && ( index = this.children.length ); + var previous = index > 0 ? this.children[ index - 1 ] : null; if ( previous ) { // If the block to be appended is following text, trim spaces at @@ -451,7 +456,7 @@ CKEDITOR.htmlParser.fragment = function() node.previous = previous; node.parent = this; - this.children.push( node ); + this.children.splice( index, 0, node ); this._.hasInlineStarted = node.type == CKEDITOR.NODE_TEXT || ( node.type == CKEDITOR.NODE_ELEMENT && !node._.isBlockLike ); },