Skip to content

Commit

Permalink
fix: fix client code to work on IE11 (#812)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr authored Nov 29, 2023
1 parent 40b2917 commit 197e057
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/browser/client-scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/browser/client-scripts/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion src/browser/commands/scrollIntoView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export = async (browser: Browser) => {
options: ScrollIntoViewOptions | boolean = { block: "start", inline: "nearest" },
): Promise<void> {
await session.execute<Promise<void>, [WebdriverIO.Element, ScrollIntoViewOptions | boolean]>(
(elem, options) => elem.scrollIntoView(options),
function (elem, options) {
return elem.scrollIntoView(options);
},
this,
options,
);
Expand Down

0 comments on commit 197e057

Please sign in to comment.