Skip to content

Commit 4005754

Browse files
Álvaro Velad Galvánjoeyparrish
Álvaro Velad Galván
andauthored
fix(cmcd): Fix Symbol usage in CMCD on Xbox One (shaka-project#4073)
Close shaka-project#4072 Co-authored-by: Joey Parrish <[email protected]>
1 parent 3822519 commit 4005754

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

build/types/polyfill

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
+../../lib/polyfill/pip_webkit.js
1616
+../../lib/polyfill/random_uuid.js
1717
+../../lib/polyfill/storage_estimate.js
18+
+../../lib/polyfill/symbol.js
1819
+../../lib/polyfill/video_play_promise.js
1920
+../../lib/polyfill/videoplaybackquality.js
2021
+../../lib/polyfill/vttcue.js

lib/polyfill/symbol.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*! @license
2+
* Shaka Player
3+
* Copyright 2016 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
goog.provide('shaka.polyfill.Symbol');
7+
8+
goog.require('shaka.log');
9+
goog.require('shaka.polyfill');
10+
11+
/**
12+
* @summary A polyfill to provide Symbol.prototype.description in all browsers.
13+
* See: https://caniuse.com/mdn-javascript_builtins_symbol_description
14+
* @export
15+
*/
16+
shaka.polyfill.Symbol = class {
17+
/**
18+
* Install the polyfill if needed.
19+
* @export
20+
*/
21+
static install() {
22+
shaka.log.debug('Symbol.install');
23+
24+
// eslint-disable-next-line no-restricted-syntax
25+
const proto = Symbol.prototype;
26+
27+
if (!('description' in proto)) {
28+
Object.defineProperty(proto, 'description', {
29+
get: shaka.polyfill.Symbol.getSymbolDescription_,
30+
});
31+
}
32+
}
33+
34+
/**
35+
* @this {Symbol}
36+
* @return {(string|undefined)}
37+
* @private
38+
*/
39+
static getSymbolDescription_() {
40+
const m = /\((.*)\)/.exec(this.toString());
41+
return m ? m[1] : undefined;
42+
}
43+
};
44+
45+
46+
shaka.polyfill.register(shaka.polyfill.Symbol.install);

shaka-player.uncompiled.js

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ goog.require('shaka.polyfill.PatchedMediaKeysNop');
4545
goog.require('shaka.polyfill.PatchedMediaKeysWebkit');
4646
goog.require('shaka.polyfill.PiPWebkit');
4747
goog.require('shaka.polyfill.RandomUUID');
48+
goog.require('shaka.polyfill.Symbol');
4849
goog.require('shaka.polyfill.VTTCue');
4950
goog.require('shaka.polyfill.VideoPlayPromise');
5051
goog.require('shaka.polyfill.VideoPlaybackQuality');

0 commit comments

Comments
 (0)