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

@charset reordered #2013

Closed
ProgerXP opened this issue May 16, 2014 · 3 comments
Closed

@charset reordered #2013

ProgerXP opened this issue May 16, 2014 · 3 comments

Comments

@ProgerXP
Copy link

As per W3C:

It is important to understand that, although the @charset declaration looks like a CSS at-rule, it is not parsed as such for detection of the character encoding. Only an exact byte sequence, beginning with the very first byte in the style sheet, will be effective.

However:

// file.less
@charset "UTF-8";
@import 'normalize.css';

Results in:

$ lessc file.less
@import 'normalize.css';
@charset "UTF-8";

Why @charset is suddenly placed after other directives even if it's the first in the input file? (For this matter LESS should have moved it to the first line even if it wasn't there to be W3C-compliant.)

Am I missing something?

@lukeapage
Copy link
Member

Hrmm they are moved to the top, but so are css imports and that looks like
a bug.

@ydaniv
Copy link

ydaniv commented Jun 10, 2014

👍 hit me too ):

SomMeri pushed a commit to SomMeri/less-rhino.js that referenced this issue 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 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.
@SomMeri
Copy link
Member

SomMeri commented Jul 28, 2014

This was fixed by the merged pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants