mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Merge https://github.com/less/less.js into misleading-error-message-2069
Conflicts: test/sourcemaps/basic.json
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
(function (tree) {
|
||||
|
||||
tree.Anonymous = function (value, index, currentFileInfo, mapLines) {
|
||||
tree.Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike) {
|
||||
this.value = value;
|
||||
this.index = index;
|
||||
this.mapLines = mapLines;
|
||||
this.currentFileInfo = currentFileInfo;
|
||||
this.rulesetLike = (typeof rulesetLike === 'undefined')? false : rulesetLike;
|
||||
};
|
||||
tree.Anonymous.prototype = {
|
||||
type: "Anonymous",
|
||||
eval: function () {
|
||||
return new tree.Anonymous(this.value, this.index, this.currentFileInfo, this.mapLines);
|
||||
return new tree.Anonymous(this.value, this.index, this.currentFileInfo, this.mapLines, this.rulesetLike);
|
||||
},
|
||||
compare: function (x) {
|
||||
if (!x.toCSS) {
|
||||
@@ -25,6 +26,9 @@ tree.Anonymous.prototype = {
|
||||
|
||||
return left < right ? -1 : 1;
|
||||
},
|
||||
isRulesetLike: function() {
|
||||
return this.rulesetLike;
|
||||
},
|
||||
genCSS: function (env, output) {
|
||||
output.add(this.value, this.currentFileInfo, this.index, this.mapLines);
|
||||
},
|
||||
|
||||
@@ -23,6 +23,9 @@ tree.Directive.prototype = {
|
||||
value = visitor.visit(value);
|
||||
}
|
||||
},
|
||||
isRulesetLike: function() {
|
||||
return "@charset" !== this.name;
|
||||
},
|
||||
genCSS: function (env, output) {
|
||||
var value = this.value, rules = this.rules;
|
||||
output.add(this.name, this.currentFileInfo, this.index);
|
||||
|
||||
@@ -103,7 +103,7 @@ tree.Import.prototype = {
|
||||
|
||||
if (this.options.inline) {
|
||||
//todo needs to reference css file not import
|
||||
var contents = new(tree.Anonymous)(this.root, 0, {filename: this.importedFilename}, true);
|
||||
var contents = new(tree.Anonymous)(this.root, 0, {filename: this.importedFilename}, true, true);
|
||||
return this.features ? new(tree.Media)([contents], this.features.value) : [contents];
|
||||
} else if (this.css) {
|
||||
var newImport = new(tree.Import)(this.evalPath(env), features, this.options, this.index);
|
||||
|
||||
@@ -283,9 +283,27 @@ tree.Ruleset.prototype = {
|
||||
tabSetStr = env.compress ? '' : Array(env.tabLevel).join(" "),
|
||||
sep;
|
||||
|
||||
function isRulesetLikeNode(rule, root) {
|
||||
// if it has nested rules, then it should be treated like a ruleset
|
||||
if (rule.rules)
|
||||
return true;
|
||||
|
||||
// medias and comments do not have nested rules, but should be treated like rulesets anyway
|
||||
if ( (rule instanceof tree.Media) || (root && rule instanceof tree.Comment))
|
||||
return true;
|
||||
|
||||
// some directives and anonumoust nodes are ruleset like, others are not
|
||||
if ((rule instanceof tree.Directive) || (rule instanceof tree.Anonymous)) {
|
||||
return rule.isRulesetLike();
|
||||
}
|
||||
|
||||
//anything else is assumed to be a rule
|
||||
return false;
|
||||
}
|
||||
|
||||
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)) {
|
||||
if (isRulesetLikeNode(rule, this.root)) {
|
||||
rulesetNodes.push(rule);
|
||||
} else {
|
||||
ruleNodes.push(rule);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
this isn't very valid CSS.
|
||||
#import {
|
||||
color: #ff0000;
|
||||
}
|
||||
@media (min-width: 600px) {
|
||||
#css { color: yellow; }
|
||||
|
||||
}
|
||||
this isn't very valid CSS.
|
||||
|
||||
1
test/css/import.css
vendored
1
test/css/import.css
vendored
@@ -1,3 +1,4 @@
|
||||
@charset "UTF-8";
|
||||
@import url(http://fonts.googleapis.com/css?family=Open+Sans);
|
||||
@import url(/absolute/something.css) screen and (color) and (max-width: 600px);
|
||||
@import url("//ha.com/file.css") (min-width: 100px);
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
@import url("import/import-test-c.less");// import inline should not float above this #1954
|
||||
@import (inline) url("import/import-test-d.css") (min-width:600px);
|
||||
@import (inline, css) url("import/invalid-css.less");
|
||||
1
test/less/import.less
vendored
1
test/less/import.less
vendored
@@ -1,3 +1,4 @@
|
||||
@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);
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["testweb/sourcemaps/imported.css","testweb/sourcemaps/basic.less"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;ACAA;EACE,YAAA;EAJA,UAAA;EAWA,iBAAA;EALA,WAAA;EACA,mBAAA;;AAJF,EASE;AATF,EASM;EACF,gBAAA;;AACA,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;EAGA,UAAA;;AALN;AAAI;AAUJ;EATE,iBAAA;;AADF,EAEE;AAFE,EAEF;AAFF,EAEM;AAFF,EAEE;AAQN,OARE;AAQF,OARM;EACF,gBAAA;;AACA,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFA;AAQN,OARE,GAQF,UARE;AAQF,OARE,GAEI,KAFJ;AAQF,OARE,GAQF,UARM;AAQN,OARE,GAEI,KAFA;AAEF,EAFF,GAQF,UARE;AAEE,EAFF,GAQF,UARM;AAQN,OARM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,UARM;EAGA,UAAA;;AAKN;EACE,WAAA;;ACxBF;AACA;AACA;AACA;AACA;AACA;AACA","file":"sourcemaps/basic.css"}
|
||||
Reference in New Issue
Block a user