less 1.7.0 → 1.7.5

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 (109) hide show
  1. package/.grunt/grunt-contrib-jasmine/es5-shim.js +1360 -0
  2. package/.idea/jsLibraryMappings.xml +0 -1
  3. package/.idea/workspace.xml +182 -183
  4. package/.travis.yml +0 -1
  5. package/CHANGELOG.md +60 -2
  6. package/CONTRIBUTING.md +1 -1
  7. package/Gruntfile.js +12 -24
  8. package/LICENSE +0 -2
  9. package/README.md +5 -3
  10. package/benchmark/less-benchmark.js +1 -2
  11. package/bin/lessc +13 -11
  12. package/bower.json +2 -2
  13. package/build/rhino-modules.js +1 -1
  14. package/dist/less-1.7.0.js +59 -59
  15. package/dist/less-1.7.0.min.js +12 -12
  16. package/dist/less-1.7.1.js +7936 -0
  17. package/dist/less-1.7.1.min.js +16 -0
  18. package/dist/less-1.7.2.js +7938 -0
  19. package/dist/less-1.7.2.min.js +16 -0
  20. package/dist/less-1.7.3.js +7942 -0
  21. package/dist/less-1.7.3.min.js +16 -0
  22. package/dist/less-1.7.4.js +7979 -0
  23. package/dist/less-1.7.4.min.js +16 -0
  24. package/dist/less-1.7.5.js +8008 -0
  25. package/dist/less-1.7.5.min.js +16 -0
  26. package/dist/less-rhino-1.7.0.js +48 -48
  27. package/dist/less-rhino-1.7.1.js +9311 -0
  28. package/dist/less-rhino-1.7.2.js +9313 -0
  29. package/dist/less-rhino-1.7.3.js +9317 -0
  30. package/dist/less-rhino-1.7.4.js +9354 -0
  31. package/dist/less-rhino-1.7.5.js +9383 -0
  32. package/dist/lessc-rhino-1.7.0.js +2 -2
  33. package/dist/lessc-rhino-1.7.1.js +449 -0
  34. package/dist/lessc-rhino-1.7.2.js +449 -0
  35. package/dist/lessc-rhino-1.7.3.js +449 -0
  36. package/dist/lessc-rhino-1.7.4.js +449 -0
  37. package/dist/lessc-rhino-1.7.5.js +449 -0
  38. package/lib/less/browser.js +14 -9
  39. package/lib/less/env.js +2 -0
  40. package/lib/less/fs.js +10 -0
  41. package/lib/less/functions.js +41 -38
  42. package/lib/less/import-visitor.js +9 -7
  43. package/lib/less/index.js +30 -18
  44. package/lib/less/lessc_helper.js +1 -0
  45. package/lib/less/parser/parser.js.orig +1747 -0
  46. package/lib/less/parser.js +81 -40
  47. package/lib/less/rhino.js +3 -3
  48. package/lib/less/source-map-output.js +1 -1
  49. package/lib/less/to-css-visitor.js +3 -0
  50. package/lib/less/tree/anonymous.js +7 -3
  51. package/lib/less/tree/directive.js +6 -0
  52. package/lib/less/tree/element.js +6 -22
  53. package/lib/less/tree/import.js +1 -1
  54. package/lib/less/tree/mixin.js +4 -3
  55. package/lib/less/tree/quoted.js +12 -4
  56. package/lib/less/tree/rule.js +7 -4
  57. package/lib/less/tree/rule.js.orig +164 -0
  58. package/lib/less/tree/ruleset.js +27 -2
  59. package/lib/less/tree/selector.js +1 -1
  60. package/lib/less/tree.js +2 -2
  61. package/package.json +13 -12
  62. package/test/browser/less.js +7317 -6931
  63. package/test/css/comments.css +8 -0
  64. package/test/css/css-3.css +9 -0
  65. package/test/css/functions.css +8 -8
  66. package/test/css/import-inline.css +4 -1
  67. package/test/css/import.css +6 -0
  68. package/test/css/javascript.css +5 -0
  69. package/test/css/mixins-guards.css +14 -3
  70. package/test/css/mixins.css +3 -0
  71. package/test/css/property-name-interp.css +1 -0
  72. package/test/css/urls.css +6 -0
  73. package/test/index.js +1 -1
  74. package/test/less/comments.less +14 -1
  75. package/test/less/css-3.less +12 -1
  76. package/test/less/errors/color-invalid-hex-code.less +3 -0
  77. package/test/less/errors/color-invalid-hex-code.txt +4 -0
  78. package/test/less/errors/color-invalid-hex-code2.less +3 -0
  79. package/test/less/errors/color-invalid-hex-code2.txt +4 -0
  80. package/test/less/errors/import-malformed.less +1 -0
  81. package/test/less/errors/import-malformed.txt +3 -0
  82. package/test/less/errors/import-no-semi.txt +1 -1
  83. package/test/less/errors/javascript-error.less +1 -1
  84. package/test/less/errors/javascript-error.txt +2 -2
  85. package/test/less/import-inline.less +1 -0
  86. package/test/less/import.less +8 -1
  87. package/test/less/javascript.less +9 -0
  88. package/test/less/mixins-guards.less +17 -3
  89. package/test/less/mixins.less +4 -0
  90. package/test/less/property-name-interp.less +4 -1
  91. package/test/less/property-name-interp.less.orig +59 -0
  92. package/test/less/urls.less +12 -0
  93. package/test/less-test.js +7 -8
  94. package/test/modify-vars.js +17 -0
  95. package/test/sourcemaps/basic.json +1 -1
  96. package/tmp/browser/test-runner-main.html +4 -0
  97. package/tmp/less.js +8295 -0
  98. package/build/README.md +0 -51
  99. package/tmp/browser/test-postProcessor.html +0 -59
  100. package/tmp/browser/test-runner-browser.html +0 -59
  101. package/tmp/browser/test-runner-errors.html +0 -267
  102. package/tmp/browser/test-runner-global-vars.html +0 -59
  103. package/tmp/browser/test-runner-legacy.html +0 -59
  104. package/tmp/browser/test-runner-modify-vars.html +0 -59
  105. package/tmp/browser/test-runner-no-js-errors.html +0 -59
  106. package/tmp/browser/test-runner-production.html +0 -55
  107. package/tmp/browser/test-runner-relative-urls.html +0 -59
  108. package/tmp/browser/test-runner-rootpath-relative.html +0 -59
  109. package/tmp/browser/test-runner-rootpath.html +0 -59
