Ticket #1414: 1414.patch

File 1414.patch, 1.1 KB (added by fredck, 15 months ago)

Proposed changes to the "pre" element processor

  • editor/_source/internals/fckxhtml.js

     
    377377 
    378378        pre : function ( node, htmlNode ) 
    379379        { 
    380                 for ( var i = 0 ; i < htmlNode.childNodes.length ; i++ ) 
    381                 { 
    382                         var item = htmlNode.childNodes[i] ; 
    383                         var val = item.nodeValue ; 
    384                         if ( item.nodeType == 3 && i == 0 ) 
    385                         { 
    386                                 // We shouldn't put the plain text value of the text node directly into HTML. (See #1414) 
    387                                 var dummyNode = document.createElement( 'pre' ) ; 
    388                                 dummyNode.appendChild( document.createTextNode( val ) ) ; 
    389                                 node.appendChild( FCKXHtml.XML.createTextNode( FCKXHtml._AppendSpecialItem( '\r\n' + dummyNode.innerHTML ) ) ) ; 
    390                         } 
    391                         else 
    392                                 FCKXHtml._AppendNode( node, item ) ; 
    393                 } 
     380                var firstChild = htmlNode.firstChild ; 
     381 
     382                if ( firstChild && firstChild.nodeType == 3 ) 
     383                        node.appendChild( FCKXHtml.XML.createTextNode( FCKXHtml._AppendSpecialItem( '\r\n' ) ) ) ; 
     384 
     385                FCKXHtml._AppendChildNodes( node, htmlNode, true ) ; 
     386 
    394387                return node ; 
    395388        }, 
    396389