mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-16 16:28:58 +00:00
support the composed option of getRootNode()
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
<p id="para"> And</p>
|
||||
<!--comment-->
|
||||
</div>
|
||||
<div id="rootNodeComposed"></div>
|
||||
</body>
|
||||
|
||||
<script src="../testing.js"></script>
|
||||
@@ -36,6 +37,26 @@ let first_child = content.firstChild.nextSibling; // nextSibling because of line
|
||||
testing.expectEqual('HTMLDocument', content.getRootNode().__proto__.constructor.name);
|
||||
</script>
|
||||
|
||||
<script id=getRootNodeComposed>
|
||||
const testContainer = $('#rootNodeComposed');
|
||||
const shadowHost = document.createElement('div');
|
||||
testContainer.appendChild(shadowHost);
|
||||
const shadowRoot = shadowHost.attachShadow({ mode: 'open' });
|
||||
const shadowChild = document.createElement('span');
|
||||
shadowRoot.appendChild(shadowChild);
|
||||
|
||||
testing.expectEqual('ShadowRoot', shadowChild.getRootNode().__proto__.constructor.name);
|
||||
testing.expectEqual('ShadowRoot', shadowChild.getRootNode({ composed: false }).__proto__.constructor.name);
|
||||
testing.expectEqual('HTMLDocument', shadowChild.getRootNode({ composed: true }).__proto__.constructor.name);
|
||||
testing.expectEqual('HTMLDocument', shadowHost.getRootNode().__proto__.constructor.name);
|
||||
|
||||
const disconnected = document.createElement('div');
|
||||
const disconnectedChild = document.createElement('span');
|
||||
disconnected.appendChild(disconnectedChild);
|
||||
testing.expectEqual('HTMLDivElement', disconnectedChild.getRootNode().__proto__.constructor.name);
|
||||
testing.expectEqual('HTMLDivElement', disconnectedChild.getRootNode({ composed: true }).__proto__.constructor.name);
|
||||
</script>
|
||||
|
||||
<script id=firstChild>
|
||||
let body_first_child = document.body.firstChild;
|
||||
testing.expectEqual('div', body_first_child.localName);
|
||||
|
||||
Reference in New Issue
Block a user