@@ -0,0 +1,164 @@
1
+ var Node = require("./node.js"),
2
+ Value = require("./value.js"),
3
+ Keyword = require("./keyword.js");
4
+
5
+ <<<<<<< HEAD
6
+ var Rule = function (name, value, important, merge, index, currentFileInfo, inline) {
7
+ =======
8
+ tree.Rule = function (name, value, important, merge, index, currentFileInfo, inline, variable) {
9
+ >>>>>>> origin/master
10
+ this.name = name;
11
+ this.value = (value instanceof Node) ? value : new(Value)([value]); //value instanceof tree.Value || value instanceof tree.Ruleset ??
12
+ this.important = important ? ' ' + important.trim() : '';
13
+ this.merge = merge;
14
+ this.index = index;
15
+ this.currentFileInfo = currentFileInfo;
16
+ this.inline = inline || false;
17
+ this.variable = (variable !== undefined) ? variable
18
+ : (name.charAt && (name.charAt(0) === '@'));
19
+ };
20
+
21
+ <<<<<<< HEAD
22
+ =======
23
+ tree.Rule.prototype = {
24
+ type: "Rule",
25
+ accept: function (visitor) {
26
+ this.value = visitor.visit(this.value);
27
+ },
28
+ genCSS: function (env, output) {
29
+ output.add(this.name + (env.compress ? ':' : ': '), this.currentFileInfo, this.index);
30
+ try {
31
+ this.value.genCSS(env, output);
32
+ }
33
+ catch(e) {
34
+ e.index = this.index;
35
+ e.filename = this.currentFileInfo.filename;
36
+ throw e;
37
+ }
38
+ output.add(this.important + ((this.inline || (env.lastRule && env.compress)) ? "" : ";"), this.currentFileInfo, this.index);
39
+ },
40
+ toCSS: tree.toCSS,
41
+ eval: function (env) {
42
+ var strictMathBypass = false, name = this.name, variable = this.variable, evaldValue;
43
+ if (typeof name !== "string") {
44
+ // expand 'primitive' name directly to get
45
+ // things faster (~10% for benchmark.less):
46
+ name = (name.length === 1)
47
+ && (name[0] instanceof tree.Keyword)
48
+ ? name[0].value : evalName(env, name);
49
+ variable = false; // never treat expanded interpolation as new variable name
50
+ }
51
+ if (name === "font" && !env.strictMath) {
52
+ strictMathBypass = true;
53
+ env.strictMath = true;
54
+ }
55
+ try {
56
+ evaldValue = this.value.eval(env);
57
+
58
+ if (!this.variable && evaldValue.type === "DetachedRuleset") {
59
+ throw { message: "Rulesets cannot be evaluated on a property.",
60
+ index: this.index, filename: this.currentFileInfo.filename };
61
+ }
62
+
63
+ return new(tree.Rule)(name,
64
+ evaldValue,
65
+ this.important,
66
+ this.merge,
67
+ this.index, this.currentFileInfo, this.inline,
68
+ variable);
69
+ }
70
+ catch(e) {
71
+ if (typeof e.index !== 'number') {
72
+ e.index = this.index;
73
+ e.filename = this.currentFileInfo.filename;
74
+ }
75
+ throw e;
76
+ }
77
+ finally {
78
+ if (strictMathBypass) {
79
+ env.strictMath = false;
80
+ }
81
+ }
82
+ },
83
+ makeImportant: function () {
84
+ return new(tree.Rule)(this.name,
85
+ this.value,
86
+ "!important",
87
+ this.merge,
88
+ this.index, this.currentFileInfo, this.inline);
89
+ }
90
+ };
91
+
92
+ >>>>>>> origin/master
93
+ function evalName(env, name) {
94
+ var value = "", i, n = name.length,
95
+ output = {add: function (s) {value += s;}};
96
+ for (i = 0; i < n; i++) {
97
+ name[i].eval(env).genCSS(env, output);
98
+ }
99
+ return value;
100
+ }
101
+
102
+ Rule.prototype = new Node();
103
+ Rule.prototype.type = "Rule";
104
+ Rule.prototype.genCSS = function (env, output) {
105
+ output.add(this.name + (env.compress ? ':' : ': '), this.currentFileInfo, this.index);
106
+ try {
107
+ this.value.genCSS(env, output);
108
+ }
109
+ catch(e) {
110
+ e.index = this.index;
111
+ e.filename = this.currentFileInfo.filename;
112
+ throw e;
113
+ }
114
+ output.add(this.important + ((this.inline || (env.lastRule && env.compress)) ? "" : ";"), this.currentFileInfo, this.index);
115
+ };
116
+ Rule.prototype.eval = function (env) {
117
+ var strictMathBypass = false, name = this.name, evaldValue;
118
+ if (typeof name !== "string") {
119
+ // expand 'primitive' name directly to get
120
+ // things faster (~10% for benchmark.less):
121
+ name = (name.length === 1)
122
+ && (name[0] instanceof Keyword)
123
+ ? name[0].value : evalName(env, name);
124
+ }
125
+ if (name === "font" && !env.strictMath) {
126
+ strictMathBypass = true;
127
+ env.strictMath = true;
128
+ }
129
+ try {
130
+ evaldValue = this.value.eval(env);
131
+
132
+ if (!this.variable && evaldValue.type === "DetachedRuleset") {
133
+ throw { message: "Rulesets cannot be evaluated on a property.",
134
+ index: this.index, filename: this.currentFileInfo.filename };
135
+ }
136
+
137
+ return new(Rule)(name,
138
+ evaldValue,
139
+ this.important,
140
+ this.merge,
141
+ this.index, this.currentFileInfo, this.inline);
142
+ }
143
+ catch(e) {
144
+ if (typeof e.index !== 'number') {
145
+ e.index = this.index;
146
+ e.filename = this.currentFileInfo.filename;
147
+ }
148
+ throw e;
149
+ }
150
+ finally {
151
+ if (strictMathBypass) {
152
+ env.strictMath = false;
153
+ }
154
+ }
155
+ };
156
+ Rule.prototype.makeImportant = function () {
157
+ return new(Rule)(this.name,
158
+ this.value,
159
+ "!important",
160
+ this.merge,
161
+ this.index, this.currentFileInfo, this.inline);
162
+ };
163
+
164
+ module.exports = Rule;
@@ -266,6 +266,7 @@ tree.Ruleset.prototype = {
266
266
  },
267
267
  genCSS: function (env, output) {
268
268
  var i, j,
269
+ charsetRuleNodes = [],
269
270
  ruleNodes = [],
270
271
  rulesetNodes = [],
271
272
  rulesetNodeCnt,
@@ -283,14 +284,38 @@ tree.Ruleset.prototype = {
283
284
  tabSetStr = env.compress ? '' : Array(env.tabLevel).join(" "),
284
285
  sep;
285
286
 
287
+ function isRulesetLikeNode(rule, root) {
288
+ // if it has nested rules, then it should be treated like a ruleset
289
+ if (rule.rules)
290
+ return true;
291
+
292
+ // medias and comments do not have nested rules, but should be treated like rulesets anyway
293
+ if ( (rule instanceof tree.Media) || (root && rule instanceof tree.Comment))
294
+ return true;
295
+
296
+ // some directives and anonumoust nodes are ruleset like, others are not
297
+ if ((rule instanceof tree.Directive) || (rule instanceof tree.Anonymous)) {
298
+ return rule.isRulesetLike();
299
+ }
300
+
301
+ //anything else is assumed to be a rule
302
+ return false;
303
+ }
304
+
286
305
  for (i = 0; i < this.rules.length; i++) {
287
306
  rule = this.rules[i];
288
- if (rule.rules || (rule instanceof tree.Media) || rule instanceof tree.Directive || (this.root && rule instanceof tree.Comment)) {
307
+ if (isRulesetLikeNode(rule, this.root)) {
289
308
  rulesetNodes.push(rule);
290
309
  } else {
291
- ruleNodes.push(rule);
310
+ //charsets should float on top of everything
311
+ if (rule.isCharset && rule.isCharset()) {
312
+ charsetRuleNodes.push(rule);
313
+ } else {
314
+ ruleNodes.push(rule);
315
+ }
292
316
  }
293
317
  }
318
+ ruleNodes = charsetRuleNodes.concat(ruleNodes);
294
319
 
295
320
  // If this is the root node, we don't render
296
321
  // a selector, or {}.
@@ -73,7 +73,7 @@ tree.Selector.prototype = {
73
73
  css += v.value.value;
74
74
  }
75
75
 
76
- this._elements = css.match(/[,&#\.\w-]([\w-]|(\\.))*/g);
76
+ this._elements = css.match(/[,&#\*\.\w-]([\w-]|(\\.))*/g);
77
77
 
78
78
  if (this._elements) {
79
79
  if (this._elements[0] === "&") {
package/lib/less/tree.js CHANGED
@@ -43,9 +43,9 @@ tree.find = function (obj, fun) {
43
43
 
44
44
  tree.jsify = function (obj) {
45
45
  if (Array.isArray(obj.value) && (obj.value.length > 1)) {
46
- return '[' + obj.value.map(function (v) { return v.toCSS(false); }).join(', ') + ']';
46
+ return '[' + obj.value.map(function (v) { return v.toCSS(); }).join(', ') + ']';
47
47
  } else {
48
- return obj.toCSS(false);
48
+ return obj.toCSS();
49
49
  }
50
50
  };
51
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "less",
3
- "version": "1.7.0",
3
+ "version": "1.7.5",
4
4
  "description": "Leaner CSS",
5
5
  "homepage": "http://lesscss.org",
6
6
  "author": {
@@ -31,7 +31,7 @@
31
31
  "test": "./test"
32
32
  },
33
33
  "jam": {
34
- "main": "./dist/less-1.6.3.js"
34
+ "main": "./dist/less-1.7.5.js"
35
35
  },
36
36
  "engines": {
37
37
  "node": ">=0.8.0"
@@ -40,25 +40,26 @@
40
40
  "test": "grunt test"
41
41
  },
42
42
  "optionalDependencies": {
43
- "mime": "1.2.x",
44
- "request": ">=2.33.0",
45
- "mkdirp": "~0.3.5",
46
- "clean-css": "2.1.x",
43
+ "graceful-fs": "~3.0.2",
44
+ "mime": "~1.2.11",
45
+ "request": "~2.40.0",
46
+ "mkdirp": "~0.5.0",
47
+ "clean-css": "2.2.x",
47
48
  "source-map": "0.1.x"
48
49
  },
49
50
  "devDependencies": {
50
51
  "diff": "~1.0",
51
52
  "grunt": "~0.4.2",
52
53
  "grunt-contrib-clean": "~0.5.0",
53
- "grunt-contrib-concat": "~0.3.0",
54
- "grunt-contrib-connect": "~0.6.0",
54
+ "grunt-contrib-concat": "~0.4.0",
55
+ "grunt-contrib-connect": "~0.7.0",
55
56
  "grunt-contrib-jasmine": "~0.5.2",
56
- "grunt-contrib-jshint": "~0.8.0",
57
- "grunt-contrib-uglify": "~0.3.2",
58
- "grunt-shell": "~0.6.4",
57
+ "grunt-contrib-jshint": "~0.10.0",
58
+ "grunt-contrib-uglify": "~0.4.0",
59
+ "grunt-shell": "~0.7.0",
59
60
  "http-server": "~0.6.1",
60
61
  "matchdep": "~0.3.0",
61
- "time-grunt": "~0.2.9"
62
+ "time-grunt": "~0.3.1"
62
63
  },
63
64
  "keywords": [
64
65
  "compile less",