Skip to content

Commit c97e689

Browse files
authored
chore: Update AbortSignal polyfill for new compiler (shaka-project#7176)
This upgrades the compiler and reworks the AbortSignal polyfill to match the new compiler externs for that class. This is important to make Shaka Player compatible with the latest compilers in use inside Google. Note that the Closure compiler is deprecated, so this should be our final upgrade. We will some day move to TypeScript. This does _not_ update the Closure library, because the latest version causes failures we don't understand in the loading mechanism in test/test/boot.js.
1 parent beed112 commit c97e689

File tree

3 files changed

+40
-32
lines changed

3 files changed

+40
-32
lines changed

lib/polyfill/abort_controller.js

+24-16
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,11 @@ shaka.polyfill.AbortController = class {
5858

5959
/**
6060
* @summary A polyfill for AbortSignal, part of the AbortController API.
61-
* @implements {AbortSignal}
61+
* @extends AbortSignal
6262
*/
63-
shaka.polyfill.AbortController.AbortSignal =
64-
class extends shaka.util.FakeEventTarget {
63+
shaka.polyfill.AbortController.AbortSignal = class {
6564
/** */
6665
constructor() {
67-
super();
68-
6966
/** @private {boolean} */
7067
this.aborted_ = false;
7168

@@ -74,19 +71,37 @@ class extends shaka.util.FakeEventTarget {
7471

7572
/** @type {?function(!Event)} */
7673
this.onabort = null;
74+
75+
/** @private {!shaka.util.FakeEventTarget} */
76+
this.eventTarget_ = new shaka.util.FakeEventTarget();
77+
}
78+
79+
/** @override */
80+
addEventListener(type, listener, options) {
81+
return this.eventTarget_.addEventListener(type, listener, options);
82+
}
83+
84+
/** @override */
85+
removeEventListener(type, listener, options) {
86+
return this.eventTarget_.removeEventListener(type, listener, options);
87+
}
88+
89+
/** @override */
90+
dispatchEvent(event) {
91+
return this.eventTarget_.dispatchEvent(event);
7792
}
7893

7994
/** @override */
8095
get aborted() {
8196
return this.aborted_;
8297
}
8398

84-
/** @return {*} */
99+
/** @override */
85100
get reason() {
86101
return this.reason_;
87102
}
88103

89-
/** @return {void} */
104+
/** @override */
90105
throwIfAborted() {
91106
if (this.aborted_) {
92107
throw this.reason_;
@@ -119,21 +134,14 @@ class extends shaka.util.FakeEventTarget {
119134
this.dispatchEvent(event);
120135
}
121136

122-
123-
/**
124-
* @param {*=} reason
125-
* @return {!AbortSignal}
126-
*/
137+
/** @override */
127138
static abort(reason) {
128139
const signal = new shaka.polyfill.AbortController.AbortSignal();
129140
signal.doAbort_(reason);
130141
return signal;
131142
}
132143

133-
/**
134-
* @param {number} timeMs
135-
* @return {!AbortSignal}
136-
*/
144+
/** @override */
137145
static timeout(timeMs) {
138146
const signal = new shaka.polyfill.AbortController.AbortSignal();
139147

package-lock.json

+14-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"eslint-plugin-shaka-rules": "file:./build/eslint-plugin-shaka-rules",
3232
"esprima": "^4.0.1",
3333
"fontfaceonload": "^1.0.2",
34-
"google-closure-compiler-java": "^20221102.0.0",
35-
"google-closure-deps": "^20221102.0.0",
34+
"google-closure-compiler-java": "^20240317.0.0",
35+
"google-closure-deps": "^20230802.0.0",
3636
"google-closure-library": "^20221102.0.0",
3737
"htmlhint": "^1.1.3",
3838
"jasmine-ajax": "^4.0.0",

0 commit comments

Comments
 (0)