ClassyKit / Classy

Expressive, flexible, and powerful stylesheets for UIView and friends.
http://classykit.github.io/Classy/
MIT License
740 stars 76 forks source link

Equal precedence style rules should override from top to bottom (currently opposite) #56

Closed keithnorm closed 10 years ago

keithnorm commented 10 years ago

Say I have this stylesheet:

UIButton.green-button {
    background-color: green;
}

UIButton.green-button {
    background-color: red;
}

My .green-button should actually be red, assuming we are playing by CSS rules in this case, but it is still green. I've traced it down to this line https://github.com/cloudkite/Classy/blob/master/Classy/Parser/CASStyler.m#L61 which seems to apply styles from bottom to top. If I flip that to be top to bottom it works the way I want it to. Is there a reason for using reverseObjectEnumerator there that I'm not getting?

Anyway, I can't tell you how much I love this project, so thanks!

cloudkite commented 10 years ago

@keithnorm Sorry for the delay, have been a bit swamped at work. I can't recall why its reserved, might have been something todo with parse order which no longer applies. I think this is probably a bug if you want to submit a PR to fix it would be great.

If you do have chance to submit PR, please add tests by extending the following test case https://github.com/cloudkite/Classy/blob/master/Tests/Stylesheets/Precedence-1.cas

Thanks!