Loosen WebElementCondition instance checks
* 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
@@ -71,6 +71,20 @@ class Condition {
description() {
return this.description_;
}
+
+ /**
+ * Allows for lenient instanceof checks
+ * @param {!(IThenable<T>|
+ * Condition<T>|
+ * function(!WebDriver): T)} condition - the condition instance
+ * @return {boolean}
+ */
+ static [Symbol.hasInstance](condition) {
+ return !!condition
+ && typeof condition === 'object'
+ && typeof condition.description === 'function'
+ && typeof condition.fn === 'function';
+ }
}
