diff options
author | Sam Potts <sam@potts.es> | 2020-03-29 12:02:59 +1100 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2020-03-29 12:02:59 +1100 |
commit | 09598f07bf062886bfa22cd8682948567e92a19a (patch) | |
tree | 2ed0de186d43b2cc27422115fe75600a12e5d303 /src/js/utils | |
parent | ef7b30c1b8a0e2d9a8cb71dfb41af0706bb8886e (diff) | |
parent | 155add66bd5b941699cea99f5c94cf8a87b030d8 (diff) | |
download | plyr-09598f07bf062886bfa22cd8682948567e92a19a.tar.lz plyr-09598f07bf062886bfa22cd8682948567e92a19a.tar.xz plyr-09598f07bf062886bfa22cd8682948567e92a19a.zip |
Merge branch 'develop' of github.com:sampotts/plyr into develop
# Conflicts:
# package.json
# yarn.lock
Diffstat (limited to 'src/js/utils')
-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 | 14 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/js/utils/elements.js b/src/js/utils/elements.js index b88aad0c..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 }; + 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 new file mode 100644 index 00000000..f45b46ab --- /dev/null +++ b/src/js/utils/promise.js @@ -0,0 +1,14 @@ +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. + */ +export function silencePromise(value) { + if (is.promise(value)) { + value.then(null, () => {}); + } +} + +export default { silencePromise }; |