diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2019-04-29 19:54:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-29 19:54:12 +0200 |
commit | 7dddb19ca4bca9685adb734c76dcf72c3f610007 (patch) | |
tree | 4aaf9854dc5f2d13ad4335031fec13c9117994ef | |
parent | 6c1e7dbf7311ae7c0c31ba335fe216185047ae5f (diff) | |
download | jquery-7dddb19ca4bca9685adb734c76dcf72c3f610007.tar.gz jquery-7dddb19ca4bca9685adb734c76dcf72c3f610007.zip |
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
-rw-r--r-- | src/core/isAttached.js | 6 | ||||
-rw-r--r-- | test/unit/css.js | 12 | ||||
-rw-r--r-- | test/unit/effects.js | 7 |
3 files changed, 20 insertions, 5 deletions
diff --git a/src/core/isAttached.js b/src/core/isAttached.js index efa2465a9..bd525194a 100644 --- a/src/core/isAttached.js +++ b/src/core/isAttached.js @@ -10,8 +10,12 @@ define( [ }, composed = { composed: true }; + // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only // Check attachment across shadow DOM boundaries when possible (gh-3504) - if ( documentElement.attachShadow ) { + // Support: iOS 10.0-10.2 only + // Early iOS 10 versions support `attachShadow` but not `getRootNode`, + // leading to errors. We need to check for `getRootNode`. + if ( documentElement.getRootNode ) { isAttached = function( elem ) { return jQuery.contains( elem.ownerDocument, elem ) || elem.getRootNode( composed ) === elem.ownerDocument; diff --git a/test/unit/css.js b/test/unit/css.js index e7acd1915..13de4704b 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -641,7 +641,11 @@ QUnit.test( "show/hide detached nodes", function( assert ) { span.remove(); } ); -QUnit[ document.body.attachShadow ? "test" : "skip" ]( "show/hide shadow child nodes", function( assert ) { +QUnit[ + document.body.attachShadow && document.body.getRootNode ? + "test" : + "skip" + ]( "show/hide shadow child nodes", function( assert ) { assert.expect( 28 ); jQuery( "<div id='shadowHost'></div>" ).appendTo( "#qunit-fixture" ); var shadowHost = document.querySelector( "#shadowHost" ); @@ -1023,7 +1027,11 @@ QUnit[ jQuery.find.compile && jQuery.fn.toggle ? "test" : "skip" ]( "detached to "cascade-hidden element in detached tree" ); } ); -QUnit[ jQuery.find.compile && jQuery.fn.toggle && document.body.attachShadow ? "test" : "skip" ]( "shadow toggle()", function( assert ) { +QUnit[ jQuery.find.compile && jQuery.fn.toggle && + document.body.attachShadow && document.body.getRootNode ? + "test" : + "skip" +]( "shadow toggle()", function( assert ) { assert.expect( 4 ); jQuery( "<div id='shadowHost'></div>" ).appendTo( "#qunit-fixture" ); var shadowHost = document.querySelector( "#shadowHost" ); diff --git a/test/unit/effects.js b/test/unit/effects.js index f71eafb62..ba11eabf5 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -221,8 +221,11 @@ supportjQuery.each( hideOptions, function( type, setup ) { assert.expectJqData( this, $span, "olddisplay" ); } ); - QUnit[ document.body.attachShadow ? "test" : "skip" ]( - "Persist correct display value - " + type + " hidden, shadow child", function( assert ) { + QUnit[ + document.body.attachShadow && document.body.getRootNode ? + "test" : + "skip" + ]( "Persist correct display value - " + type + " hidden, shadow child", function( assert ) { assert.expect( 3 ); jQuery( "<div id='shadowHost'></div>" ).appendTo( "#qunit-fixture" ); |