Skip to content

Commit 69ec65f

Browse files
authored
Merge pull request #5 from rdkcentral/fix/polyfill-global-this
Added a 'horrifying' polyfill for globalThis (https://mathiasbynens.b…
2 parents d0e3d04 + f2209ca commit 69ec65f

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

dist/thunderJS.js

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

module/thunderJS.js

+15
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,21 @@ const unregister = function(plugin, event) {
256256
}
257257
};
258258

259+
(function (Object) {
260+
typeof globalThis !== 'object' && (
261+
this ?
262+
get() :
263+
(Object.defineProperty(Object.prototype, '_T_', {
264+
configurable: true,
265+
get: get
266+
}), _T_)
267+
);
268+
function get() {
269+
this.globalThis = this;
270+
delete Object.prototype._T_;
271+
}
272+
}(Object));
273+
259274
let api;
260275
var thunderJS = options => {
261276
if (globalThis.thunder && typeof globalThis.thunder.token === 'function') {

package-lock.json

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

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Metrological, Wouter <[email protected]>"
55
],
66
"name": "ThunderJS",
7-
"version": "1.2.0",
7+
"version": "1.2.1",
88
"license": "apache",
99
"browser": "dist/thunderJS.js",
1010
"main": "src/thunderJS.js",
@@ -60,6 +60,7 @@
6060
"tape": "^4.13.2"
6161
},
6262
"dependencies": {
63+
"@ungap/global-this": "^0.3.1",
6364
"ws": "^7.2.3"
6465
}
6566
}

src/thunderJS.js

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import API from './api'
2121
import plugins from './plugins/index'
2222
import listener from './listener'
23+
import '@ungap/global-this'
2324

2425
let api
2526

0 commit comments

Comments
 (0)