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

Commit

Permalink
fix: IE =< 8 incompatibility regression (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwr authored and michael-ciniawsky committed Sep 28, 2017
1 parent fde94d7 commit dbb6d54
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions addScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@
Author Tobias Koppers @sokra
*/
module.exports = function(src) {
function log(error) {
(typeof console !== "undefined")
&& (console.error || console.log)("[Script Loader]", error);
}

// Check for IE =< 8
function isIE() {
return typeof attachEvent !== "undefined" && typeof addEventListener === "undefined";
}

try {
if (typeof eval !== "undefined") {
eval.call(null, src);
} else if (typeof execScript !== "undefined") {
if (typeof execScript !== "undefined" && isIE()) {
execScript(src);
} else if (typeof eval !== "undefined") {
eval.call(null, src);
} else {
console.error("[Script Loader] EvalError: No eval function available");
log("EvalError: No eval function available");
}
} catch (error) {
console.error("[Script Loader] ", error.message);
log(error);
}
}

0 comments on commit dbb6d54

Please sign in to comment.