kneath/kss — pull request #60 by gregjopa (2013-01-24 00:28:48+00:00)
Title: Fix infinite while loop and reset regex in CoffeeScript

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