Skip to content

Commit dd77482

Browse files
authored
Tests: Test for Shadow DOM v1 support
There was a test for Shadow DOM nodes working as root but it was using Shadow DOM v0 that only Chromium implements and which it plans to remove in the future. The test was reworked to rely on Shadow DOM v1. jQuery master already uses the new API in its tests. Closes gh-464
1 parent 102b3d6 commit dd77482

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

test/unit/selector.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,16 +1551,12 @@ QUnit.test( "select() with pre-compiled function", function( assert ) {
15511551
} );
15521552
} );
15531553

1554-
QUnit.test( "Sizzle supports shadow DOM nodes as root", function( assert ) {
1555-
if ( !document.documentElement.createShadowRoot ) {
1556-
assert.ok( true, "Shadow DOM not supported in this browser" );
1557-
return;
1558-
}
1559-
1554+
QUnit[ document.body.attachShadow && document.body.getRootNode ? "test" : "skip" ](
1555+
"Sizzle supports shadow DOM nodes as root", function( assert ) {
15601556
assert.expect( 2 );
15611557

1562-
var div = jQuery( "<div/>" ).appendTo( "#qunit-fixture" )[ 0 ],
1563-
shadowRoot = div.createShadowRoot();
1558+
var shadowHost = jQuery( "<div/>" ).appendTo( "#qunit-fixture" )[ 0 ],
1559+
shadowRoot = shadowHost.attachShadow( { mode: "open" } );
15641560

15651561
shadowRoot.innerHTML = "<div class='vagabond'><p></p></div>";
15661562
assert.equal( Sizzle( ".vagabond", shadowRoot ).length, 1,

0 commit comments

Comments
 (0)