mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Trim trailing whitespace.
This commit is contained in:
@@ -8,21 +8,21 @@ tree.Anonymous = function (string, index, currentFileInfo, mapLines) {
|
||||
};
|
||||
tree.Anonymous.prototype = {
|
||||
type: "Anonymous",
|
||||
eval: function () {
|
||||
eval: function () {
|
||||
return new tree.Anonymous(this.value, this.index, this.currentFileInfo, this.mapLines);
|
||||
},
|
||||
compare: function (x) {
|
||||
if (!x.toCSS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
var left = this.toCSS(),
|
||||
right = x.toCSS();
|
||||
|
||||
|
||||
if (left === right) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return left < right ? -1 : 1;
|
||||
},
|
||||
genCSS: function (env, output) {
|
||||
|
||||
@@ -20,7 +20,7 @@ tree.Call.prototype = {
|
||||
// When evaluating a function call,
|
||||
// we either find the function in `tree.functions` [1],
|
||||
// in which case we call it, passing the evaluated arguments,
|
||||
// if this returns null or we cannot find the function, we
|
||||
// if this returns null or we cannot find the function, we
|
||||
// simply print it out as it appeared originally [2].
|
||||
//
|
||||
// The *functions.js* file contains the built-in functions.
|
||||
|
||||
@@ -153,7 +153,7 @@ tree.Color.prototype = {
|
||||
if (!x.rgb) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return (x.rgb[0] === this.rgb[0] &&
|
||||
x.rgb[1] === this.rgb[1] &&
|
||||
x.rgb[2] === this.rgb[2] &&
|
||||
@@ -183,7 +183,7 @@ function toHex(v) {
|
||||
}
|
||||
|
||||
function clamp(v, max) {
|
||||
return Math.min(Math.max(v, 0), max);
|
||||
return Math.min(Math.max(v, 0), max);
|
||||
}
|
||||
|
||||
})(require('../tree'));
|
||||
|
||||
@@ -91,7 +91,7 @@ tree.Dimension.prototype = {
|
||||
if (other instanceof tree.Dimension) {
|
||||
var a, b,
|
||||
aValue, bValue;
|
||||
|
||||
|
||||
if (this.unit.isEmpty() || other.unit.isEmpty()) {
|
||||
a = this;
|
||||
b = other;
|
||||
@@ -100,7 +100,7 @@ tree.Dimension.prototype = {
|
||||
b = other.unify();
|
||||
if (a.unit.compare(b.unit) !== 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
aValue = a.value;
|
||||
bValue = b.value;
|
||||
|
||||
@@ -97,10 +97,10 @@ tree.Import.prototype = {
|
||||
this.skip = this.skip();
|
||||
}
|
||||
if (this.skip) {
|
||||
return [];
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (this.options.inline) {
|
||||
//todo needs to reference css file not import
|
||||
var contents = new(tree.Anonymous)(this.root, 0, {filename: this.importedFilename}, true);
|
||||
|
||||
@@ -31,7 +31,7 @@ tree.Media.prototype = {
|
||||
env.mediaBlocks = [];
|
||||
env.mediaPath = [];
|
||||
}
|
||||
|
||||
|
||||
var media = new(tree.Media)(null, [], this.index, this.currentFileInfo);
|
||||
if(this.debugInfo) {
|
||||
this.rules[0].debugInfo = this.debugInfo;
|
||||
@@ -50,14 +50,14 @@ tree.Media.prototype = {
|
||||
env.strictMath = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
env.mediaPath.push(media);
|
||||
env.mediaBlocks.push(media);
|
||||
|
||||
|
||||
env.frames.unshift(this.rules[0]);
|
||||
media.rules = [this.rules[0].eval(env)];
|
||||
env.frames.shift();
|
||||
|
||||
|
||||
env.mediaPath.pop();
|
||||
|
||||
return env.mediaPath.length === 0 ? media.evalTop(env) :
|
||||
@@ -66,7 +66,7 @@ tree.Media.prototype = {
|
||||
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.rules[0], name); },
|
||||
find: function () { return tree.Ruleset.prototype.find.apply(this.rules[0], arguments); },
|
||||
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.rules[0]); },
|
||||
emptySelectors: function() {
|
||||
emptySelectors: function() {
|
||||
var el = new(tree.Element)('', '&', this.index, this.currentFileInfo),
|
||||
sels = [new(tree.Selector)([el], null, null, this.index, this.currentFileInfo)];
|
||||
sels[0].mediaEmpty = true;
|
||||
|
||||
@@ -21,7 +21,7 @@ tree.mixin.Call.prototype = {
|
||||
eval: function (env) {
|
||||
var mixins, mixin, args, rules = [], match = false, i, m, f, isRecursive, isOneFound, rule,
|
||||
candidates = [], candidate, conditionResult = [], defaultFunc = tree.defaultFunc,
|
||||
defaultResult, defNone = 0, defTrue = 1, defFalse = 2, count;
|
||||
defaultResult, defNone = 0, defTrue = 1, defFalse = 2, count;
|
||||
|
||||
args = this.arguments && this.arguments.map(function (a) {
|
||||
return { name: a.name, value: a.value.eval(env) };
|
||||
@@ -30,12 +30,12 @@ tree.mixin.Call.prototype = {
|
||||
for (i = 0; i < env.frames.length; i++) {
|
||||
if ((mixins = env.frames[i].find(this.selector)).length > 0) {
|
||||
isOneFound = true;
|
||||
|
||||
|
||||
// To make `default()` function independent of definition order we have two "subpasses" here.
|
||||
// At first we evaluate each guard *twice* (with `default() == true` and `default() == false`),
|
||||
// and build candidate list with corresponding flags. Then, when we know all possible matches,
|
||||
// we make a final decision.
|
||||
|
||||
|
||||
for (m = 0; m < mixins.length; m++) {
|
||||
mixin = mixins[m];
|
||||
isRecursive = false;
|
||||
@@ -48,11 +48,11 @@ tree.mixin.Call.prototype = {
|
||||
if (isRecursive) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mixin.matchArgs(args, env)) {
|
||||
|
||||
if (mixin.matchArgs(args, env)) {
|
||||
candidate = {mixin: mixin, group: defNone};
|
||||
|
||||
if (mixin.matchCondition) {
|
||||
|
||||
if (mixin.matchCondition) {
|
||||
for (f = 0; f < 2; f++) {
|
||||
defaultFunc.value(f);
|
||||
conditionResult[f] = mixin.matchCondition(args, env);
|
||||
@@ -64,16 +64,16 @@ tree.mixin.Call.prototype = {
|
||||
}
|
||||
|
||||
candidates.push(candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
candidates.push(candidate);
|
||||
}
|
||||
|
||||
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
defaultFunc.reset();
|
||||
|
||||
count = [0, 0, 0];
|
||||
@@ -92,7 +92,7 @@ tree.mixin.Call.prototype = {
|
||||
index: this.index, filename: this.currentFileInfo.filename };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (m = 0; m < candidates.length; m++) {
|
||||
candidate = candidates[m].group;
|
||||
if ((candidate === defNone) || (candidate === defaultResult)) {
|
||||
@@ -109,7 +109,7 @@ tree.mixin.Call.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (match) {
|
||||
if (!this.currentFileInfo || !this.currentFileInfo.reference) {
|
||||
for (i = 0; i < rules.length; i++) {
|
||||
@@ -242,7 +242,7 @@ tree.mixin.Definition.prototype = {
|
||||
throw { type: 'Runtime', message: "wrong number of arguments for " + this.name +
|
||||
' (' + argsLength + ' for ' + this.arity + ')' };
|
||||
}
|
||||
|
||||
|
||||
frame.prependRule(new(tree.Rule)(name, val));
|
||||
evaldArguments[i] = val;
|
||||
}
|
||||
|
||||
@@ -33,14 +33,14 @@ tree.Quoted.prototype = {
|
||||
if (!x.toCSS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
var left = this.toCSS(),
|
||||
right = x.toCSS();
|
||||
|
||||
|
||||
if (left === right) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return left < right ? -1 : 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ tree.Rule.prototype = {
|
||||
if (typeof name !== "string") {
|
||||
// expand 'primitive' name directly to get
|
||||
// things faster (~10% for benchmark.less):
|
||||
name = (name.length === 1)
|
||||
name = (name.length === 1)
|
||||
&& (name[0] instanceof tree.Keyword)
|
||||
? name[0].value : evalName(env, name);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ tree.Rule.prototype = {
|
||||
}
|
||||
try {
|
||||
evaldValue = this.value.eval(env);
|
||||
|
||||
|
||||
if (!this.variable && evaldValue.type === "DetachedRuleset") {
|
||||
throw { message: "Rulesets cannot be evaluated on a property.",
|
||||
index: this.index, filename: this.currentFileInfo.filename };
|
||||
|
||||
@@ -19,14 +19,14 @@ tree.Ruleset.prototype = {
|
||||
}
|
||||
},
|
||||
eval: function (env) {
|
||||
var thisSelectors = this.selectors, selectors,
|
||||
var thisSelectors = this.selectors, selectors,
|
||||
selCnt, selector, i, defaultFunc = tree.defaultFunc, hasOnePassingSelector = false;
|
||||
|
||||
if (thisSelectors && (selCnt = thisSelectors.length)) {
|
||||
selectors = [];
|
||||
defaultFunc.error({
|
||||
type: "Syntax",
|
||||
message: "it is currently only allowed in parametric mixin guards,"
|
||||
type: "Syntax",
|
||||
message: "it is currently only allowed in parametric mixin guards,"
|
||||
});
|
||||
for (i = 0; i < selCnt; i++) {
|
||||
selector = thisSelectors[i].eval(env);
|
||||
@@ -35,7 +35,7 @@ tree.Ruleset.prototype = {
|
||||
hasOnePassingSelector = true;
|
||||
}
|
||||
}
|
||||
defaultFunc.reset();
|
||||
defaultFunc.reset();
|
||||
} else {
|
||||
hasOnePassingSelector = true;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ tree.Ruleset.prototype = {
|
||||
if(this.debugInfo) {
|
||||
ruleset.debugInfo = this.debugInfo;
|
||||
}
|
||||
|
||||
|
||||
if (!hasOnePassingSelector) {
|
||||
rules.length = 0;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ tree.Ruleset.prototype = {
|
||||
rsRules[i] = rule = rule.eval ? rule.eval(env) : rule;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Evaluate everything else
|
||||
for (i = 0; i < rsRules.length; i++) {
|
||||
rule = rsRules[i];
|
||||
@@ -147,7 +147,7 @@ tree.Ruleset.prototype = {
|
||||
// Pop the stack
|
||||
envFrames.shift();
|
||||
envSelectors.shift();
|
||||
|
||||
|
||||
if (env.mediaBlocks) {
|
||||
for (i = mediaBlockCount; i < env.mediaBlocks.length; i++) {
|
||||
env.mediaBlocks[i].bubbleSelectors(selectors);
|
||||
@@ -387,19 +387,19 @@ tree.Ruleset.prototype = {
|
||||
|
||||
joinSelector: function (paths, context, selector) {
|
||||
|
||||
var i, j, k,
|
||||
hasParentSelector, newSelectors, el, sel, parentSel,
|
||||
newSelectorPath, afterParentJoin, newJoinedSelector,
|
||||
var i, j, k,
|
||||
hasParentSelector, newSelectors, el, sel, parentSel,
|
||||
newSelectorPath, afterParentJoin, newJoinedSelector,
|
||||
newJoinedSelectorEmpty, lastSelector, currentElements,
|
||||
selectorsMultiplied;
|
||||
|
||||
|
||||
for (i = 0; i < selector.elements.length; i++) {
|
||||
el = selector.elements[i];
|
||||
if (el.value === '&') {
|
||||
hasParentSelector = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!hasParentSelector) {
|
||||
if (context.length > 0) {
|
||||
for (i = 0; i < context.length; i++) {
|
||||
@@ -529,7 +529,7 @@ tree.Ruleset.prototype = {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
mergeElementsOnToSelectors: function(elements, selectors) {
|
||||
var i, sel;
|
||||
|
||||
|
||||
@@ -87,9 +87,9 @@ tree.Selector.prototype = {
|
||||
}
|
||||
},
|
||||
isJustParentSelector: function() {
|
||||
return !this.mediaEmpty &&
|
||||
this.elements.length === 1 &&
|
||||
this.elements[0].value === '&' &&
|
||||
return !this.mediaEmpty &&
|
||||
this.elements.length === 1 &&
|
||||
this.elements[0].value === '&' &&
|
||||
(this.elements[0].combinator.value === ' ' || this.elements[0].combinator.value === '');
|
||||
},
|
||||
eval: function (env) {
|
||||
|
||||
@@ -29,7 +29,7 @@ tree.URL.prototype = {
|
||||
}
|
||||
val.value = rootpath + val.value;
|
||||
}
|
||||
|
||||
|
||||
val.value = ctx.normalizePath(val.value);
|
||||
|
||||
// Add url args if enabled
|
||||
|
||||
@@ -13,14 +13,14 @@ tree.Variable.prototype = {
|
||||
if (name.indexOf('@@') === 0) {
|
||||
name = '@' + new(tree.Variable)(name.slice(1)).eval(env).value;
|
||||
}
|
||||
|
||||
|
||||
if (this.evaluating) {
|
||||
throw { type: 'Name',
|
||||
message: "Recursive variable definition for " + name,
|
||||
filename: this.currentFileInfo.file,
|
||||
index: this.index };
|
||||
}
|
||||
|
||||
|
||||
this.evaluating = true;
|
||||
|
||||
variable = tree.find(env.frames, function (frame) {
|
||||
@@ -29,7 +29,7 @@ tree.Variable.prototype = {
|
||||
return v.value.eval(env);
|
||||
}
|
||||
});
|
||||
if (variable) {
|
||||
if (variable) {
|
||||
this.evaluating = false;
|
||||
return variable;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user