Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

fixes #56 sort style nodes in ascending precedence order before applying rules. #59

Merged
merged 2 commits into from
Apr 29, 2014

Conversation

keithnorm
Copy link
Contributor

This is to be more in line with CSS rules such that given this scenario:

UILabel {
text-color: blue;
}

UILabel {
text-color: red;
}

A UILabel should have red text.

Also, this missing Ball.png was breaking the example app. It's not used but I added it anyway as a quick fix.

NOTE: This is a fundamental change to Classy's behavior and may cause some stylesheets to appear to be broken if they were written in a way that relies on applying the rules from the bottom to the top of a stylesheet.

…ore applying rules.

This is to be more in line with CSS rules such that given this scenario:

UILabel {
  text-color: blue;
}

UILabel {
  text-color: red;
}

A UILabel should have red text.
@@ -57,8 +57,21 @@ - (void)styleItem:(id<CASStyleableItem>)item {
// load default style file
self.filePath = [[NSBundle mainBundle] pathForResource:@"stylesheet.cas" ofType:nil];
}

// order ascending by precedence
[self.styleNodes sortWithOptions:NSSortStable usingComparator:^NSComparisonResult(CASStyleNode *n1, CASStyleNode *n2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why ordering needs to be done again here? Its already being ordered on line 148? This would be very costly as it means ordering would happen every time a view is styled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're right that is unnecessary. Since self.styleNodes is only set in setFilePath:error and it gets sorted in that method. I removed the sorting from styleItem and the tests still pass.

@cloudkite
Copy link
Contributor

Cool thanks for the contribution!

cloudkite added a commit that referenced this pull request Apr 29, 2014
fixes #56 sort style nodes in ascending precedence order before applying rules.
@cloudkite cloudkite merged commit 4b154a4 into ClassyKit:master Apr 29, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants