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 ) {
692692 }
693693 return ret ;
694694 } ;
695- } else if ( Array . prototype . indexOf ) {
696- var indexOf = Array . prototype . indexOf ,
697- allSort = document . getElementsByTagName ( "*" ) ;
698-
695+ } else if ( "sourceIndex" in document . documentElement ) {
699696 sortOrder = function ( a , b ) {
700- var ret = indexOf . call ( allSort , a ) - indexOf . call ( allSort , b ) ;
697+ var ret = a . sourceIndex - b . sourceIndex ;
701698 if ( ret === 0 ) {
702699 hasDuplicate = true ;
703700 }
704701 return ret ;
705702 } ;
706- } else if ( "sourceIndex" in document . documentElement ) {
703+ } else if ( document . createRange ) {
707704 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 ) ;
709711 if ( ret === 0 ) {
710712 hasDuplicate = true ;
711713 }
You can’t perform that action at this time.
0 commit comments