-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
showModalDialog calls inside another function causes script to break #41
Comments
You can use yield and await version instead of eval, like this: var val = String(await window.showModalDialog(url, "", feature)); or: var val = window.showModalDialog(url, "", feature);
val = String(val) |
Yes, I understand that yield and await are options, but we still have to support older versions of IE (we're talking IE5) as well -- and Babel is out of the question. Using generators and async will just mean we'd have to build two separate codebases at that point. Regardless, I mentioned the issue in case someone else ran into it with a possible means to fix it. We have it fixed in our version of the polyfill. |
Prevent showModalDialog from breaking when used inside another function. Reference: niutech#41
Prevent showModalDialog from breaking when used inside another function. Reference: niutech#41
Is nested calls more than 1 level working? If not how to make it work? |
If window.showModalDialog call is nested inside another function call, your script will break since there will be a parenthesis at the end that will have already been escaped. For example, when trying to apply this polyfill to the following line:
var val = String(window.showModalDialog(url, "",
feature));`causes an error since it's replacing everything from (window.)showModalDialog onward even though there's a parenthesis before it for the outer function call. Replacing the regex on line 55 to the below will handle this use case:
nextStmts[0] = nextStmts[0].replace(/(window\.)?showModalDialog\([^\)]*\)/g,JSON.stringify(returnValue));
showModalDialog/showModalDialog.js
Line 55 in 198b9f8
The text was updated successfully, but these errors were encountered: