X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fhtmlparser%2Ffragment.js;h=bfa5cc57925c31bcd800e086e33f45a154e07f5c;hb=refs%2Ftags%2Fv3.6.1;hp=8c3ad5d3b960f98564078c2e139cfc93b6280f91;hpb=4e90e78dc97789709ee7404359a5517540c27553;p=ckeditor.git diff --git a/_source/core/htmlparser/fragment.js b/_source/core/htmlparser/fragment.js index 8c3ad5d..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 ] ) @@ -360,8 +364,8 @@ CKEDITOR.htmlParser.fragment = function() parser.onText = function( text ) { - // Trim empty spaces at beginning of element contents except
    .
    -			if ( !currentNode._.hasInlineStarted && !inPre )
    +			// Trim empty spaces at beginning of text contents except 
    .
    +			if ( ( !currentNode._.hasInlineStarted || pendingBRs.length ) && !inPre )
     			{
     				text = CKEDITOR.tools.ltrim( text );
     
    @@ -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 );
     		},