mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(ElementHandle): teach ElementHandle to work with shadowdom (#1227)
Elements in shadow dom erroneously considered that they were detached from document. This patch starts using `Element.isConnected` instead of `document.contains()` call. Fixes #1061.
This commit is contained in:
17
test/assets/shadow.html
Normal file
17
test/assets/shadow.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<script>
|
||||
|
||||
let h1 = null;
|
||||
let button = null;
|
||||
let clicked = false;
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
const shadowRoot = document.body.attachShadow({mode: 'open'});
|
||||
h1 = document.createElement('h1');
|
||||
h1.textContent = 'Hellow Shadow DOM v1';
|
||||
button = document.createElement('button');
|
||||
button.textContent = 'Click';
|
||||
button.addEventListener('click', () => clicked = true);
|
||||
shadowRoot.appendChild(h1);
|
||||
shadowRoot.appendChild(button);
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user