Skip to content

Commit

Permalink
fix(cmcd): Fix Symbol usage in CMCD on Xbox One (#4073)
Browse files Browse the repository at this point in the history
Close #4072

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
  • Loading branch information
Álvaro Velad Galván and joeyparrish committed Mar 29, 2022
1 parent 3822519 commit 4005754
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/types/polyfill
Expand Up @@ -15,6 +15,7 @@
+../../lib/polyfill/pip_webkit.js
+../../lib/polyfill/random_uuid.js
+../../lib/polyfill/storage_estimate.js
+../../lib/polyfill/symbol.js
+../../lib/polyfill/video_play_promise.js
+../../lib/polyfill/videoplaybackquality.js
+../../lib/polyfill/vttcue.js
46 changes: 46 additions & 0 deletions lib/polyfill/symbol.js
@@ -0,0 +1,46 @@
/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
goog.provide('shaka.polyfill.Symbol');

goog.require('shaka.log');
goog.require('shaka.polyfill');

/**
* @summary A polyfill to provide Symbol.prototype.description in all browsers.
* See: https://caniuse.com/mdn-javascript_builtins_symbol_description
* @export
*/
shaka.polyfill.Symbol = class {
/**
* Install the polyfill if needed.
* @export
*/
static install() {
shaka.log.debug('Symbol.install');

// eslint-disable-next-line no-restricted-syntax
const proto = Symbol.prototype;

if (!('description' in proto)) {
Object.defineProperty(proto, 'description', {
get: shaka.polyfill.Symbol.getSymbolDescription_,
});
}
}

/**
* @this {Symbol}
* @return {(string|undefined)}
* @private
*/
static getSymbolDescription_() {
const m = /\((.*)\)/.exec(this.toString());
return m ? m[1] : undefined;
}
};


shaka.polyfill.register(shaka.polyfill.Symbol.install);
1 change: 1 addition & 0 deletions shaka-player.uncompiled.js
Expand Up @@ -45,6 +45,7 @@ goog.require('shaka.polyfill.PatchedMediaKeysNop');
goog.require('shaka.polyfill.PatchedMediaKeysWebkit');
goog.require('shaka.polyfill.PiPWebkit');
goog.require('shaka.polyfill.RandomUUID');
goog.require('shaka.polyfill.Symbol');
goog.require('shaka.polyfill.VTTCue');
goog.require('shaka.polyfill.VideoPlayPromise');
goog.require('shaka.polyfill.VideoPlaybackQuality');
Expand Down

0 comments on commit 4005754

Please sign in to comment.