Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ordering of @import and @charset rules #1954 #2013 #2117

Merged
merged 3 commits into from
Jul 27, 2014

Conversation

SomMeri
Copy link
Member

@SomMeri SomMeri commented Jul 22, 2014

The genCss method of ruleset.js splits child nodes into two groups:

  • rules,
  • rulesets.

Rules are always printed first and have special handling for last rule.
Rulesets are always printed second. Wrong ordering was caused by the
condition that determined what is rule and what is ruleset.

Issue #2013: The condition made no difference between @charset and @page,
because both are compiled into tree.Directive nodes. I added isRulesetLike
method to the tree.Directive to differentiate between them.

Issue #1954: The condition treated all tree.Anonymous types as rules and
caused them to float up. That is incorrect, because @import (inline) is
compiled into tree.Anonymous too, but should be treated as ruleset and
stay where it is.

jurcovicovam added 2 commits July 22, 2014 14:46
The genCss method of ruleset.js splits child nodes into two groups:
* rules,
* rulesets.

Rules are always printed first and have special handling for last rule.
Rulesets are always printed second. Wrong ordering was caused by the
condition that determined what is rule and what is ruleset.

Issue less#2013: The condition made no difference between @charset and @page,
because both are compiled into tree.Directive nodes. I added isRulesetLike
method to the tree.Directive to differentiate between them.

Issue less#1954: The condition treated all tree.Anonymous types as rules and
caused them to float up. That is incorrect, because `@import (inline)` is
compiled into tree.Anonymous too, but should be treated as ruleset and
stay where it is.
for (i = 0; i < this.rules.length; i++) {
rule = this.rules[i];
if (rule.rules || (rule instanceof tree.Media) || rule instanceof tree.Directive || (this.root && rule instanceof tree.Comment)) {
// console.log(rule.type);
// if (rule.rules || (rule instanceof tree.Media) || rule instanceof tree.Directive || (this.root && rule instanceof tree.Comment)) {
Copy link
Member

Choose a reason for hiding this comment

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

I guess this should be deleted?

@lukeapage
Copy link
Member

Thanks alot @SomMeri, looks good apart from the 2 stray comments

@SomMeri
Copy link
Member Author

SomMeri commented Jul 24, 2014

Stray comments are removed now.

lukeapage added a commit that referenced this pull request Jul 27, 2014
@lukeapage lukeapage merged commit 1b204fe into less:master Jul 27, 2014
@SomMeri SomMeri deleted the import-charset-ordering-2013-1954 branch July 27, 2014 12:35
@SomMeri SomMeri restored the import-charset-ordering-2013-1954 branch July 28, 2014 11:18
@SomMeri SomMeri deleted the import-charset-ordering-2013-1954 branch July 28, 2014 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants