@@ -24,6 +24,14 @@ file, You can obtain one at https://mozilla.org/MPL/2.0/.
2424 */
2525const isObject = ( obj ) => ! ! obj && typeof obj === 'object' ;
2626
27+ /**
28+ * Object.hasOwn() but it works in more browsers.
29+ * @param {unknown } obj
30+ * @param {string } property
31+ * @returns {boolean } true if Object.hasOwn(obj, property)
32+ */
33+ const hasOwn = ( obj , property ) => Object . prototype . hasOwnProperty . call ( obj , property ) ;
34+
2735/**
2836 * @typedef PlatformInfo
2937 * @property {boolean } [allowsNonScalarVariables]
@@ -44,8 +52,8 @@ const platforms = {
4452 * @returns {PlatformInfo }
4553 */
4654const getPlatform = ( options ) => {
47- if ( options && Object . prototype . hasOwnProperty . call ( options , 'platform' ) ) {
48- if ( Object . prototype . hasOwnProperty . call ( platforms , options . platform ) ) {
55+ if ( options && hasOwn ( options , 'platform' ) ) {
56+ if ( hasOwn ( platforms , options . platform ) ) {
4957 return platforms [ options . platform ] ;
5058 }
5159 throw new Error ( `Unknown platform: ${ options . platform } ` ) ;
@@ -475,7 +483,7 @@ const fixJSON = (data, options = {}) => {
475483 'off' ,
476484 'on-flipped'
477485 ] ;
478- if ( Object . prototype . hasOwnProperty . call ( stage , 'videoState' ) && ! VIDEO_STATES . includes ( stage . videoState ) ) {
486+ if ( hasOwn ( stage , 'videoState' ) && ! VIDEO_STATES . includes ( stage . videoState ) ) {
479487 log ( `stage had invalid videoState: ${ stage . videoState } ` ) ;
480488 stage . videoState = 'off' ;
481489 }
0 commit comments