Skip to content

Commit 5ec8094

Browse files
afsmith92jleyba
authored andcommitted
Loosen WebElementCondition instance checks (SeleniumHQ#5968)
* Loosen WebElementCondition instance checks Update WebElementCondition and Condition with custom static hasInstance methods so that `instanceof` checks are more lenient and don't cause issues with Babel. Fixes SeleniumHQ#5560
1 parent bfd4dcc commit 5ec8094

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎javascript/node/selenium-webdriver/lib/webdriver.js‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ class Condition {
7171
description() {
7272
return this.description_;
7373
}
74+
75+
/**
76+
* Allows for lenient instanceof checks
77+
* @param {!(IThenable<T>|
78+
* Condition<T>|
79+
* function(!WebDriver): T)} condition - the condition instance
80+
* @return {boolean}
81+
*/
82+
static [Symbol.hasInstance](condition) {
83+
return !!condition
84+
&& typeof condition === 'object'
85+
&& typeof condition.description === 'function'
86+
&& typeof condition.fn === 'function';
87+
}
7488
}
7589

7690

0 commit comments

Comments
 (0)