Ticket #7470: 7470.patch
File 7470.patch, 2.8 KB (added by , 14 years ago) |
---|
-
_source/core/htmlparser/fragment.js
112 112 } 113 113 114 114 /* 115 * Beside of simply append specified element to target, italso takes115 * Beside of simply append specified element to target, this function also takes 116 116 * care of other dirty lifts like forcing block in body, trimming spaces at 117 117 * the block boundaries etc. 118 118 * 119 * Note: This function should NOT change the "currentNode" global unless 120 * there's a return point node specified on the element. 119 * @param {Element} element The element to be added as the last child of {@link target}. 120 * @param {Element} target The parent element to relieve the new node. 121 * @param {Boolean} [moveCurrent=false] Don't change the "currentNode" global unless 122 * there's a return point node specified on the element, otherwise move current onto {@link target} node. 121 123 */ 122 function addElement( element, target )124 function addElement( element, target, moveCurrent ) 123 125 { 124 126 // Ignore any element that has already been added. 125 127 if ( element.previous !== undefined ) … … 150 152 parser.onTagOpen( fixForBody, {} ); 151 153 152 154 // The new target now is the <p>. 153 target = currentNode;155 element.returnPoint = target = currentNode; 154 156 } 155 157 } 156 158 … … 179 181 delete element.returnPoint; 180 182 } 181 183 else 182 currentNode = savedCurrent;184 currentNode = moveCurrent ? target : savedCurrent; 183 185 } 184 186 185 187 parser.onTagOpen = function( tagName, attributes, selfClosing ) … … 258 260 // The most common case where we just need to close the 259 261 // current one and append the new one to the parent. 260 262 if ( currentNode.parent ) 261 { 262 addElement( currentNode, currentNode.parent ); 263 currentNode = currentNode.parent; 264 } 263 addElement( currentNode, currentNode.parent, 1 ); 265 264 // We've tried our best to fix the embarrassment here, while 266 265 // this element still doesn't find it's parent, mark it as 267 266 // orphan and show our tolerance to it. … … 399 398 // Send all pending BRs except one, which we consider a unwanted bogus. (#5293) 400 399 sendPendingBRs( !CKEDITOR.env.ie && 1 ); 401 400 402 // Close all pending nodes .401 // Close all pending nodes, make sure return point is properly restored. 403 402 while ( currentNode != fragment ) 404 { 405 // Make sure return point is properly restored. 406 var returnPoint = currentNode.returnPoint; 407 addElement( currentNode, currentNode.parent ); 408 currentNode = returnPoint || currentNode.parent; 409 } 403 addElement( currentNode, currentNode.parent, 1 ); 410 404 411 405 return fragment; 412 406 };