mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Selector: Use shallow document comparisons in uniqueSort
IE/Edge sometimes crash when comparing documents between frames using the strict equality operator (`===` & `!==`). Funnily enough, shallow comparisons (`==` & `!=`) work without crashing. The change to shallow comparisons in `src/selector.js` was done in gh-4471 but relevant changes in `src/selector/uniqueSort.js` were missed. Those changes have landed in Sizzle in jquery/sizzle#459. Fixes gh-4441 Closes gh-4512 Ref gh-4471 Ref jquery/sizzle#459
This commit is contained in:
parent
f09d92100f
commit
15750b0af2
@ -24,7 +24,11 @@ function sortOrder( a, b ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate position if both inputs belong to the same document
|
// Calculate position if both inputs belong to the same document
|
||||||
compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
|
// Support: IE 11+, Edge 17 - 18+
|
||||||
|
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
|
||||||
|
// two documents; shallow comparisons work.
|
||||||
|
// eslint-disable-next-line eqeqeq
|
||||||
|
compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
|
||||||
a.compareDocumentPosition( b ) :
|
a.compareDocumentPosition( b ) :
|
||||||
|
|
||||||
// Otherwise we know they are disconnected
|
// Otherwise we know they are disconnected
|
||||||
@ -34,11 +38,20 @@ function sortOrder( a, b ) {
|
|||||||
if ( compare & 1 ) {
|
if ( compare & 1 ) {
|
||||||
|
|
||||||
// Choose the first element that is related to the document
|
// Choose the first element that is related to the document
|
||||||
if ( a === document || a.ownerDocument === document &&
|
// Support: IE 11+, Edge 17 - 18+
|
||||||
|
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
|
||||||
|
// two documents; shallow comparisons work.
|
||||||
|
// eslint-disable-next-line eqeqeq
|
||||||
|
if ( a == document || a.ownerDocument == document &&
|
||||||
jQuery.contains( document, a ) ) {
|
jQuery.contains( document, a ) ) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ( b === document || b.ownerDocument === document &&
|
|
||||||
|
// Support: IE 11+, Edge 17 - 18+
|
||||||
|
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
|
||||||
|
// two documents; shallow comparisons work.
|
||||||
|
// eslint-disable-next-line eqeqeq
|
||||||
|
if ( b == document || b.ownerDocument == document &&
|
||||||
jQuery.contains( document, b ) ) {
|
jQuery.contains( document, b ) ) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user