diff options
author | Sam Potts <sam@selz.com> | 2017-10-25 23:54:10 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-25 23:54:10 +1100 |
commit | 34d28a69ad9720ccf7e3a25967cc1ef631de0585 (patch) | |
tree | e018c816479199ffeb064a8ed53e34e77765db15 | |
parent | 57517a9dcc7ce75aef455b157fb6d1b97eab4e79 (diff) | |
parent | 542095f5eb9f2d81e9d0ff533529d7b08a1a07e1 (diff) | |
download | plyr-34d28a69ad9720ccf7e3a25967cc1ef631de0585.tar.lz plyr-34d28a69ad9720ccf7e3a25967cc1ef631de0585.tar.xz plyr-34d28a69ad9720ccf7e3a25967cc1ef631de0585.zip |
Merge pull request #693 from friday/fix/instanceof-undefined
v3: Add instanceof wrapper to avoid TypeErrors
-rw-r--r-- | src/js/plyr.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index 59e8c8ef..a563e345 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -373,10 +373,10 @@ return input !== null && input instanceof Event; }, cue: function(input) { - return input !== null && (input instanceof window.TextTrackCue || input instanceof window.VTTCue); + this.instanceOf(input, window.TextTrackCue) || this.instanceOf(input, window.VTTCue); }, track: function(input) { - return input !== null && (input instanceof window.TextTrack || typeof input.kind === 'string'); + return input !== null && (this.instanceOf(input, window.TextTrack) || typeof input.kind === 'string'); }, undefined: function(input) { return input !== null && typeof input === 'undefined'; @@ -389,6 +389,9 @@ (this.object(input) && Object.keys(input).length === 0) ); }, + instanceOf: function(input, constructor) { + return Boolean(input && constructor && input instanceof constructor); + }, }, // Credits: http://paypal.github.io/accessible-html5-video-player/ |