aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndre Gagnon <ajgagnon@uwalumni.com>2021-01-23 17:32:45 -0600
committerGitHub <noreply@github.com>2021-01-24 10:32:45 +1100
commit16c134fc1e1c1a6938c2d86d8e884530a0ad4711 (patch)
tree70b5c5fe94911e4d9559151c86a36e05d8f753c3 /src
parentf00e81a97607350ccc48ff6b83c21c20b199eb12 (diff)
downloadplyr-16c134fc1e1c1a6938c2d86d8e884530a0ad4711.tar.lz
plyr-16c134fc1e1c1a6938c2d86d8e884530a0ad4711.tar.xz
plyr-16c134fc1e1c1a6938c2d86d8e884530a0ad4711.zip
Fix to work inside iframes. (#2069)
* Fix to work inside iframes. Right now Plyr fails to load inside iframes because the selectors are not instances of Element (iframes have their own, separate globals). This is an alternative method to check isElement that will work inside iframes. This is battle-tested fallback code used before browsers supported HTMLElement. * Update is.js
Diffstat (limited to 'src')
-rw-r--r--src/js/utils/is.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/js/utils/is.js b/src/js/utils/is.js
index 3bb50a00..5a60da06 100644
--- a/src/js/utils/is.js
+++ b/src/js/utils/is.js
@@ -13,7 +13,6 @@ const isFunction = (input) => getConstructor(input) === Function;
const isArray = (input) => Array.isArray(input);
const isWeakMap = (input) => instanceOf(input, WeakMap);
const isNodeList = (input) => instanceOf(input, NodeList);
-const isElement = (input) => instanceOf(input, Element);
const isTextNode = (input) => getConstructor(input) === Text;
const isEvent = (input) => instanceOf(input, Event);
const isKeyboardEvent = (input) => instanceOf(input, KeyboardEvent);
@@ -21,6 +20,13 @@ const isCue = (input) => instanceOf(input, window.TextTrackCue) || instanceOf(in
const isTrack = (input) => instanceOf(input, TextTrack) || (!isNullOrUndefined(input) && isString(input.kind));
const isPromise = (input) => instanceOf(input, Promise) && isFunction(input.then);
+const isElement = (input) =>
+ input !== null &&
+ (typeof input === "object") &&
+ (input.nodeType === 1) &&
+ (typeof input.style === "object") &&
+ (typeof input.ownerDocument === "object");
+
const isEmpty = (input) =>
isNullOrUndefined(input) ||
((isString(input) || isArray(input) || isNodeList(input)) && !input.length) ||