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.
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.
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 anif
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 withlastIndex
. 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