Changeset 2203 for FCKeditor/branches

Show
Ignore:
Timestamp:
2008-07-11 08:10:30 (4 months ago)
Author:
martinkou
Message:

Fixed the issue where nested DIV containers may be incorrectly selected.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/branches/features/div_container/editor/_source/internals/fckdomtools.js

    r2201 r2203  
    10321032                var endNode = range.EndNode ; 
    10331033                var elementMarkers = {} ; 
    1034  
    1035                 var startPath = new FCKElementPath( startNode ) ; 
    1036                 if ( startPath.BlockLimit && startPath.BlockLimit.nodeName.IEquals( 'div' ) ) 
    1037                         startNode = startPath.BlockLimit ; 
    10381034                var currentNode = startNode ; 
    1039  
    1040                 do 
    1041                 { 
    1042                         var child = currentNode.firstChild ; 
    1043                         while ( child && child.nodeType != 1 ) 
    1044                                 child = child.nextSibling ; 
    1045  
    1046                         if ( currentNode.nodeName.IEquals( 'div' ) && child && 
    1047                                         FCKListsLib.BlockElements[ child.nodeName.toLowerCase() ] ) 
    1048                         { 
    1049                                 // This is a block limit node. 
    1050                                 currentBlocks.push( currentNode ) ; 
    1051                                 if ( currentNode.parentNode.nodeName.IEquals( 'div' ) ) 
    1052                                         FCKDomTools.SetElementMarker( elementMarkers, currentNode.parentNode, 
    1053                                                         '_fckignorethisnode', true ) ; 
    1054                         } 
    1055                         else 
    1056                         { 
    1057                                 // This is not a block limit node. 
    1058                                 FCKDomTools.SetElementMarker( elementMarkers, currentNode.parentNode, 
    1059                                                 '_fckincludethisnode', true ) ; 
    1060                         } 
    1061                 } 
    1062                 while ( ( currentNode = FCKDomTools.GetNextSourceElement( currentNode ) ) && currentNode != endNode 
    1063                                 && currentNode != endNode.parentNode ) ; 
    1064  
    1065                 for ( var i = currentBlocks.length - 1 ; i >= 0 ; i-- ) 
    1066                 { 
    1067                         if ( currentBlocks[i]['_fckignorethisnode'] && !currentBlocks[i]['_fckincludethisnode'] ) 
    1068                                 currentBlocks.splice( i, 1 ) ; 
     1035                 
     1036                if ( startNode == endNode ) 
     1037                { 
     1038                        while ( endNode.lastChild ) 
     1039                                endNode = endNode.lastChild ; 
     1040                        endNode = FCKDomTools.GetNextSourceElement( endNode ) ; 
     1041                } 
     1042 
     1043                while ( currentNode != endNode && currentNode != endNode.parentNode ) 
     1044                { 
     1045                        var path = new FCKElementPath( currentNode ) ; 
     1046                        var blockLimit = path.BlockLimit ; 
     1047                        if ( blockLimit && blockLimit.nodeName.IEquals( 'div' ) && !blockLimit['_fckdivincluded'] ) 
     1048                        { 
     1049                                currentBlocks.push( blockLimit ) ; 
     1050                                FCKDomTools.SetElementMarker( elementMarkers, blockLimit, '_fckdivincluded', true ) ; 
     1051                        } 
     1052 
     1053                        currentNode = FCKDomTools.GetNextSourceElement( currentNode ) ; 
    10691054                } 
    10701055