Skip to content

Commit 7dddb19

Browse files
authored
Core: Make isAttached work with iOS 10.0-10.2
The test for Shadow DOM v1 support has been changed to rely on the presence of `documentElement.getRootNode` as iOS 10.0-10.2 supports `attachShadow` but doesn't support `getRootNode`. No new test is necessary - iOS 10.0 fails lots of our test suite because of this bug. Fixes gh-4356 Closes gh-4360
1 parent 6c1e7db commit 7dddb19

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/core/isAttached.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ define( [
1010
},
1111
composed = { composed: true };
1212

13+
// Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
1314
// Check attachment across shadow DOM boundaries when possible (gh-3504)
14-
if ( documentElement.attachShadow ) {
15+
// Support: iOS 10.0-10.2 only
16+
// Early iOS 10 versions support `attachShadow` but not `getRootNode`,
17+
// leading to errors. We need to check for `getRootNode`.
18+
if ( documentElement.getRootNode ) {
1519
isAttached = function( elem ) {
1620
return jQuery.contains( elem.ownerDocument, elem ) ||
1721
elem.getRootNode( composed ) === elem.ownerDocument;

test/unit/css.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,11 @@ QUnit.test( "show/hide detached nodes", function( assert ) {
641641
span.remove();
642642
} );
643643

644-
QUnit[ document.body.attachShadow ? "test" : "skip" ]( "show/hide shadow child nodes", function( assert ) {
644+
QUnit[
645+
document.body.attachShadow && document.body.getRootNode ?
646+
"test" :
647+
"skip"
648+
]( "show/hide shadow child nodes", function( assert ) {
645649
assert.expect( 28 );
646650
jQuery( "<div id='shadowHost'></div>" ).appendTo( "#qunit-fixture" );
647651
var shadowHost = document.querySelector( "#shadowHost" );
@@ -1023,7 +1027,11 @@ QUnit[ jQuery.find.compile && jQuery.fn.toggle ? "test" : "skip" ]( "detached to
10231027
"cascade-hidden element in detached tree" );
10241028
} );
10251029

1026-
QUnit[ jQuery.find.compile && jQuery.fn.toggle && document.body.attachShadow ? "test" : "skip" ]( "shadow toggle()", function( assert ) {
1030+
QUnit[ jQuery.find.compile && jQuery.fn.toggle &&
1031+
document.body.attachShadow && document.body.getRootNode ?
1032+
"test" :
1033+
"skip"
1034+
]( "shadow toggle()", function( assert ) {
10271035
assert.expect( 4 );
10281036
jQuery( "<div id='shadowHost'></div>" ).appendTo( "#qunit-fixture" );
10291037
var shadowHost = document.querySelector( "#shadowHost" );

test/unit/effects.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,11 @@ supportjQuery.each( hideOptions, function( type, setup ) {
221221
assert.expectJqData( this, $span, "olddisplay" );
222222
} );
223223

224-
QUnit[ document.body.attachShadow ? "test" : "skip" ](
225-
"Persist correct display value - " + type + " hidden, shadow child", function( assert ) {
224+
QUnit[
225+
document.body.attachShadow && document.body.getRootNode ?
226+
"test" :
227+
"skip"
228+
]( "Persist correct display value - " + type + " hidden, shadow child", function( assert ) {
226229
assert.expect( 3 );
227230

228231
jQuery( "<div id='shadowHost'></div>" ).appendTo( "#qunit-fixture" );

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy