Fix infinite while loop and reset regex in CoffeeScript #60

Merged
merged 1 commit into from Jun 15, 2013

6 participants

@gregjopa

The while loop that iterates over a single pseudo style is causing webkit browsers to crash as discussed in issues #55 and #48. It seems like this while loop's original purpose was to select a pseudo style missed by the first pass through of the test() regex function. When a regex is used in a loop like this it's lastIndex needs to be reset to zero on each iteration otherwise it will continue from the last match-end position (I experience this issue in Firefox but not Chrome).

For example, if you just change the while loop to an if statement like in the pull request in #48 the example Sinatra app won't display the button:disable pseudo element style properly in Firefox because of this issue with lastIndex. Resetting the lastIndex of the regex on each style iteration fixes this issue so this while loop is no longer needed and can be replaced by an if statement.

See this post for more details about this bug with regex lastIndex: http://blog.stevenlevithan.com/archives/es3-regexes-broken

@gregjopa gregjopa Fix infinite while loop and reset regex
the while loop that iterates over a single pseudo style was causing webkit browsers to crash. It seems like this while loop's original purpose was to select a pseudo style missed by the first pass through of the test() regex function. Resetting the last index of the regex on each style iteration fixes this issue so this while loop is no longer needed and can be replaced by an if statement.
278dc88
@janiv

I agree with this fix and suggested a similar change in #53. This pull requests also fixes the while statement so I'll close mine as this one is more complete.

@chibicode

👍

@drusellers

👍

@bangpound

👍 👍

@benschwarz benschwarz merged commit 278dc88 into kneath:master Jun 15, 2013
@benschwarz
Collaborator

Confirmed. Merged. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment