File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -692,20 +692,22 @@ if ( document.documentElement.compareDocumentPosition ) {
692
692
}
693
693
return ret ;
694
694
} ;
695
- } else if ( Array . prototype . indexOf ) {
696
- var indexOf = Array . prototype . indexOf ,
697
- allSort = document . getElementsByTagName ( "*" ) ;
698
-
695
+ } else if ( "sourceIndex" in document . documentElement ) {
699
696
sortOrder = function ( a , b ) {
700
- var ret = indexOf . call ( allSort , a ) - indexOf . call ( allSort , b ) ;
697
+ var ret = a . sourceIndex - b . sourceIndex ;
701
698
if ( ret === 0 ) {
702
699
hasDuplicate = true ;
703
700
}
704
701
return ret ;
705
702
} ;
706
- } else if ( "sourceIndex" in document . documentElement ) {
703
+ } else if ( document . createRange ) {
707
704
sortOrder = function ( a , b ) {
708
- var ret = a . sourceIndex - b . sourceIndex ;
705
+ var aRange = a . ownerDocument . createRange ( ) , bRange = b . ownerDocument . createRange ( ) ;
706
+ aRange . selectNode ( a ) ;
707
+ aRange . collapse ( true ) ;
708
+ bRange . selectNode ( b ) ;
709
+ bRange . collapse ( true ) ;
710
+ var ret = aRange . compareBoundaryPoints ( Range . START_TO_END , bRange ) ;
709
711
if ( ret === 0 ) {
710
712
hasDuplicate = true ;
711
713
}
You can’t perform that action at this time.
0 commit comments