diff options
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/captions.js | 7 | ||||
-rw-r--r-- | src/js/fullscreen.js | 2 | ||||
-rw-r--r-- | src/js/plugins/ads.js | 12 | ||||
-rw-r--r-- | src/js/plugins/preview-thumbnails.js | 8 | ||||
-rw-r--r-- | src/js/utils/elements.js | 2 | ||||
-rw-r--r-- | src/js/utils/is.js | 2 | ||||
-rw-r--r-- | src/js/utils/promise.js | 23 |
7 files changed, 21 insertions, 35 deletions
diff --git a/src/js/captions.js b/src/js/captions.js index 724def9e..04da4651 100644 --- a/src/js/captions.js +++ b/src/js/captions.js @@ -151,8 +151,11 @@ const captions = { toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is.empty(tracks)); // Update available languages in list - if ((is.array(this.config.controls) && this.config.controls.includes('settings')) - && this.config.settings.includes('captions')) { + if ( + is.array(this.config.controls) && + this.config.controls.includes('settings') && + this.config.settings.includes('captions') + ) { controls.setCaptionsMenu.call(this); } }, diff --git a/src/js/fullscreen.js b/src/js/fullscreen.js index d92552e2..4d3c89ac 100644 --- a/src/js/fullscreen.js +++ b/src/js/fullscreen.js @@ -119,7 +119,7 @@ class Fullscreen { const element = !this.prefix ? document.fullscreenElement : document[`${this.prefix}${this.property}Element`]; - return (element && element.shadowRoot) ? element === this.target.getRootNode().host : element === this.target; + return element && element.shadowRoot ? element === this.target.getRootNode().host : element === this.target; } // Get target element diff --git a/src/js/plugins/ads.js b/src/js/plugins/ads.js index 48682dcf..9f1088fa 100644 --- a/src/js/plugins/ads.js +++ b/src/js/plugins/ads.js @@ -370,14 +370,12 @@ class Ads { // TODO: So there is still this thing where a video should only be allowed to start // playing when the IMA SDK is ready or has failed - if (player.ended){ - this.loadAds(); - } - else - { + if (this.player.ended) { + this.loadAds(); + } else { // The SDK won't allow new ads to be called without receiving a contentComplete() - this.loader.contentComplete(); - } + this.loader.contentComplete(); + } break; diff --git a/src/js/plugins/preview-thumbnails.js b/src/js/plugins/preview-thumbnails.js index 4c13ab33..290ce949 100644 --- a/src/js/plugins/preview-thumbnails.js +++ b/src/js/plugins/preview-thumbnails.js @@ -146,13 +146,11 @@ class PreviewThumbnails { resolve(); }; + // Via callback() if (is.function(src)) { - // Ask - let that = this; - src(function(thumbnails) { - that.thumbnails = thumbnails; - // Resolve + src(thumbnails => { + this.thumbnails = thumbnails; sortAndResolve(); }); } diff --git a/src/js/utils/elements.js b/src/js/utils/elements.js index 43f46416..bdf18bfd 100644 --- a/src/js/utils/elements.js +++ b/src/js/utils/elements.js @@ -221,7 +221,7 @@ export function hasClass(element, className) { // Element matches selector export function matches(element, selector) { - const prototype = Element.prototype; + const {prototype} = Element; function match() { return Array.from(document.querySelectorAll(selector)).includes(this); diff --git a/src/js/utils/is.js b/src/js/utils/is.js index b005cd31..24f176cc 100644 --- a/src/js/utils/is.js +++ b/src/js/utils/is.js @@ -19,7 +19,7 @@ const isEvent = input => instanceOf(input, Event); const isKeyboardEvent = input => instanceOf(input, KeyboardEvent); const isCue = input => instanceOf(input, window.TextTrackCue) || instanceOf(input, window.VTTCue); const isTrack = input => instanceOf(input, TextTrack) || (!isNullOrUndefined(input) && isString(input.kind)); -const isPromise = input => instanceOf(input, Promise); +const isPromise = input => instanceOf(input, Promise) && isFunction(input.then); const isEmpty = input => isNullOrUndefined(input) || diff --git a/src/js/utils/promise.js b/src/js/utils/promise.js index 42fcc2c3..f45b46ab 100644 --- a/src/js/utils/promise.js +++ b/src/js/utils/promise.js @@ -1,27 +1,14 @@ -/** - * Returns whether an object is `Promise`-like (i.e. has a `then` method). - * - * @param {Object} value - * An object that may or may not be `Promise`-like. - * - * @return {boolean} - * Whether or not the object is `Promise`-like. - */ -export function isPromise(value) { - return value !== undefined && value !== null && typeof value.then === 'function'; -} - +import is from './is'; /** * Silence a Promise-like object. - * * This is useful for avoiding non-harmful, but potentially confusing "uncaught * play promise" rejection error messages. - * - * @param {Object} value - * An object that may or may not be `Promise`-like. + * @param {Object} value An object that may or may not be `Promise`-like. */ export function silencePromise(value) { - if (isPromise(value)) { + if (is.promise(value)) { value.then(null, () => {}); } } + +export default { silencePromise }; |