less 2.1.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/.idea/inspectionProfiles/Project_Default.xml +1 -0
  2. package/.idea/jsLinters/jscs.xml +4 -0
  3. package/.idea/jsLinters/jshint.xml +58 -4
  4. package/.idea/workspace.xml +499 -760
  5. package/.jscsrc +73 -0
  6. package/.jshintrc +0 -2
  7. package/.travis.yml +1 -0
  8. package/CHANGELOG.md +59 -0
  9. package/Gruntfile.js +37 -3
  10. package/appveyor.yml +5 -0
  11. package/bin/lessc +383 -316
  12. package/bower.json +1 -1
  13. package/dist/less.js +1638 -1244
  14. package/dist/less.min.js +7 -7
  15. package/lib/less/contexts.js +3 -3
  16. package/lib/less/data/unit-conversions.js +3 -3
  17. package/lib/less/environment/abstract-file-manager.js +8 -8
  18. package/lib/less/environment/environment.js +2 -2
  19. package/lib/less/functions/color-blending.js +3 -3
  20. package/lib/less/functions/color.js +20 -12
  21. package/lib/less/functions/data-uri.js +26 -18
  22. package/lib/less/functions/math.js +1 -1
  23. package/lib/less/functions/number.js +2 -2
  24. package/lib/less/functions/string.js +3 -1
  25. package/lib/less/functions/svg.js +12 -15
  26. package/lib/less/functions/types.js +33 -10
  27. package/lib/less/import-manager.js +14 -9
  28. package/lib/less/index.js +2 -1
  29. package/lib/less/less-error.js +1 -1
  30. package/lib/less/logger.js +2 -2
  31. package/lib/less/parse-tree.js +48 -42
  32. package/lib/less/parse.js +68 -0
  33. package/lib/less/parser/parser-input.js +6 -5
  34. package/lib/less/parser/parser.js +76 -29
  35. package/lib/less/plugin-manager.js +30 -3
  36. package/lib/less/render.js +11 -37
  37. package/lib/less/source-map-builder.js +4 -0
  38. package/lib/less/source-map-output.js +6 -6
  39. package/lib/less/transform-tree.js +4 -4
  40. package/lib/less/tree/anonymous.js +1 -1
  41. package/lib/less/tree/assignment.js +0 -1
  42. package/lib/less/tree/call.js +1 -1
  43. package/lib/less/tree/color.js +6 -6
  44. package/lib/less/tree/condition.js +9 -5
  45. package/lib/less/tree/debug-info.js +6 -2
  46. package/lib/less/tree/dimension.js +5 -5
  47. package/lib/less/tree/directive.js +25 -6
  48. package/lib/less/tree/element.js +1 -1
  49. package/lib/less/tree/expression.js +2 -2
  50. package/lib/less/tree/extend.js +3 -3
  51. package/lib/less/tree/import.js +2 -2
  52. package/lib/less/tree/index.js +1 -0
  53. package/lib/less/tree/javascript.js +2 -2
  54. package/lib/less/tree/media.js +20 -19
  55. package/lib/less/tree/mixin-call.js +5 -6
  56. package/lib/less/tree/mixin-definition.js +33 -11
  57. package/lib/less/tree/quoted.js +3 -3
  58. package/lib/less/tree/rule.js +3 -4
  59. package/lib/less/tree/ruleset.js +290 -177
  60. package/lib/less/tree/selector.js +3 -2
  61. package/lib/less/tree/unit.js +2 -0
  62. package/lib/less/tree/url.js +5 -2
  63. package/lib/less/tree/value.js +2 -2
  64. package/lib/less/tree/variable.js +1 -1
  65. package/lib/less/visitors/extend-visitor.js +72 -36
  66. package/lib/less/visitors/import-sequencer.js +20 -14
  67. package/lib/less/visitors/import-visitor.js +15 -12
  68. package/lib/less/visitors/to-css-visitor.js +41 -9
  69. package/lib/less-browser/add-default-options.js +5 -1
  70. package/lib/less-browser/bootstrap.js +10 -8
  71. package/lib/less-browser/cache.js +3 -3
  72. package/lib/less-browser/file-manager.js +96 -96
  73. package/lib/less-browser/index.js +206 -205
  74. package/lib/less-browser/log-listener.js +2 -2
  75. package/lib/less-browser/utils.js +6 -6
  76. package/lib/less-node/file-manager.js +58 -30
  77. package/lib/less-node/image-size.js +34 -0
  78. package/lib/less-node/index.js +6 -3
  79. package/lib/less-node/lessc-helper.js +3 -2
  80. package/lib/less-node/plugin-loader.js +3 -3
  81. package/lib/less-node/url-file-manager.js +6 -3
  82. package/lib/less-rhino/index.js +15 -13
  83. package/lib/source-map/source-map-0.1.31.js +1 -1
  84. package/package.json +10 -7
  85. package/test/browser/common.js +13 -11
  86. package/test/browser/css/relative-urls/urls.css +1 -0
  87. package/test/browser/css/urls.css +6 -3
  88. package/test/browser/jasmine-jsreporter.js +2 -3
  89. package/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
  90. package/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
  91. package/test/browser/less/relative-urls/urls.less +1 -0
  92. package/test/browser/less/urls.less +1 -0
  93. package/test/browser/runner-browser-options.js +23 -23
  94. package/test/browser/runner-errors-options.js +0 -1
  95. package/test/browser/runner-errors-spec.js +1 -2
  96. package/test/browser/runner-global-vars-spec.js +1 -1
  97. package/test/browser/runner-legacy-options.js +0 -1
  98. package/test/browser/runner-main-options.js +5 -5
  99. package/test/browser/runner-main-spec.js +1 -1
  100. package/test/browser/runner-no-js-errors-spec.js +0 -1
  101. package/test/browser/runner-production-options.js +0 -1
  102. package/test/browser/runner-relative-urls-options.js +0 -1
  103. package/test/browser/runner-rootpath-options.js +0 -1
  104. package/test/browser/runner-rootpath-relative-options.js +0 -1
  105. package/test/browser/runner-strict-units-options.js +0 -1
  106. package/test/copy-bom.js +72 -0
  107. package/test/css/comments.css +1 -0
  108. package/test/css/css-3.css +2 -0
  109. package/test/css/functions.css +10 -0
  110. package/test/css/import-interpolation.css +7 -0
  111. package/test/css/import-reference.css +25 -0
  112. package/test/css/include-path/include-path.css +6 -0
  113. package/test/css/mixins-important.css +12 -0
  114. package/test/css/selectors.css +15 -1
  115. package/test/css/static-urls/urls.css +1 -0
  116. package/test/css/url-args/urls.css +3 -3
  117. package/test/css/urls.css +13 -4
  118. package/test/css/variables.css +7 -1
  119. package/test/data/image.svg +3 -0
  120. package/test/index.js +15 -10
  121. package/test/less/comments.less +1 -0
  122. package/test/less/css-3.less +3 -0
  123. package/test/less/css-guards.less +2 -1
  124. package/test/less/errors/detached-ruleset-2.txt +1 -1
  125. package/test/less/errors/import-missing.txt +1 -1
  126. package/test/less/errors/parens-error-1.txt +1 -1
  127. package/test/less/errors/parens-error-2.txt +1 -1
  128. package/test/less/errors/parens-error-3.txt +1 -1
  129. package/test/less/errors/single-character.less +1 -0
  130. package/test/less/errors/single-character.txt +2 -0
  131. package/test/less/functions.less +18 -0
  132. package/test/less/import/import-interpolation.less +1 -0
  133. package/test/less/import/import-reference.less +38 -0
  134. package/test/less/import/imports/logo.less +1 -0
  135. package/test/less/import-reference.less +3 -1
  136. package/test/less/import.less +2 -0
  137. package/test/less/include-path/include-path.less +6 -0
  138. package/test/less/mixins-important.less +28 -0
  139. package/test/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
  140. package/test/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
  141. package/test/less/selectors.less +29 -4
  142. package/test/less/sourcemaps-empty/empty.less +0 -0
  143. package/test/less/sourcemaps-empty/var-defs.less +1 -0
  144. package/test/less/urls.less +10 -1
  145. package/test/less/variables.less +17 -3
  146. package/test/less-test.js +133 -52
  147. package/test/modify-vars.js +14 -12
  148. package/test/browser/less.js +0 -9473
