Skip to content
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

Fixed issue #95. #176

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fixed issue #95. #176

wants to merge 2 commits into from

Conversation

PythonCow
Copy link

Now loops with popup functions (alert, prompt, confirm) like this:
for (var i = 0; i < 6; i++){alert(i);}
Will work.
It also works with loops without curly braces, nested loops, and popups called through the window object (e.g. window.alert()).

@chinchang
Copy link
Owner

wow! Thanks for the fix @PythonCow. I'll check it out.

if (node.range[0]>=loop.start && node.range[0]<=loop.end){
patches.push({
pos: node.range[1],
str: '\n%d = Date.now();\n'.replace('%d', loop.varName)
Copy link
Owner

Choose a reason for hiding this comment

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

@PythonCow this is basically resetting the loop timer after the alert statement. This means if there is a real infinite loop that has alert statements in it, it would run forever because of this reset. Right?

Copy link
Owner

Choose a reason for hiding this comment

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

Possible solution:

  • Just before alert statement we record time in a variable.
  • After alert, we subtract the time taken by alert from the loop timer variable _wmloopvar.
    That way time taken by alert statement won't ever be counted in the loop's timer.

@chinchang
Copy link
Owner

@PythonCow I had the comment written in 2017, but damn this Github UI, they were in "pending" state till today. Sorry!

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

Successfully merging this pull request may close these issues.

None yet

2 participants