Ticket #8812: 8812_3.patch
File 8812_3.patch, 2.3 KB (added by , 13 years ago) |
---|
-
_source/plugins/selection/plugin.js
845 845 endIndex = siblings.length - 1, 846 846 index = -1, 847 847 position, 848 distance; 848 distance, 849 container; 849 850 850 851 // Binary search over all element childs to test the range to see whether 851 852 // range is right on the boundary of one element. … … 896 897 { 897 898 child = siblings[ siblings.length - 1 ]; 898 899 899 if ( child.nodeType == CKEDITOR.NODE_ELEMENT )900 if ( child.nodeType != CKEDITOR.NODE_TEXT ) 900 901 return { container : parent, offset : siblings.length }; 901 902 else 902 903 return { container : child, offset : child.nodeValue.length }; … … 904 905 905 906 // Start the measuring until distance overflows, meanwhile count the text nodes. 906 907 var i = siblings.length; 907 while ( distance > 0 ) 908 distance -= siblings[ --i ].nodeValue.length; 908 while ( distance > 0 && i > 0 ) 909 { 910 sibling = siblings[ --i ]; 911 if ( sibling.nodeType == CKEDITOR.NODE_TEXT ) 912 { 913 container = sibling; 914 distance -= sibling.nodeValue.length; 915 } 916 } 909 917 910 return { container : siblings[ i ], offset : -distance };918 return { container : container, offset : -distance }; 911 919 } 912 920 // Test range was one offset beyond OR behind the anchored text node. 913 921 else … … 932 940 try 933 941 { 934 942 sibling = child[ position > 0 ? 'previousSibling' : 'nextSibling' ]; 935 distance -= sibling.nodeValue.length; 943 if ( sibling.nodeType == CKEDITOR.NODE_TEXT ) 944 { 945 distance -= sibling.nodeValue.length; 946 container = sibling; 947 } 936 948 child = sibling; 937 949 } 938 950 // Measurement in IE could be somtimes wrong because of <select> element. (#4611) … … 942 954 } 943 955 } 944 956 945 return { container : c hild, offset : position > 0 ? -distance : child.nodeValue.length + distance };957 return { container : container, offset : position > 0 ? -distance : container.nodeValue.length + distance }; 946 958 } 947 959 }; 948 960