@@ -21,7 +21,7 @@ module.exports = function(root, options) {
21
21
  // ])
22
22
  // )
23
23
  //
24
- if (typeof(variables) === 'object' && !Array.isArray(variables)) {
24
+ if (typeof variables === 'object' && !Array.isArray(variables)) {
25
25
  variables = Object.keys(variables).map(function (k) {
26
26
  var value = variables[k];
27
27
 
@@ -45,7 +45,7 @@ module.exports = function(root, options) {
45
45
 
46
46
  if (options.pluginManager) {
47
47
  var pluginVisitors = options.pluginManager.getVisitors();
48
- for(i =0; i < pluginVisitors.length; i++) {
48
+ for (i = 0; i < pluginVisitors.length; i++) {
49
49
  var pluginVisitor = pluginVisitors[i];
50
50
  if (pluginVisitor.isPreEvalVisitor) {
51
51
  preEvalVisitors.push(pluginVisitor);
@@ -59,13 +59,13 @@ module.exports = function(root, options) {
59
59
  }
60
60
  }
61
61
 
62
- for(i = 0; i < preEvalVisitors.length; i++) {
62
+ for (i = 0; i < preEvalVisitors.length; i++) {
63
63
  preEvalVisitors[i].run(root);
64
64
  }
65
65
 
66
66
  evaldRoot = root.eval(evalEnv);
67
67
 
68
- for(i = 0; i < visitors.length; i++) {
68
+ for (i = 0; i < visitors.length; i++) {
69
69
  visitors[i].run(evaldRoot);
70
70
  }
71
71
 
@@ -5,7 +5,7 @@ var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike)
5
5
  this.index = index;
6
6
  this.mapLines = mapLines;
7
7
  this.currentFileInfo = currentFileInfo;
8
- this.rulesetLike = (typeof rulesetLike === 'undefined')? false : rulesetLike;
8
+ this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike;
9
9
  };
10
10
  Anonymous.prototype = new Node();
11
11
  Anonymous.prototype.type = "Anonymous";
@@ -25,4 +25,3 @@ Assignment.prototype.genCSS = function (context, output) {
25
25
  }
26
26
  };
27
27
  module.exports = Assignment;
28
-
@@ -50,7 +50,7 @@ Call.prototype.eval = function (context) {
50
50
  Call.prototype.genCSS = function (context, output) {
51
51
  output.add(this.name + "(", this.currentFileInfo, this.index);
52
52
 
53
- for(var i = 0; i < this.args.length; i++) {
53
+ for (var i = 0; i < this.args.length; i++) {
54
54
  this.args[i].genCSS(context, output);
55
55
  if (i + 1 < this.args.length) {
56
56
  output.add(", ");
@@ -22,7 +22,7 @@ var Color = function (rgb, a) {
22
22
  return parseInt(c + c, 16);
23
23
  });
24
24
  }
25
- this.alpha = typeof(a) === 'number' ? a : 1;
25
+ this.alpha = typeof a === 'number' ? a : 1;
26
26
  };
27
27
 
28
28
  Color.prototype = new Node();
@@ -56,11 +56,11 @@ Color.prototype.genCSS = function (context, output) {
56
56
  Color.prototype.toCSS = function (context, doNotCompress) {
57
57
  var compress = context && context.compress && !doNotCompress, color, alpha;
58
58
 
59
- // `keyword` is set if this color was originally
59
+ // `value` is set if this color was originally
60
60
  // converted from a named color string so we need
61
61
  // to respect this and try to output named color too.
62
- if (this.keyword) {
63
- return this.keyword;
62
+ if (this.value) {
63
+ return this.value;
64
64
  }
65
65
 
66
66
  // If we have some transparency, the only way to represent it
@@ -149,7 +149,7 @@ Color.prototype.toHSV = function () {
149
149
  if (max === min) {
150
150
  h = 0;
151
151
  } else {
152
- switch(max){
152
+ switch(max) {
153
153
  case r: h = (g - b) / d + (g < b ? 6 : 0); break;
154
154
  case g: h = (b - r) / d + 2; break;
155
155
  case b: h = (r - g) / d + 4; break;
@@ -179,7 +179,7 @@ Color.fromKeyword = function(keyword) {
179
179
  }
180
180
 
181
181
  if (c) {
182
- c.keyword = keyword;
182
+ c.value = keyword;
183
183
  return c;
184
184
  }
185
185
  };
@@ -20,13 +20,17 @@ Condition.prototype.eval = function (context) {
20
20
  case 'or': return a || b;
21
21
  default:
22
22
  switch (Node.compare(a, b)) {
23
- case -1: return op === '<' || op === '=<' || op === '<=';
24
- case 0: return op === '=' || op === '>=' || op === '=<' || op === '<=';
25
- case 1: return op === '>' || op === '>=';
26
- default: return false;
23
+ case -1:
24
+ return op === '<' || op === '=<' || op === '<=';
25
+ case 0:
26
+ return op === '=' || op === '>=' || op === '=<' || op === '<=';
27
+ case 1:
28
+ return op === '>' || op === '>=';
29
+ default:
30
+ return false;
27
31
  }
28
32
  }
29
- }) (this.op, this.lvalue.eval(context), this.rvalue.eval(context));
33
+ })(this.op, this.lvalue.eval(context), this.rvalue.eval(context));
30
34
 
31
35
  return this.negate ? !result : result;
32
36
  };
@@ -1,5 +1,5 @@
1
1
  var debugInfo = function(context, ctx, lineSeparator) {
2
- var result="";
2
+ var result = "";
3
3
  if (context.dumpLineNumbers && !context.compress) {
4
4
  switch(context.dumpLineNumbers) {
5
5
  case 'comments':
@@ -21,8 +21,12 @@ debugInfo.asComment = function(ctx) {
21
21
  };
22
22
 
23
23
  debugInfo.asMediaQuery = function(ctx) {
24
+ var filenameWithProtocol = ctx.debugInfo.fileName;
25
+ if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) {
26
+ filenameWithProtocol = 'file://' + filenameWithProtocol;
27
+ }
24
28
  return '@media -sass-debug-info{filename{font-family:' +
25
- ('file://' + ctx.debugInfo.fileName).replace(/([.:\/\\])/g, function (a) {
29
+ filenameWithProtocol.replace(/([.:\/\\])/g, function (a) {
26
30
  if (a == '\\') {
27
31
  a = '\/';
28
32
  }
@@ -25,7 +25,7 @@ Dimension.prototype.toColor = function () {
25
25
  };
26
26
  Dimension.prototype.genCSS = function (context, output) {
27
27
  if ((context && context.strictUnits) && !this.unit.isSingular()) {
28
- throw new Error("Multiple units in dimension. Correct the units or use the unit function. Bad unit: "+this.unit.toString());
28
+ throw new Error("Multiple units in dimension. Correct the units or use the unit function. Bad unit: " + this.unit.toString());
29
29
  }
30
30
 
31
31
  var value = this.fround(context, this.value),
@@ -70,9 +70,9 @@ Dimension.prototype.operate = function (context, op, other) {
70
70
  } else {
71
71
  other = other.convertTo(this.unit.usedUnits());
72
72
 
73
- if(context.strictUnits && other.unit.toString() !== unit.toString()) {
74
- throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '" + unit.toString() +
75
- "' and '" + other.unit.toString() + "'.");
73
+ if (context.strictUnits && other.unit.toString() !== unit.toString()) {
74
+ throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '" + unit.toString() +
75
+ "' and '" + other.unit.toString() + "'.");
76
76
  }
77
77
 
78
78
  value = this._operate(context, op, this.value, other.value);
@@ -116,7 +116,7 @@ Dimension.prototype.convertTo = function (conversions) {
116
116
  i, groupName, group, targetUnit, derivedConversions = {}, applyUnit;
117
117
 
118
118
  if (typeof conversions === 'string') {
119
- for(i in unitConversions) {
119
+ for (i in unitConversions) {
120
120
  if (unitConversions[i].hasOwnProperty(conversions)) {
121
121
  derivedConversions = {};
122
122
  derivedConversions[i] = conversions;
@@ -1,7 +1,7 @@
1
1
  var Node = require("./node"),
2
2
  Ruleset = require("./ruleset");
3
3
 
4
- var Directive = function (name, value, rules, index, currentFileInfo, debugInfo) {
4
+ var Directive = function (name, value, rules, index, currentFileInfo, debugInfo, isReferenced) {
5
5
  this.name = name;
6
6
  this.value = value;
7
7
  if (rules) {
@@ -11,6 +11,7 @@ var Directive = function (name, value, rules, index, currentFileInfo, debugInfo)
11
11
  this.index = index;
12
12
  this.currentFileInfo = currentFileInfo;
13
13
  this.debugInfo = debugInfo;
14
+ this.isReferenced = isReferenced;
14
15
  };
15
16
 
16
17
  Directive.prototype = new Node();
@@ -38,7 +39,10 @@ Directive.prototype.genCSS = function (context, output) {
38
39
  value.genCSS(context, output);
39
40
  }
40
41
  if (rules) {
41
- this.outputRuleset(context, output, [rules]);
42
+ if (rules.type === "Ruleset") {
43
+ rules = [rules];
44
+ }
45
+ this.outputRuleset(context, output, rules);
42
46
  } else {
43
47
  output.add(';');
44
48
  }
@@ -53,11 +57,23 @@ Directive.prototype.eval = function (context) {
53
57
  rules.root = true;
54
58
  }
55
59
  return new Directive(this.name, value, rules,
56
- this.index, this.currentFileInfo, this.debugInfo);
60
+ this.index, this.currentFileInfo, this.debugInfo, this.isReferenced);
61
+ };
62
+ Directive.prototype.variable = function (name) {
63
+ if (this.rules) {
64
+ return Ruleset.prototype.variable.call(this.rules, name);
65
+ }
66
+ };
67
+ Directive.prototype.find = function () {
68
+ if (this.rules) {
69
+ return Ruleset.prototype.find.apply(this.rules, arguments);
70
+ }
71
+ };
72
+ Directive.prototype.rulesets = function () {
73
+ if (this.rules) {
74
+ return Ruleset.prototype.rulesets.apply(this.rules);
75
+ }
57
76
  };
58
- Directive.prototype.variable = function (name) { if (this.rules) return Ruleset.prototype.variable.call(this.rules, name); };
59
- Directive.prototype.find = function () { if (this.rules) return Ruleset.prototype.find.apply(this.rules, arguments); };
60
- Directive.prototype.rulesets = function () { if (this.rules) return Ruleset.prototype.rulesets.apply(this.rules); };
61
77
  Directive.prototype.markReferenced = function () {
62
78
  var i, rules;
63
79
  this.isReferenced = true;
@@ -70,6 +86,9 @@ Directive.prototype.markReferenced = function () {
70
86
  }
71
87
  }
72
88
  };
89
+ Directive.prototype.getIsReferenced = function () {
90
+ return !this.currentFileInfo || !this.currentFileInfo.reference || this.isReferenced;
91
+ };
73
92
  Directive.prototype.outputRuleset = function (context, output, rules) {
74
93
  var ruleCnt = rules.length, i;
75
94
  context.tabLevel = (context.tabLevel | 0) + 1;
@@ -6,7 +6,7 @@ var Element = function (combinator, value, index, currentFileInfo) {
6
6
  this.combinator = combinator instanceof Combinator ?
7
7
  combinator : new Combinator(combinator);
8
8
 
9
- if (typeof(value) === 'string') {
9
+ if (typeof value === 'string') {
10
10
  this.value = value.trim();
11
11
  } else if (value) {
12
12
  this.value = value;
@@ -5,7 +5,7 @@ var Node = require("./node"),
5
5
  var Expression = function (value) {
6
6
  this.value = value;
7
7
  if (!value) {
8
- throw new Error("Expression requires a array parameter");
8
+ throw new Error("Expression requires an array parameter");
9
9
  }
10
10
  };
11
11
  Expression.prototype = new Node();
@@ -41,7 +41,7 @@ Expression.prototype.eval = function (context) {
41
41
  return returnValue;
42
42
  };
43
43
  Expression.prototype.genCSS = function (context, output) {
44
- for(var i = 0; i < this.value.length; i++) {
44
+ for (var i = 0; i < this.value.length; i++) {
45
45
  this.value[i].genCSS(context, output);
46
46
  if (i + 1 < this.value.length) {
47
47
  output.add(" ");
@@ -11,11 +11,11 @@ var Extend = function Extend(selector, option, index) {
11
11
  case "all":
12
12
  this.allowBefore = true;
13
13
  this.allowAfter = true;
14
- break;
14
+ break;
15
15
  default:
16
16
  this.allowBefore = false;
17
17
  this.allowAfter = false;
18
- break;
18
+ break;
19
19
  }
20
20
  };
21
21
  Extend.next_id = 0;
@@ -36,7 +36,7 @@ Extend.prototype.findSelfSelectors = function (selectors) {
36
36
  i,
37
37
  selectorElements;
38
38
 
39
- for(i = 0; i < selectors.length; i++) {
39
+ for (i = 0; i < selectors.length; i++) {
40
40
  selectorElements = selectors[i].elements;
41
41
  // duplicate the logic in genCSS function inside the selector node.
42
42
  // future TODO - move both logics into the selector joiner visitor
@@ -28,7 +28,7 @@ var Import = function (path, features, options, index, currentFileInfo) {
28
28
  this.css = !this.options.less || this.options.inline;
29
29
  } else {
30
30
  var pathValue = this.getPath();
31
- if (pathValue && /css([\?;].*)?$/.test(pathValue)) {
31
+ if (pathValue && /[#\.\&\?\/]css([\?;].*)?$/.test(pathValue)) {
32
32
  this.css = true;
33
33
  }
34
34
  }
@@ -100,7 +100,7 @@ Import.prototype.evalPath = function (context) {
100
100
  var pathValue = path.value;
101
101
  // Add the base path if the import is relative
102
102
  if (pathValue && context.isPathRelative(pathValue)) {
103
- path.value = rootpath +pathValue;
103
+ path.value = rootpath + pathValue;
104
104
  }
105
105
  }
106
106
  path.value = context.normalizePath(path.value);
@@ -1,5 +1,6 @@
1
1
  var tree = {};
2
2
 
3
+ tree.Node = require('./node');
3
4
  tree.Alpha = require('./alpha');
4
5
  tree.Color = require('./color');
5
6
  tree.Directive = require('./directive');
@@ -14,9 +14,9 @@ JavaScript.prototype.type = "JavaScript";
14
14
  JavaScript.prototype.eval = function(context) {
15
15
  var result = this.evaluateJavaScript(this.expression, context);
16
16
 
17
- if (typeof(result) === 'number') {
17
+ if (typeof result === 'number') {
18
18
  return new Dimension(result);
19
- } else if (typeof(result) === 'string') {
19
+ } else if (typeof result === 'string') {
20
20
  return new Quoted('"' + result + '"', result, this.escaped, this.index);
21
21
  } else if (Array.isArray(result)) {
22
22
  return new Anonymous(result.join(', '));
@@ -39,7 +39,7 @@ Media.prototype.eval = function (context) {
39
39
  }
40
40
 
41
41
  var media = new Media(null, [], this.index, this.currentFileInfo);
42
- if(this.debugInfo) {
42
+ if (this.debugInfo) {
43
43
  this.rules[0].debugInfo = this.debugInfo;
44
44
  media.debugInfo = this.debugInfo;
45
45
  }
@@ -127,7 +127,7 @@ Media.prototype.evalNested = function (context) {
127
127
  return fragment.toCSS ? fragment : new Anonymous(fragment);
128
128
  });
129
129
 
130
- for(i = path.length - 1; i > 0; i--) {
130
+ for (i = path.length - 1; i > 0; i--) {
131
131
  path.splice(i, 0, new Anonymous("and"));
132
132
  }
133
133
 
@@ -138,24 +138,25 @@ Media.prototype.evalNested = function (context) {
138
138
  return new Ruleset([], []);
139
139
  };
140
140
  Media.prototype.permute = function (arr) {
141
- if (arr.length === 0) {
142
- return [];
143
- } else if (arr.length === 1) {
144
- return arr[0];
145
- } else {
146
- var result = [];
147
- var rest = this.permute(arr.slice(1));
148
- for (var i = 0; i < rest.length; i++) {
149
- for (var j = 0; j < arr[0].length; j++) {
150
- result.push([arr[0][j]].concat(rest[i]));
151
- }
152
- }
153
- return result;
154
- }
141
+ if (arr.length === 0) {
142
+ return [];
143
+ } else if (arr.length === 1) {
144
+ return arr[0];
145
+ } else {
146
+ var result = [];
147
+ var rest = this.permute(arr.slice(1));
148
+ for (var i = 0; i < rest.length; i++) {
149
+ for (var j = 0; j < arr[0].length; j++) {
150
+ result.push([arr[0][j]].concat(rest[i]));
151
+ }
152
+ }
153
+ return result;
154
+ }
155
155
  };
156
156
  Media.prototype.bubbleSelectors = function (selectors) {
157
- if (!selectors)
158
- return;
159
- this.rules = [new Ruleset(selectors.slice(0), [this.rules[0]])];
157
+ if (!selectors) {
158
+ return;
159
+ }
160
+ this.rules = [new Ruleset(selectors.slice(0), [this.rules[0]])];
160
161
  };
161
162
  module.exports = Media;
@@ -22,7 +22,7 @@ MixinCall.prototype.accept = function (visitor) {
22
22
  };
23
23
  MixinCall.prototype.eval = function (context) {
24
24
  var mixins, mixin, mixinPath, args, rules = [], match = false, i, m, f, isRecursive, isOneFound, rule,
25
- candidates = [], candidate, conditionResult = [], defaultResult, defFalseEitherCase=-1,
25
+ candidates = [], candidate, conditionResult = [], defaultResult, defFalseEitherCase = -1,
26
26
  defNone = 0, defTrue = 1, defFalse = 2, count, originalRuleset, noArgumentsFilter;
27
27
 
28
28
  function calcDefGroup(mixin, mixinPath) {
@@ -31,7 +31,7 @@ MixinCall.prototype.eval = function (context) {
31
31
  for (f = 0; f < 2; f++) {
32
32
  conditionResult[f] = true;
33
33
  defaultFunc.value(f);
34
- for(p = 0; p < mixinPath.length && conditionResult[f]; p++) {
34
+ for (p = 0; p < mixinPath.length && conditionResult[f]; p++) {
35
35
  namespace = mixinPath[p];
36
36
  if (namespace.matchCondition) {
37
37
  conditionResult[f] = conditionResult[f] && namespace.matchCondition(null, context);
@@ -71,7 +71,7 @@ MixinCall.prototype.eval = function (context) {
71
71
  mixin = mixins[m].rule;
72
72
  mixinPath = mixins[m].path;
73
73
  isRecursive = false;
74
- for(f = 0; f < context.frames.length; f++) {
74
+ for (f = 0; f < context.frames.length; f++) {
75
75
  if ((!(mixin instanceof MixinDefinition)) && mixin === (context.frames[f].originalRuleset || context.frames[f])) {
76
76
  isRecursive = true;
77
77
  break;
@@ -84,7 +84,7 @@ MixinCall.prototype.eval = function (context) {
84
84
  if (mixin.matchArgs(args, context)) {
85
85
  candidate = {mixin: mixin, group: calcDefGroup(mixin, mixinPath)};
86
86
 
87
- if (candidate.group!==defFalseEitherCase) {
87
+ if (candidate.group !== defFalseEitherCase) {
88
88
  candidates.push(candidate);
89
89
  }
90
90
 
@@ -105,8 +105,7 @@ MixinCall.prototype.eval = function (context) {
105
105
  defaultResult = defTrue;
106
106
  if ((count[defTrue] + count[defFalse]) > 1) {
107
107
  throw { type: 'Runtime',
108
- message: 'Ambiguous use of `default()` found when matching for `'
109
- + this.format(args) + '`',
108
+ message: 'Ambiguous use of `default()` found when matching for `' + this.format(args) + '`',
110
109
  index: this.index, filename: this.currentFileInfo.filename };
111
110
  }
112
111
  }
@@ -15,8 +15,12 @@ var Definition = function (name, params, rules, condition, variadic, frames) {
15
15
  this.rules = rules;
16
16
  this._lookups = {};
17
17
  this.required = params.reduce(function (count, p) {
18
- if (!p.name || (p.name && !p.value)) { return count + 1; }
19
- else { return count; }
18
+ if (!p.name || (p.name && !p.value)) {
19
+ return count + 1;
20
+ }
21
+ else {
22
+ return count;
23
+ }
20
24
  }, 0);
21
25
  this.frames = frames;
22
26
  };
@@ -45,11 +49,11 @@ Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArgume
45
49
  args = args.slice(0);
46
50
  argsLength = args.length;
47
51
 
48
- for(i = 0; i < argsLength; i++) {
52
+ for (i = 0; i < argsLength; i++) {
49
53
  arg = args[i];
50
54
  if (name = (arg && arg.name)) {
51
55
  isNamedFound = false;
52
- for(j = 0; j < params.length; j++) {
56
+ for (j = 0; j < params.length; j++) {
53
57
  if (!evaldArguments[j] && name === params[j].name) {
54
58
  evaldArguments[j] = arg.value.eval(context);
55
59
  frame.prependRule(new Rule(name, arg.value.eval(context)));
@@ -108,6 +112,17 @@ Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArgume
108
112
 
109
113
  return frame;
110
114
  };
115
+ Definition.prototype.makeImportant = function() {
116
+ var rules = !this.rules ? this.rules : this.rules.map(function (r) {
117
+ if (r.makeImportant) {
118
+ return r.makeImportant(true);
119
+ } else {
120
+ return r;
121
+ }
122
+ });
123
+ var result = new Definition (this.name, this.params, rules, this.condition, this.variadic, this.frames);
124
+ return result;
125
+ };
111
126
  Definition.prototype.eval = function (context) {
112
127
  return new Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || context.frames.slice(0));
113
128
  };
@@ -125,16 +140,17 @@ Definition.prototype.evalCall = function (context, args, important) {
125
140
  ruleset.originalRuleset = this;
126
141
  ruleset = ruleset.eval(new contexts.Eval(context, [this, frame].concat(mixinFrames)));
127
142
  if (important) {
128
- ruleset = this.makeImportant.apply(ruleset);
143
+ ruleset = ruleset.makeImportant();
129
144
  }
130
145
  return ruleset;
131
146
  };
132
147
  Definition.prototype.matchCondition = function (args, context) {
133
148
  if (this.condition && !this.condition.eval(
134
149
  new contexts.Eval(context,
135
- [this.evalParams(context, new contexts.Eval(context, this.frames ? this.frames.concat(context.frames) : context.frames), args, [])] // the parameter variables
136
- .concat(this.frames) // the parent namespace/mixin frames
137
- .concat(context.frames)))) { // the current environment frames
150
+ [this.evalParams(context, /* the parameter variables*/
151
+ new contexts.Eval(context, this.frames ? this.frames.concat(context.frames) : context.frames), args, [])]
152
+ .concat(this.frames) // the parent namespace/mixin frames
153
+ .concat(context.frames)))) { // the current environment frames
138
154
  return false;
139
155
  }
140
156
  return true;
@@ -143,10 +159,16 @@ Definition.prototype.matchArgs = function (args, context) {
143
159
  var argsLength = (args && args.length) || 0, len;
144
160
 
145
161
  if (! this.variadic) {
146
- if (argsLength < this.required) { return false; }
147
- if (argsLength > this.params.length) { return false; }
162
+ if (argsLength < this.required) {
163
+ return false;
164
+ }
165
+ if (argsLength > this.params.length) {
166
+ return false;
167
+ }
148
168
  } else {
149
- if (argsLength < (this.required - 1)) { return false; }
169
+ if (argsLength < (this.required - 1)) {
170
+ return false;
171
+ }
150
172
  }
151
173
 
152
174
  len = Math.min(argsLength, this.arity);
@@ -35,9 +35,9 @@ Quoted.prototype.eval = function (context) {
35
35
  function iterativeReplace(value, regexp, replacementFnc) {
36
36
  var evaluatedValue = value;
37
37
  do {
38
- value = evaluatedValue;
39
- evaluatedValue = value.replace(regexp, replacementFnc);
40
- } while (value!==evaluatedValue);
38
+ value = evaluatedValue;
39
+ evaluatedValue = value.replace(regexp, replacementFnc);
40
+ } while (value !== evaluatedValue);
41
41
  return evaluatedValue;
42
42
  }
43
43
  value = iterativeReplace(value, /`([^`]+)`/g, javascriptReplacement);
@@ -42,10 +42,9 @@ Rule.prototype.eval = function (context) {
42
42
  if (typeof name !== "string") {
43
43
  // expand 'primitive' name directly to get
44
44
  // things faster (~10% for benchmark.less):
45
- name = (name.length === 1)
46
- && (name[0] instanceof Keyword)
47
- ? name[0].value : evalName(context, name);
48
- variable = false; // never treat expanded interpolation as new variable name
45
+ name = (name.length === 1) && (name[0] instanceof Keyword) ?
46
+ name[0].value : evalName(context, name);
47
+ variable = false; // never treat expanded interpolation as new variable name
49
48
  }
50
49
  if (name === "font" && !context.strictMath) {
51
50
  strictMathBypass = true;