[Pkg-javascript-commits] [less.js] 07/25: Charsets should float on top #2126
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:23:09 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v1.7.5
in repository less.js.
commit e7c81125b776cb3cd220bbde8b877a46f65f5002
Author: jurcovicovam <meri at meri.org>
Date: Sun Aug 3 10:37:10 2014 +0200
Charsets should float on top #2126
---
lib/less/tree/directive.js | 5 ++++-
lib/less/tree/ruleset.js | 9 ++++++++-
test/less/import.less | 6 ++++--
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/lib/less/tree/directive.js b/lib/less/tree/directive.js
index 3d598f4..9b0eb0f 100644
--- a/lib/less/tree/directive.js
+++ b/lib/less/tree/directive.js
@@ -24,7 +24,10 @@ tree.Directive.prototype = {
}
},
isRulesetLike: function() {
- return "@charset" !== this.name;
+ return !this.isCharset();
+ },
+ isCharset: function() {
+ return "@charset" === this.name;
},
genCSS: function (env, output) {
var value = this.value, rules = this.rules;
diff --git a/lib/less/tree/ruleset.js b/lib/less/tree/ruleset.js
index 510c1f1..17c0ad1 100644
--- a/lib/less/tree/ruleset.js
+++ b/lib/less/tree/ruleset.js
@@ -266,6 +266,7 @@ tree.Ruleset.prototype = {
},
genCSS: function (env, output) {
var i, j,
+ charsetRuleNodes = [],
ruleNodes = [],
rulesetNodes = [],
rulesetNodeCnt,
@@ -306,9 +307,15 @@ tree.Ruleset.prototype = {
if (isRulesetLikeNode(rule, this.root)) {
rulesetNodes.push(rule);
} else {
- ruleNodes.push(rule);
+ //charsets should float on top of everything
+ if (rule.isCharset && rule.isCharset()) {
+ charsetRuleNodes.push(rule);
+ } else {
+ ruleNodes.push(rule);
+ }
}
}
+ ruleNodes = charsetRuleNodes.concat(ruleNodes);
// If this is the root node, we don't render
// a selector, or {}.
diff --git a/test/less/import.less b/test/less/import.less
index 98573cf..9f8b291 100644
--- a/test/less/import.less
+++ b/test/less/import.less
@@ -1,4 +1,3 @@
- at charset "UTF-8"; // stay on top #2013
@import url(http://fonts.googleapis.com/css?family=Open+Sans);
@import url(/absolute/something.css) screen and (color) and (max-width: 600px);
@@ -23,4 +22,7 @@
@media print {
@import (multiple) "import/import-test-e";
-}
\ No newline at end of file
+}
+
+ at charset "UTF-8"; // climb on top #2126
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git
More information about the Pkg-javascript-commits
mailing list