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

fix: modify script evaluation for IE11 #41

Merged
merged 1 commit into from
Sep 12, 2017

Conversation

emememw
Copy link
Contributor

@emememw emememw commented Aug 24, 2017

Pull Request (Notable Changes)

I've moved up the check for eval because IE11 still has the execScript function, but throws an error when it's called.

The added error handling allows us to gracefuly reject scripts with non compatible code (like ES6 syntax). It would be better if we could transpile with babel before evaluating, but I don't know how we could implement that. There's already a separate issue regarding this feature (See #40).

Issues

Fixes #36
Fixes #39

Edited by @michael-ciniawsky (Formatting && Fixes #Issue Support)

@jsf-clabot
Copy link

jsf-clabot commented Aug 24, 2017

CLA assistant check
All committers have signed the CLA.

addScript.js Outdated
} else if (typeof execScript !== "undefined") {
execScript(src);
} else {
// TODO error: no eval function available
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Todo in code is bad practice. How we can solve this problem, what you think?

Copy link
Contributor Author

@emememw emememw Aug 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evilebottnawi As I mention in the description of my pull request, I don't know how these errors should be handled. We could just log them ( console.log("no eval function available") ) or throw them ( throw new Error("no eval function available") ), so that they have to be handled outside of the script loader.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Markus-WI i think console.log is good solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evilebottnawi ok, I've added the error logging and updated my pull request

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

addScript.js Outdated
} else if (typeof execScript !== "undefined") {
execScript(src);
} else {
console.log("no eval function available");
Copy link
Member

@michael-ciniawsky michael-ciniawsky Aug 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.error('[Script Loader] EvalError: No eval function available')

Copy link
Member

@alexander-akait alexander-akait Aug 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michael-ciniawsky it can be break execution there eval and execScript not allowed or forbidden (CSP). Maybe best output error than break execution?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the try/catch is solely for errors within eval ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michael-ciniawsky I've updated my commit accordingly.

addScript.js Outdated
console.log("no eval function available");
}
} catch (error) {
console.log("script evaluation error occurred", error);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.error('[Script Loader] ', err.message)

@michael-ciniawsky
Copy link
Member

I've moved up the check for eval because IE11 still has the execScript function, but throws an error when it's called

Is the execScript still needed, or could it be removed as superseded by eval/new Function()? (General Question)

@michael-ciniawsky michael-ciniawsky changed the title Modified script evaluation for IE11. Ref #36 fix: modify script evaluation for IE11 Aug 24, 2017
@michael-ciniawsky michael-ciniawsky added this to the 0.7.1 milestone Aug 24, 2017
@emememw
Copy link
Contributor Author

emememw commented Aug 25, 2017

Is the execScript still needed, or could it be removed as superseded by eval/new Function()? (General Question)

As far as I know, execScript is needed for IE < 11 compatibility

Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@TigerC10
Copy link

👍 I just tested this myself and it works great. Solves the problem beautifully.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants