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:
Andrey Lushnikov
2017-10-31 12:02:16 -07:00
committed by GitHub
parent 557aa940ec
commit c9a26e11f1
3 changed files with 24 additions and 1 deletions

View File

@@ -42,7 +42,7 @@ class ElementHandle extends JSHandle {
async _scrollIntoViewIfNeeded() {
const error = await this.executionContext().evaluate(element => {
if (!element.ownerDocument.contains(element))
if (!element.isConnected)
return 'Node is detached from document';
if (element.nodeType !== Node.ELEMENT_NODE)
return 'Node is not of type HTMLElement';