blakeembrey / free-style

Make CSS easier and more maintainable by using JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible regression in v1?

apalm opened this issue · comments

v0.5.6:
http://requirebin.com/?gist=cb4df599fb69934baea9

v1.0.1:
http://requirebin.com/?gist=ff31e7c6c16f720fbae2

Hopefully, the requirebins make it clear enough, but in the latter version, class y within the media query is overridden by the later class y, so the div's background is always palegreen. I'm guessing this is related to the de-duping of @-rules introduced in v1.

@apalm Awesome catch! Definitely a regression, and partially related to the new de-deduping - the cause is actually a tiny bit more complex, but interesting, so I'll write it out (for fun).

So when a style is added to the cache, it's stored in an object. Object keys are ordered based on addition time (E.g. the first key added is before the second key). So the issue here is that it's correctly deduped, but the key order isn't updated - this results in output style being in the wrong order whenever there's a deduped style like this.

I'll release a patch ASAP, but thanks for the catch 👍

Wow, that was quick 👍

Thanks for the explanation and patch.