Skip to content
This repository was archived by the owner on Nov 5, 2019. It is now read-only.

Commit dbb6d54

Browse files
lwrmichael-ciniawsky
authored andcommitted
fix: IE =< 8 incompatibility regression (#43)
1 parent fde94d7 commit dbb6d54

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

addScript.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,25 @@
33
Author Tobias Koppers @sokra
44
*/
55
module.exports = function(src) {
6+
function log(error) {
7+
(typeof console !== "undefined")
8+
&& (console.error || console.log)("[Script Loader]", error);
9+
}
10+
11+
// Check for IE =< 8
12+
function isIE() {
13+
return typeof attachEvent !== "undefined" && typeof addEventListener === "undefined";
14+
}
15+
616
try {
7-
if (typeof eval !== "undefined") {
8-
eval.call(null, src);
9-
} else if (typeof execScript !== "undefined") {
17+
if (typeof execScript !== "undefined" && isIE()) {
1018
execScript(src);
19+
} else if (typeof eval !== "undefined") {
20+
eval.call(null, src);
1121
} else {
12-
console.error("[Script Loader] EvalError: No eval function available");
22+
log("EvalError: No eval function available");
1323
}
1424
} catch (error) {
15-
console.error("[Script Loader] ", error.message);
25+
log(error);
1626
}
1727
}

0 commit comments

Comments
 (0)