Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 428b734

Browse files
committed
Check module support using an external file, instead of data url, fixes #502
1 parent 9123e4f commit 428b734

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

assets/modules.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
var test_module_scope = true;
2+
window.callback_es6_modules(typeof window.test_module_scope === 'undefined')

scripts/9/engine.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,7 +4146,7 @@ Test9 = (function () {
41464146

41474147
item.startBackground();
41484148

4149-
var callback = item.getGlobalCallback(function(scoped) {
4149+
var callback = item.getGlobalCallback("es6_modules", function(scoped) {
41504150
item.update({
41514151
passed: scoped ? YES : YES | BUGGY
41524152
});
@@ -4160,7 +4160,7 @@ Test9 = (function () {
41604160

41614161
var s = document.createElement('script');
41624162
s.type = 'module';
4163-
s.src = "data:text/javascript;charset=utf-8,var test_module_scope = true; window." + callback + "(typeof window.test_module_scope === 'undefined')";
4163+
s.src = '/assets/modules.js';
41644164
document.body.appendChild(s);
41654165

41664166
window.setTimeout(function () {
@@ -4408,8 +4408,11 @@ Test9 = (function () {
44084408
this.list.parent.stopBackground(this.data.key);
44094409
},
44104410

4411-
getGlobalCallback: function(callback) {
4412-
var uniqueid = (((1 + Math.random()) * 0x1000000) | 0).toString(16).substring(1);
4411+
getGlobalCallback: function(uniqueid, callback) {
4412+
if (typeof uniqueid == "function") {
4413+
callback = uniqueid;
4414+
uniqueid = (((1 + Math.random()) * 0x1000000) | 0).toString(16).substring(1);
4415+
}
44134416

44144417
var that = this;
44154418
window['callback_' + uniqueid] = function() {

0 commit comments

Comments
 (0)