From 35159c8142a3ce925d987e4e226547ed8d647a7a Mon Sep 17 00:00:00 2001 From: shadowusr <58862284+shadowusr@users.noreply.github.com> Date: Tue, 28 Nov 2023 18:27:26 +0300 Subject: [PATCH] fix: fix client code to work on IE11 (#811) --- src/browser/client-scripts/index.js | 3 ++- src/browser/client-scripts/util.js | 3 ++- src/browser/commands/scrollIntoView.ts | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/browser/client-scripts/index.js b/src/browser/client-scripts/index.js index a5b7f3e32..4106d69d2 100644 --- a/src/browser/client-scripts/index.js +++ b/src/browser/client-scripts/index.js @@ -177,7 +177,8 @@ function disableFrameAnimationsUnsafe() { window.__cleanupAnimation = function () { for (var i = 0; i < styleElements.length; i++) { - styleElements[i].remove(); + // IE11 doesn't have remove() on node + styleElements[i].parentNode.removeChild(styleElements[i]); } delete window.__cleanupAnimation; diff --git a/src/browser/client-scripts/util.js b/src/browser/client-scripts/util.js index 337cc8760..e6438101a 100644 --- a/src/browser/client-scripts/util.js +++ b/src/browser/client-scripts/util.js @@ -93,7 +93,8 @@ exports.forEachRoot = function (cb) { function traverseRoots(root) { cb(root); - var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT); + // In IE 11, we need to pass the third and fourth arguments + var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, null, false); for (var node = treeWalker.currentNode; node !== null; node = treeWalker.nextNode()) { if (node instanceof Element && node.shadowRoot) { diff --git a/src/browser/commands/scrollIntoView.ts b/src/browser/commands/scrollIntoView.ts index 6fb1d915d..389c39326 100644 --- a/src/browser/commands/scrollIntoView.ts +++ b/src/browser/commands/scrollIntoView.ts @@ -14,7 +14,9 @@ export = async (browser: Browser): Promise => { options: ScrollIntoViewOptions | boolean = { block: "start", inline: "nearest" }, ): Promise { await session.execute, [WebdriverIO.Element, ScrollIntoViewOptions | boolean]>( - (elem, options) => elem.scrollIntoView(options), + function (elem, options) { + return elem.scrollIntoView(options); + }, this, options, );