less 4.1.3 → 4.2.1
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.
- package/.eslintrc.js +63 -0
- package/Gruntfile.js +4 -14
- package/dist/less.js +7240 -7042
- package/dist/less.min.js +3 -3
- package/dist/less.min.js.map +1 -1
- package/lib/less/contexts.js +2 -2
- package/lib/less/contexts.js.map +1 -1
- package/lib/less/default-options.js +0 -1
- package/lib/less/default-options.js.map +1 -1
- package/lib/less/environment/abstract-file-manager.js +12 -6
- package/lib/less/environment/abstract-file-manager.js.map +1 -1
- package/lib/less/environment/abstract-plugin-loader.js +2 -2
- package/lib/less/environment/abstract-plugin-loader.js.map +1 -1
- package/lib/less/environment/environment-api.js +0 -25
- package/lib/less/environment/environment-api.js.map +1 -1
- package/lib/less/environment/environment.js +2 -2
- package/lib/less/environment/environment.js.map +1 -1
- package/lib/less/environment/file-manager-api.js +0 -103
- package/lib/less/environment/file-manager-api.js.map +1 -1
- package/lib/less/functions/color-blending.js +1 -0
- package/lib/less/functions/color-blending.js.map +1 -1
- package/lib/less/functions/color.js +20 -20
- package/lib/less/functions/color.js.map +1 -1
- package/lib/less/functions/data-uri.js +3 -3
- package/lib/less/functions/data-uri.js.map +1 -1
- package/lib/less/functions/default.js +2 -1
- package/lib/less/functions/default.js.map +1 -1
- package/lib/less/functions/function-caller.js +1 -1
- package/lib/less/functions/function-caller.js.map +1 -1
- package/lib/less/functions/function-registry.js +1 -0
- package/lib/less/functions/function-registry.js.map +1 -1
- package/lib/less/functions/index.js +4 -2
- package/lib/less/functions/index.js.map +1 -1
- package/lib/less/functions/list.js +2 -2
- package/lib/less/functions/list.js.map +1 -1
- package/lib/less/functions/math-helper.js +1 -1
- package/lib/less/functions/math-helper.js.map +1 -1
- package/lib/less/functions/math.js +2 -1
- package/lib/less/functions/math.js.map +1 -1
- package/lib/less/functions/number.js +10 -6
- package/lib/less/functions/number.js.map +1 -1
- package/lib/less/functions/style.js +28 -0
- package/lib/less/functions/style.js.map +1 -0
- package/lib/less/functions/svg.js +6 -6
- package/lib/less/functions/svg.js.map +1 -1
- package/lib/less/functions/types.js +1 -1
- package/lib/less/functions/types.js.map +1 -1
- package/lib/less/import-manager.js +2 -3
- package/lib/less/import-manager.js.map +1 -1
- package/lib/less/index.js +8 -9
- package/lib/less/index.js.map +1 -1
- package/lib/less/less-error.js +11 -12
- package/lib/less/less-error.js.map +1 -1
- package/lib/less/parse-tree.js +2 -3
- package/lib/less/parse-tree.js.map +1 -1
- package/lib/less/parse.js +1 -2
- package/lib/less/parse.js.map +1 -1
- package/lib/less/parser/chunker.js +1 -2
- package/lib/less/parser/chunker.js.map +1 -1
- package/lib/less/parser/parser-input.js +11 -5
- package/lib/less/parser/parser-input.js.map +1 -1
- package/lib/less/parser/parser.js +150 -104
- package/lib/less/parser/parser.js.map +1 -1
- package/lib/less/render.js +1 -2
- package/lib/less/render.js.map +1 -1
- package/lib/less/source-map-builder.js +2 -3
- package/lib/less/source-map-builder.js.map +1 -1
- package/lib/less/source-map-output.js +1 -1
- package/lib/less/source-map-output.js.map +1 -1
- package/lib/less/transform-tree.js +1 -2
- package/lib/less/transform-tree.js.map +1 -1
- package/lib/less/tree/assignment.js +1 -1
- package/lib/less/tree/assignment.js.map +1 -1
- package/lib/less/tree/atrule-syntax.js +10 -0
- package/lib/less/tree/atrule-syntax.js.map +1 -0
- package/lib/less/tree/atrule.js +4 -4
- package/lib/less/tree/atrule.js.map +1 -1
- package/lib/less/tree/attribute.js +2 -2
- package/lib/less/tree/attribute.js.map +1 -1
- package/lib/less/tree/call.js +3 -2
- package/lib/less/tree/call.js.map +1 -1
- package/lib/less/tree/color.js +8 -6
- package/lib/less/tree/color.js.map +1 -1
- package/lib/less/tree/comment.js +1 -1
- package/lib/less/tree/comment.js.map +1 -1
- package/lib/less/tree/container.js +48 -0
- package/lib/less/tree/container.js.map +1 -0
- package/lib/less/tree/debug-info.js +6 -6
- package/lib/less/tree/debug-info.js.map +1 -1
- package/lib/less/tree/declaration.js +1 -1
- package/lib/less/tree/declaration.js.map +1 -1
- package/lib/less/tree/dimension.js +6 -4
- package/lib/less/tree/dimension.js.map +1 -1
- package/lib/less/tree/expression.js +5 -1
- package/lib/less/tree/expression.js.map +1 -1
- package/lib/less/tree/extend.js +2 -0
- package/lib/less/tree/extend.js.map +1 -1
- package/lib/less/tree/import.js +1 -1
- package/lib/less/tree/import.js.map +1 -1
- package/lib/less/tree/index.js +4 -0
- package/lib/less/tree/index.js.map +1 -1
- package/lib/less/tree/javascript.js +1 -1
- package/lib/less/tree/javascript.js.map +1 -1
- package/lib/less/tree/js-eval-node.js +6 -6
- package/lib/less/tree/js-eval-node.js.map +1 -1
- package/lib/less/tree/media.js +4 -88
- package/lib/less/tree/media.js.map +1 -1
- package/lib/less/tree/mixin-call.js +6 -6
- package/lib/less/tree/mixin-call.js.map +1 -1
- package/lib/less/tree/mixin-definition.js +2 -2
- package/lib/less/tree/mixin-definition.js.map +1 -1
- package/lib/less/tree/namespace-value.js +6 -6
- package/lib/less/tree/namespace-value.js.map +1 -1
- package/lib/less/tree/nested-at-rule.js +91 -0
- package/lib/less/tree/nested-at-rule.js.map +1 -0
- package/lib/less/tree/node.js +6 -4
- package/lib/less/tree/node.js.map +1 -1
- package/lib/less/tree/property.js +2 -2
- package/lib/less/tree/property.js.map +1 -1
- package/lib/less/tree/query-in-parens.js +41 -0
- package/lib/less/tree/query-in-parens.js.map +1 -0
- package/lib/less/tree/quoted.js +3 -3
- package/lib/less/tree/quoted.js.map +1 -1
- package/lib/less/tree/ruleset.js +14 -11
- package/lib/less/tree/ruleset.js.map +1 -1
- package/lib/less/tree/selector.js +5 -3
- package/lib/less/tree/selector.js.map +1 -1
- package/lib/less/tree/unit.js +4 -2
- package/lib/less/tree/unit.js.map +1 -1
- package/lib/less/tree/url.js +2 -2
- package/lib/less/tree/url.js.map +1 -1
- package/lib/less/tree/variable-call.js +1 -1
- package/lib/less/tree/variable-call.js.map +1 -1
- package/lib/less/tree/variable.js +3 -3
- package/lib/less/tree/variable.js.map +1 -1
- package/lib/less/utils.js +9 -5
- package/lib/less/utils.js.map +1 -1
- package/lib/less/visitors/extend-visitor.js +8 -4
- package/lib/less/visitors/extend-visitor.js.map +1 -1
- package/lib/less/visitors/import-visitor.js +4 -0
- package/lib/less/visitors/import-visitor.js.map +1 -1
- package/lib/less/visitors/join-selector-visitor.js +4 -0
- package/lib/less/visitors/join-selector-visitor.js.map +1 -1
- package/lib/less/visitors/to-css-visitor.js +9 -5
- package/lib/less/visitors/to-css-visitor.js.map +1 -1
- package/lib/less/visitors/visitor.js +2 -2
- package/lib/less/visitors/visitor.js.map +1 -1
- package/lib/less-browser/add-default-options.js +1 -1
- package/lib/less-browser/add-default-options.js.map +1 -1
- package/lib/less-browser/bootstrap.js +6 -7
- package/lib/less-browser/bootstrap.js.map +1 -1
- package/lib/less-browser/browser.js +1 -1
- package/lib/less-browser/browser.js.map +1 -1
- package/lib/less-browser/cache.js +7 -7
- package/lib/less-browser/cache.js.map +1 -1
- package/lib/less-browser/error-reporting.js +11 -11
- package/lib/less-browser/error-reporting.js.map +1 -1
- package/lib/less-browser/file-manager.js +4 -5
- package/lib/less-browser/file-manager.js.map +1 -1
- package/lib/less-browser/index.js +17 -13
- package/lib/less-browser/index.js.map +1 -1
- package/lib/less-browser/plugin-loader.js +3 -2
- package/lib/less-browser/plugin-loader.js.map +1 -1
- package/lib/less-browser/utils.js +4 -4
- package/lib/less-browser/utils.js.map +1 -1
- package/lib/less-node/file-manager.js +17 -17
- package/lib/less-node/file-manager.js.map +1 -1
- package/lib/less-node/image-size.js +1 -1
- package/lib/less-node/image-size.js.map +1 -1
- package/lib/less-node/index.js +1 -1
- package/lib/less-node/index.js.map +1 -1
- package/lib/less-node/lessc-helper.js +2 -1
- package/lib/less-node/lessc-helper.js.map +1 -1
- package/lib/less-node/url-file-manager.js +9 -4
- package/lib/less-node/url-file-manager.js.map +1 -1
- package/package.json +140 -137
- package/test/browser/css/plugin/plugin.css +1 -1
- package/test/browser/css/relative-urls/urls.css +8 -8
- package/test/browser/css/rewrite-urls/urls.css +8 -8
- package/test/browser/css/urls.css +12 -12
- package/test/browser/generator/benchmark.config.js +19 -19
- package/test/browser/generator/generate.js +1 -1
- package/test/browser/generator/runner.config.js +76 -74
- package/test/browser/generator/template.js +17 -7
- package/test/browser/generator/utils.js +14 -0
- package/test/browser/less/relative-urls/urls.less +1 -1
- package/test/browser/less/rewrite-urls/urls.less +1 -1
- package/test/browser/less/rootpath/urls.less +1 -1
- package/test/browser/less/rootpath-relative/urls.less +1 -1
- package/test/browser/less/rootpath-rewrite-urls/urls.less +1 -1
- package/test/browser/less/urls.less +2 -2
- package/test/browser/runner-rewrite-urls-spec.js +1 -1
- package/test/index.js +2 -0
- package/test/less-test.js +33 -9
- package/test/plugins/filemanager/index.js +1 -1
- package/test/sourcemaps-variable-selector/basic.json +1 -0
- package/test/test-es6.ts +5 -5
- package/tsconfig.build.json +7 -0
- package/tsconfig.json +20 -18
- package/.eslintrc.json +0 -71
|
@@ -7,6 +7,7 @@ var visitors_1 = tslib_1.__importDefault(require("../visitors"));
|
|
|
7
7
|
var parser_input_1 = tslib_1.__importDefault(require("./parser-input"));
|
|
8
8
|
var utils = tslib_1.__importStar(require("../utils"));
|
|
9
9
|
var function_registry_1 = tslib_1.__importDefault(require("../functions/function-registry"));
|
|
10
|
+
var atrule_syntax_1 = require("../tree/atrule-syntax");
|
|
10
11
|
//
|
|
11
12
|
// less.js - parser
|
|
12
13
|
//
|
|
@@ -39,9 +40,10 @@ var function_registry_1 = tslib_1.__importDefault(require("../functions/function
|
|
|
39
40
|
// a terminal string or regexp, or a non-terminal function to call.
|
|
40
41
|
// It also takes care of moving all the indices forwards.
|
|
41
42
|
//
|
|
42
|
-
var Parser = function Parser(context, imports, fileInfo) {
|
|
43
|
+
var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
44
|
+
currentIndex = currentIndex || 0;
|
|
43
45
|
var parsers;
|
|
44
|
-
var parserInput = parser_input_1.default();
|
|
46
|
+
var parserInput = (0, parser_input_1.default)();
|
|
45
47
|
function error(msg, type) {
|
|
46
48
|
throw new less_error_1.default({
|
|
47
49
|
index: parserInput.i,
|
|
@@ -57,7 +59,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
57
59
|
return result;
|
|
58
60
|
}
|
|
59
61
|
error(msg || (typeof arg === 'string'
|
|
60
|
-
? "expected '"
|
|
62
|
+
? "expected '".concat(arg, "' got '").concat(parserInput.currentChar(), "'")
|
|
61
63
|
: 'unexpected token'));
|
|
62
64
|
}
|
|
63
65
|
// Specialization of expect()
|
|
@@ -65,7 +67,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
65
67
|
if (parserInput.$char(arg)) {
|
|
66
68
|
return arg;
|
|
67
69
|
}
|
|
68
|
-
error(msg || "expected '"
|
|
70
|
+
error(msg || "expected '".concat(arg, "' got '").concat(parserInput.currentChar(), "'"));
|
|
69
71
|
}
|
|
70
72
|
function getDebugInfo(index) {
|
|
71
73
|
var filename = fileInfo.filename;
|
|
@@ -82,7 +84,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
82
84
|
* @param {Number} currentIndex - start number to begin indexing
|
|
83
85
|
* @param {Object} fileInfo - fileInfo to attach to created nodes
|
|
84
86
|
*/
|
|
85
|
-
function parseNode(str, parseList,
|
|
87
|
+
function parseNode(str, parseList, callback) {
|
|
86
88
|
var result;
|
|
87
89
|
var returnNodes = [];
|
|
88
90
|
var parser = parserInput;
|
|
@@ -93,20 +95,9 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
93
95
|
index: index + currentIndex
|
|
94
96
|
});
|
|
95
97
|
});
|
|
96
|
-
for (var x = 0, p = void 0
|
|
97
|
-
i = parser.i;
|
|
98
|
+
for (var x = 0, p = void 0; (p = parseList[x]); x++) {
|
|
98
99
|
result = parsers[p]();
|
|
99
|
-
|
|
100
|
-
try {
|
|
101
|
-
result._index = i + currentIndex;
|
|
102
|
-
result._fileInfo = fileInfo;
|
|
103
|
-
}
|
|
104
|
-
catch (e) { }
|
|
105
|
-
returnNodes.push(result);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
returnNodes.push(null);
|
|
109
|
-
}
|
|
100
|
+
returnNodes.push(result || null);
|
|
110
101
|
}
|
|
111
102
|
var endInfo = parser.end();
|
|
112
103
|
if (endInfo.isFinished) {
|
|
@@ -153,9 +144,8 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
153
144
|
}
|
|
154
145
|
};
|
|
155
146
|
}
|
|
156
|
-
;
|
|
157
|
-
|
|
158
|
-
modifyVars = (additionalData && additionalData.modifyVars) ? "\n" + Parser.serializeVars(additionalData.modifyVars) : '';
|
|
147
|
+
globalVars = (additionalData && additionalData.globalVars) ? "".concat(Parser.serializeVars(additionalData.globalVars), "\n") : '';
|
|
148
|
+
modifyVars = (additionalData && additionalData.modifyVars) ? "\n".concat(Parser.serializeVars(additionalData.modifyVars)) : '';
|
|
159
149
|
if (context.pluginManager) {
|
|
160
150
|
var preProcessors = context.pluginManager.getPreProcessors();
|
|
161
151
|
for (var i = 0; i < preProcessors.length; i++) {
|
|
@@ -336,7 +326,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
336
326
|
comment: function () {
|
|
337
327
|
if (parserInput.commentStore.length) {
|
|
338
328
|
var comment = parserInput.commentStore.shift();
|
|
339
|
-
return new (tree_1.default.Comment)(comment.text, comment.isLineComment, comment.index, fileInfo);
|
|
329
|
+
return new (tree_1.default.Comment)(comment.text, comment.isLineComment, comment.index + currentIndex, fileInfo);
|
|
340
330
|
}
|
|
341
331
|
},
|
|
342
332
|
//
|
|
@@ -369,7 +359,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
369
359
|
return;
|
|
370
360
|
}
|
|
371
361
|
parserInput.forget();
|
|
372
|
-
return new (tree_1.default.Quoted)(str.charAt(0), str.substr(1, str.length - 2), isEscaped, index, fileInfo);
|
|
362
|
+
return new (tree_1.default.Quoted)(str.charAt(0), str.substr(1, str.length - 2), isEscaped, index + currentIndex, fileInfo);
|
|
373
363
|
},
|
|
374
364
|
//
|
|
375
365
|
// A catch-all word, such as:
|
|
@@ -399,7 +389,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
399
389
|
return;
|
|
400
390
|
}
|
|
401
391
|
parserInput.save();
|
|
402
|
-
name = parserInput.$re(/^([\w-]+|%|~|progid:[\w
|
|
392
|
+
name = parserInput.$re(/^([\w-]+|%|~|progid:[\w.]+)\(/);
|
|
403
393
|
if (!name) {
|
|
404
394
|
parserInput.forget();
|
|
405
395
|
return;
|
|
@@ -419,7 +409,33 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
419
409
|
return;
|
|
420
410
|
}
|
|
421
411
|
parserInput.forget();
|
|
422
|
-
return new (tree_1.default.Call)(name, args, index, fileInfo);
|
|
412
|
+
return new (tree_1.default.Call)(name, args, index + currentIndex, fileInfo);
|
|
413
|
+
},
|
|
414
|
+
declarationCall: function () {
|
|
415
|
+
var validCall;
|
|
416
|
+
var args;
|
|
417
|
+
var index = parserInput.i;
|
|
418
|
+
parserInput.save();
|
|
419
|
+
validCall = parserInput.$re(/^[\w]+\(/);
|
|
420
|
+
if (!validCall) {
|
|
421
|
+
parserInput.forget();
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
validCall = validCall.substring(0, validCall.length - 1);
|
|
425
|
+
var rule = this.ruleProperty();
|
|
426
|
+
var value;
|
|
427
|
+
if (rule) {
|
|
428
|
+
value = this.value();
|
|
429
|
+
}
|
|
430
|
+
if (rule && value) {
|
|
431
|
+
args = [new (tree_1.default.Declaration)(rule, value, null, null, parserInput.i + currentIndex, fileInfo, true)];
|
|
432
|
+
}
|
|
433
|
+
if (!parserInput.$char(')')) {
|
|
434
|
+
parserInput.restore('Could not parse call arguments or missing \')\'');
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
parserInput.forget();
|
|
438
|
+
return new (tree_1.default.Call)(validCall, args, index + currentIndex, fileInfo);
|
|
423
439
|
},
|
|
424
440
|
//
|
|
425
441
|
// Parsing rules for functions with non-standard args, e.g.:
|
|
@@ -441,7 +457,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
441
457
|
function f(parse, stop) {
|
|
442
458
|
return {
|
|
443
459
|
parse: parse,
|
|
444
|
-
stop: stop // when true - stop after parse() and return its result,
|
|
460
|
+
stop: stop // when true - stop after parse() and return its result,
|
|
445
461
|
// otherwise continue for plain args
|
|
446
462
|
};
|
|
447
463
|
}
|
|
@@ -532,13 +548,13 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
532
548
|
return;
|
|
533
549
|
}
|
|
534
550
|
value = this.quoted() || this.variable() || this.property() ||
|
|
535
|
-
parserInput.$re(/^(?:(?:\\[
|
|
551
|
+
parserInput.$re(/^(?:(?:\\[()'"])|[^()'"])+/) || '';
|
|
536
552
|
parserInput.autoCommentAbsorb = true;
|
|
537
553
|
expectChar(')');
|
|
538
|
-
return new (tree_1.default.URL)((value.value
|
|
554
|
+
return new (tree_1.default.URL)((value.value !== undefined ||
|
|
539
555
|
value instanceof tree_1.default.Variable ||
|
|
540
556
|
value instanceof tree_1.default.Property) ?
|
|
541
|
-
value : new (tree_1.default.Anonymous)(value, index), index, fileInfo);
|
|
557
|
+
value : new (tree_1.default.Anonymous)(value, index), index + currentIndex, fileInfo);
|
|
542
558
|
},
|
|
543
559
|
//
|
|
544
560
|
// A Variable entity, such as `@fink`, in
|
|
@@ -564,7 +580,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
564
580
|
}
|
|
565
581
|
}
|
|
566
582
|
parserInput.forget();
|
|
567
|
-
return new (tree_1.default.Variable)(name, index, fileInfo);
|
|
583
|
+
return new (tree_1.default.Variable)(name, index + currentIndex, fileInfo);
|
|
568
584
|
}
|
|
569
585
|
parserInput.restore();
|
|
570
586
|
},
|
|
@@ -573,7 +589,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
573
589
|
var curly;
|
|
574
590
|
var index = parserInput.i;
|
|
575
591
|
if (parserInput.currentChar() === '@' && (curly = parserInput.$re(/^@\{([\w-]+)\}/))) {
|
|
576
|
-
return new (tree_1.default.Variable)("@"
|
|
592
|
+
return new (tree_1.default.Variable)("@".concat(curly[1]), index + currentIndex, fileInfo);
|
|
577
593
|
}
|
|
578
594
|
},
|
|
579
595
|
//
|
|
@@ -585,7 +601,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
585
601
|
var name;
|
|
586
602
|
var index = parserInput.i;
|
|
587
603
|
if (parserInput.currentChar() === '$' && (name = parserInput.$re(/^\$[\w-]+/))) {
|
|
588
|
-
return new (tree_1.default.Property)(name, index, fileInfo);
|
|
604
|
+
return new (tree_1.default.Property)(name, index + currentIndex, fileInfo);
|
|
589
605
|
}
|
|
590
606
|
},
|
|
591
607
|
// A property entity useing the protective {} e.g. ${prop}
|
|
@@ -593,7 +609,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
593
609
|
var curly;
|
|
594
610
|
var index = parserInput.i;
|
|
595
611
|
if (parserInput.currentChar() === '$' && (curly = parserInput.$re(/^\$\{([\w-]+)\}/))) {
|
|
596
|
-
return new (tree_1.default.Property)("$"
|
|
612
|
+
return new (tree_1.default.Property)("$".concat(curly[1]), index + currentIndex, fileInfo);
|
|
597
613
|
}
|
|
598
614
|
},
|
|
599
615
|
//
|
|
@@ -606,7 +622,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
606
622
|
color: function () {
|
|
607
623
|
var rgb;
|
|
608
624
|
parserInput.save();
|
|
609
|
-
if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})([\w
|
|
625
|
+
if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})([\w.#[])?/))) {
|
|
610
626
|
if (!rgb[2]) {
|
|
611
627
|
parserInput.forget();
|
|
612
628
|
return new (tree_1.default.Color)(rgb[1], undefined, rgb[0]);
|
|
@@ -652,7 +668,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
652
668
|
//
|
|
653
669
|
unicodeDescriptor: function () {
|
|
654
670
|
var ud;
|
|
655
|
-
ud = parserInput.$re(/^U\+[0-9a-fA-F?]+(
|
|
671
|
+
ud = parserInput.$re(/^U\+[0-9a-fA-F?]+(-[0-9a-fA-F?]+)?/);
|
|
656
672
|
if (ud) {
|
|
657
673
|
return new (tree_1.default.UnicodeDescriptor)(ud[0]);
|
|
658
674
|
}
|
|
@@ -675,7 +691,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
675
691
|
js = parserInput.$re(/^[^`]*`/);
|
|
676
692
|
if (js) {
|
|
677
693
|
parserInput.forget();
|
|
678
|
-
return new (tree_1.default.JavaScript)(js.substr(0, js.length - 1), Boolean(escape), index, fileInfo);
|
|
694
|
+
return new (tree_1.default.JavaScript)(js.substr(0, js.length - 1), Boolean(escape), index + currentIndex, fileInfo);
|
|
679
695
|
}
|
|
680
696
|
parserInput.restore('invalid javascript definition');
|
|
681
697
|
}
|
|
@@ -759,7 +775,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
759
775
|
if (!elements) {
|
|
760
776
|
error('Missing target selector for :extend().');
|
|
761
777
|
}
|
|
762
|
-
extend = new (tree_1.default.Extend)(new (tree_1.default.Selector)(elements), option, index, fileInfo);
|
|
778
|
+
extend = new (tree_1.default.Extend)(new (tree_1.default.Selector)(elements), option, index + currentIndex, fileInfo);
|
|
763
779
|
if (extendList) {
|
|
764
780
|
extendList.push(extend);
|
|
765
781
|
}
|
|
@@ -835,7 +851,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
835
851
|
}
|
|
836
852
|
if (inValue || parsers.end()) {
|
|
837
853
|
parserInput.forget();
|
|
838
|
-
var mixin = new (tree_1.default.mixin.Call)(elements, args, index, fileInfo, !lookups && important);
|
|
854
|
+
var mixin = new (tree_1.default.mixin.Call)(elements, args, index + currentIndex, fileInfo, !lookups && important);
|
|
839
855
|
if (lookups) {
|
|
840
856
|
return new tree_1.default.NamespaceValue(mixin, lookups);
|
|
841
857
|
}
|
|
@@ -863,7 +879,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
863
879
|
if (!e) {
|
|
864
880
|
break;
|
|
865
881
|
}
|
|
866
|
-
elem = new (tree_1.default.Element)(c, e, false, elemIndex, fileInfo);
|
|
882
|
+
elem = new (tree_1.default.Element)(c, e, false, elemIndex + currentIndex, fileInfo);
|
|
867
883
|
if (elements) {
|
|
868
884
|
elements.push(elem);
|
|
869
885
|
}
|
|
@@ -1056,14 +1072,12 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1056
1072
|
},
|
|
1057
1073
|
ruleLookups: function () {
|
|
1058
1074
|
var rule;
|
|
1059
|
-
var args;
|
|
1060
1075
|
var lookups = [];
|
|
1061
1076
|
if (parserInput.currentChar() !== '[') {
|
|
1062
1077
|
return;
|
|
1063
1078
|
}
|
|
1064
1079
|
while (true) {
|
|
1065
1080
|
parserInput.save();
|
|
1066
|
-
args = null;
|
|
1067
1081
|
rule = this.lookupValue();
|
|
1068
1082
|
if (!rule && rule !== '') {
|
|
1069
1083
|
parserInput.restore();
|
|
@@ -1126,10 +1140,10 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1126
1140
|
value = parserInput.$re(/^\d+/);
|
|
1127
1141
|
if (!value) {
|
|
1128
1142
|
value = expect(parsers.entities.variable, 'Could not parse alpha');
|
|
1129
|
-
value = "@{"
|
|
1143
|
+
value = "@{".concat(value.name.slice(1), "}");
|
|
1130
1144
|
}
|
|
1131
1145
|
expectChar(')');
|
|
1132
|
-
return new tree_1.default.Quoted('', "alpha(opacity="
|
|
1146
|
+
return new tree_1.default.Quoted('', "alpha(opacity=".concat(value, ")"));
|
|
1133
1147
|
},
|
|
1134
1148
|
//
|
|
1135
1149
|
// A Selector Element
|
|
@@ -1150,9 +1164,10 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1150
1164
|
var index = parserInput.i;
|
|
1151
1165
|
c = this.combinator();
|
|
1152
1166
|
e = parserInput.$re(/^(?:\d+\.\d+|\d+)%/) ||
|
|
1167
|
+
// eslint-disable-next-line no-control-regex
|
|
1153
1168
|
parserInput.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||
|
|
1154
1169
|
parserInput.$char('*') || parserInput.$char('&') || this.attribute() ||
|
|
1155
|
-
parserInput.$re(/^\([^&()@]+\)/) || parserInput.$re(/^[
|
|
1170
|
+
parserInput.$re(/^\([^&()@]+\)/) || parserInput.$re(/^[.#:](?=@)/) ||
|
|
1156
1171
|
this.entities.variableCurly();
|
|
1157
1172
|
if (!e) {
|
|
1158
1173
|
parserInput.save();
|
|
@@ -1170,7 +1185,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1170
1185
|
}
|
|
1171
1186
|
}
|
|
1172
1187
|
if (e) {
|
|
1173
|
-
return new (tree_1.default.Element)(c, e, e instanceof tree_1.default.Variable, index, fileInfo);
|
|
1188
|
+
return new (tree_1.default.Element)(c, e, e instanceof tree_1.default.Variable, index + currentIndex, fileInfo);
|
|
1174
1189
|
}
|
|
1175
1190
|
},
|
|
1176
1191
|
//
|
|
@@ -1263,7 +1278,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1263
1278
|
}
|
|
1264
1279
|
}
|
|
1265
1280
|
if (elements) {
|
|
1266
|
-
return new (tree_1.default.Selector)(elements, allExtends, condition, index, fileInfo);
|
|
1281
|
+
return new (tree_1.default.Selector)(elements, allExtends, condition, index + currentIndex, fileInfo);
|
|
1267
1282
|
}
|
|
1268
1283
|
if (allExtends) {
|
|
1269
1284
|
error('Extend must be used to extend a selector, it cannot be used on its own');
|
|
@@ -1285,13 +1300,13 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1285
1300
|
}
|
|
1286
1301
|
parserInput.commentStore.length = 0;
|
|
1287
1302
|
if (s.condition && selectors.length > 1) {
|
|
1288
|
-
error(
|
|
1303
|
+
error('Guards are only currently allowed on a single selector.');
|
|
1289
1304
|
}
|
|
1290
1305
|
if (!parserInput.$char(',')) {
|
|
1291
1306
|
break;
|
|
1292
1307
|
}
|
|
1293
1308
|
if (s.condition) {
|
|
1294
|
-
error(
|
|
1309
|
+
error('Guards are only currently allowed on a single selector.');
|
|
1295
1310
|
}
|
|
1296
1311
|
parserInput.commentStore.length = 0;
|
|
1297
1312
|
}
|
|
@@ -1311,7 +1326,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1311
1326
|
//
|
|
1312
1327
|
var cif;
|
|
1313
1328
|
if (!(key = entities.variableCurly())) {
|
|
1314
|
-
key = expect(/^(?:[_A-Za-z0-9
|
|
1329
|
+
key = expect(/^(?:[_A-Za-z0-9-*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/);
|
|
1315
1330
|
}
|
|
1316
1331
|
op = parserInput.$re(/^[|~*$^]?=/);
|
|
1317
1332
|
if (op) {
|
|
@@ -1424,7 +1439,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1424
1439
|
merge = !isVariable && name.length > 1 && name.pop().value;
|
|
1425
1440
|
// Custom property values get permissive parsing
|
|
1426
1441
|
if (name[0].value && name[0].value.slice(0, 2) === '--') {
|
|
1427
|
-
value = this.permissiveValue();
|
|
1442
|
+
value = this.permissiveValue(/[;}]/);
|
|
1428
1443
|
}
|
|
1429
1444
|
// Try to store values as anonymous
|
|
1430
1445
|
// If we need the value later we'll re-parse it in ruleset.parseValue
|
|
@@ -1434,7 +1449,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1434
1449
|
if (value) {
|
|
1435
1450
|
parserInput.forget();
|
|
1436
1451
|
// anonymous values absorb the end ';' which is required for them to work
|
|
1437
|
-
return new (tree_1.default.Declaration)(name, value, false, merge, index, fileInfo);
|
|
1452
|
+
return new (tree_1.default.Declaration)(name, value, false, merge, index + currentIndex, fileInfo);
|
|
1438
1453
|
}
|
|
1439
1454
|
if (!value) {
|
|
1440
1455
|
value = this.value();
|
|
@@ -1449,7 +1464,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1449
1464
|
}
|
|
1450
1465
|
if (value && (this.end() || hasDR)) {
|
|
1451
1466
|
parserInput.forget();
|
|
1452
|
-
return new (tree_1.default.Declaration)(name, value, important, merge, index, fileInfo);
|
|
1467
|
+
return new (tree_1.default.Declaration)(name, value, important, merge, index + currentIndex, fileInfo);
|
|
1453
1468
|
}
|
|
1454
1469
|
else {
|
|
1455
1470
|
parserInput.restore();
|
|
@@ -1461,9 +1476,9 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1461
1476
|
},
|
|
1462
1477
|
anonymousValue: function () {
|
|
1463
1478
|
var index = parserInput.i;
|
|
1464
|
-
var match = parserInput.$re(/^([
|
|
1479
|
+
var match = parserInput.$re(/^([^.#@$+/'"*`(;{}-]*);/);
|
|
1465
1480
|
if (match) {
|
|
1466
|
-
return new (tree_1.default.Anonymous)(match[1], index);
|
|
1481
|
+
return new (tree_1.default.Anonymous)(match[1], index + currentIndex);
|
|
1467
1482
|
}
|
|
1468
1483
|
},
|
|
1469
1484
|
/**
|
|
@@ -1506,6 +1521,10 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1506
1521
|
if (e) {
|
|
1507
1522
|
value.push(e);
|
|
1508
1523
|
}
|
|
1524
|
+
if (parserInput.peek(',')) {
|
|
1525
|
+
value.push(new (tree_1.default.Anonymous)(',', parserInput.i));
|
|
1526
|
+
parserInput.$char(',');
|
|
1527
|
+
}
|
|
1509
1528
|
} while (e);
|
|
1510
1529
|
done = testCurrentChar();
|
|
1511
1530
|
if (value.length > 0) {
|
|
@@ -1525,7 +1544,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1525
1544
|
value = parserInput.$parseUntil(tok);
|
|
1526
1545
|
if (value) {
|
|
1527
1546
|
if (typeof value === 'string') {
|
|
1528
|
-
error("Expected '"
|
|
1547
|
+
error("Expected '".concat(value, "'"), 'Parse');
|
|
1529
1548
|
}
|
|
1530
1549
|
if (value.length === 1 && value[0] === ' ') {
|
|
1531
1550
|
parserInput.forget();
|
|
@@ -1572,13 +1591,13 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1572
1591
|
if (dir) {
|
|
1573
1592
|
var options = (dir ? this.importOptions() : null) || {};
|
|
1574
1593
|
if ((path = this.entities.quoted() || this.entities.url())) {
|
|
1575
|
-
features = this.mediaFeatures();
|
|
1594
|
+
features = this.mediaFeatures({});
|
|
1576
1595
|
if (!parserInput.$char(';')) {
|
|
1577
1596
|
parserInput.i = index;
|
|
1578
1597
|
error('missing semi-colon or unrecognised media features on import');
|
|
1579
1598
|
}
|
|
1580
1599
|
features = features && new (tree_1.default.Value)(features);
|
|
1581
|
-
return new (tree_1.default.Import)(path, features, options, index, fileInfo);
|
|
1600
|
+
return new (tree_1.default.Import)(path, features, options, index + currentIndex, fileInfo);
|
|
1582
1601
|
}
|
|
1583
1602
|
else {
|
|
1584
1603
|
parserInput.i = index;
|
|
@@ -1625,23 +1644,41 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1625
1644
|
return opt[1];
|
|
1626
1645
|
}
|
|
1627
1646
|
},
|
|
1628
|
-
mediaFeature: function () {
|
|
1647
|
+
mediaFeature: function (syntaxOptions) {
|
|
1629
1648
|
var entities = this.entities;
|
|
1630
1649
|
var nodes = [];
|
|
1631
1650
|
var e;
|
|
1632
1651
|
var p;
|
|
1652
|
+
var rangeP;
|
|
1633
1653
|
parserInput.save();
|
|
1634
1654
|
do {
|
|
1635
|
-
e = entities.keyword() || entities.variable() || entities.mixinLookup();
|
|
1655
|
+
e = entities.declarationCall.bind(this)() || entities.keyword() || entities.variable() || entities.mixinLookup();
|
|
1636
1656
|
if (e) {
|
|
1637
1657
|
nodes.push(e);
|
|
1638
1658
|
}
|
|
1639
1659
|
else if (parserInput.$char('(')) {
|
|
1640
1660
|
p = this.property();
|
|
1641
|
-
|
|
1661
|
+
parserInput.save();
|
|
1662
|
+
if (!p && syntaxOptions.queryInParens && parserInput.$re(/^[0-9a-z-]*\s*([<>]=|<=|>=|[<>]|=)/)) {
|
|
1663
|
+
parserInput.restore();
|
|
1664
|
+
p = this.condition();
|
|
1665
|
+
parserInput.save();
|
|
1666
|
+
rangeP = this.atomicCondition(null, p.rvalue);
|
|
1667
|
+
if (!rangeP) {
|
|
1668
|
+
parserInput.restore();
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
else {
|
|
1672
|
+
parserInput.restore();
|
|
1673
|
+
e = this.value();
|
|
1674
|
+
}
|
|
1642
1675
|
if (parserInput.$char(')')) {
|
|
1643
|
-
if (p && e) {
|
|
1644
|
-
nodes.push(new (tree_1.default.Paren)(new (tree_1.default.
|
|
1676
|
+
if (p && !e) {
|
|
1677
|
+
nodes.push(new (tree_1.default.Paren)(new (tree_1.default.QueryInParens)(p.op, p.lvalue, p.rvalue, rangeP ? rangeP.op : null, rangeP ? rangeP.rvalue : null, p._index)));
|
|
1678
|
+
e = p;
|
|
1679
|
+
}
|
|
1680
|
+
else if (p && e) {
|
|
1681
|
+
nodes.push(new (tree_1.default.Paren)(new (tree_1.default.Declaration)(p, e, null, null, parserInput.i + currentIndex, fileInfo, true)));
|
|
1645
1682
|
}
|
|
1646
1683
|
else if (e) {
|
|
1647
1684
|
nodes.push(new (tree_1.default.Paren)(e));
|
|
@@ -1660,12 +1697,12 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1660
1697
|
return new (tree_1.default.Expression)(nodes);
|
|
1661
1698
|
}
|
|
1662
1699
|
},
|
|
1663
|
-
mediaFeatures: function () {
|
|
1700
|
+
mediaFeatures: function (syntaxOptions) {
|
|
1664
1701
|
var entities = this.entities;
|
|
1665
1702
|
var features = [];
|
|
1666
1703
|
var e;
|
|
1667
1704
|
do {
|
|
1668
|
-
e = this.mediaFeature();
|
|
1705
|
+
e = this.mediaFeature(syntaxOptions);
|
|
1669
1706
|
if (e) {
|
|
1670
1707
|
features.push(e);
|
|
1671
1708
|
if (!parserInput.$char(',')) {
|
|
@@ -1684,28 +1721,33 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1684
1721
|
} while (e);
|
|
1685
1722
|
return features.length > 0 ? features : null;
|
|
1686
1723
|
},
|
|
1687
|
-
|
|
1688
|
-
var features;
|
|
1689
|
-
var rules;
|
|
1690
|
-
|
|
1724
|
+
prepareAndGetNestableAtRule: function (treeType, index, debugInfo, syntaxOptions) {
|
|
1725
|
+
var features = this.mediaFeatures(syntaxOptions);
|
|
1726
|
+
var rules = this.block();
|
|
1727
|
+
if (!rules) {
|
|
1728
|
+
error('media definitions require block statements after any features');
|
|
1729
|
+
}
|
|
1730
|
+
parserInput.forget();
|
|
1731
|
+
var atRule = new (treeType)(rules, features, index + currentIndex, fileInfo);
|
|
1732
|
+
if (context.dumpLineNumbers) {
|
|
1733
|
+
atRule.debugInfo = debugInfo;
|
|
1734
|
+
}
|
|
1735
|
+
return atRule;
|
|
1736
|
+
},
|
|
1737
|
+
nestableAtRule: function () {
|
|
1691
1738
|
var debugInfo;
|
|
1692
1739
|
var index = parserInput.i;
|
|
1693
1740
|
if (context.dumpLineNumbers) {
|
|
1694
1741
|
debugInfo = getDebugInfo(index);
|
|
1695
1742
|
}
|
|
1696
1743
|
parserInput.save();
|
|
1697
|
-
if (parserInput.$
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
if (!rules) {
|
|
1701
|
-
error('media definitions require block statements after any features');
|
|
1744
|
+
if (parserInput.$peekChar('@')) {
|
|
1745
|
+
if (parserInput.$str('@media')) {
|
|
1746
|
+
return this.prepareAndGetNestableAtRule(tree_1.default.Media, index, debugInfo, atrule_syntax_1.MediaSyntaxOptions);
|
|
1702
1747
|
}
|
|
1703
|
-
parserInput
|
|
1704
|
-
|
|
1705
|
-
if (context.dumpLineNumbers) {
|
|
1706
|
-
media.debugInfo = debugInfo;
|
|
1748
|
+
if (parserInput.$str('@container')) {
|
|
1749
|
+
return this.prepareAndGetNestableAtRule(tree_1.default.Container, index, debugInfo, atrule_syntax_1.ContainerSyntaxOptions);
|
|
1707
1750
|
}
|
|
1708
|
-
return media;
|
|
1709
1751
|
}
|
|
1710
1752
|
parserInput.restore();
|
|
1711
1753
|
},
|
|
@@ -1736,7 +1778,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1736
1778
|
parserInput.i = index;
|
|
1737
1779
|
error('missing semi-colon on @plugin');
|
|
1738
1780
|
}
|
|
1739
|
-
return new (tree_1.default.Import)(path, null, options, index, fileInfo);
|
|
1781
|
+
return new (tree_1.default.Import)(path, null, options, index + currentIndex, fileInfo);
|
|
1740
1782
|
}
|
|
1741
1783
|
else {
|
|
1742
1784
|
parserInput.i = index;
|
|
@@ -1751,7 +1793,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1751
1793
|
parserInput.restore();
|
|
1752
1794
|
return null;
|
|
1753
1795
|
}
|
|
1754
|
-
var args = parserInput.$re(/^\s*([
|
|
1796
|
+
var args = parserInput.$re(/^\s*([^);]+)\)\s*/);
|
|
1755
1797
|
if (args[1]) {
|
|
1756
1798
|
parserInput.forget();
|
|
1757
1799
|
return args[1].trim();
|
|
@@ -1780,7 +1822,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1780
1822
|
if (parserInput.currentChar() !== '@') {
|
|
1781
1823
|
return;
|
|
1782
1824
|
}
|
|
1783
|
-
value = this['import']() || this.plugin() || this.
|
|
1825
|
+
value = this['import']() || this.plugin() || this.nestableAtRule();
|
|
1784
1826
|
if (value) {
|
|
1785
1827
|
return value;
|
|
1786
1828
|
}
|
|
@@ -1791,7 +1833,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1791
1833
|
}
|
|
1792
1834
|
nonVendorSpecificName = name;
|
|
1793
1835
|
if (name.charAt(1) == '-' && name.indexOf('-', 2) > 0) {
|
|
1794
|
-
nonVendorSpecificName = "@"
|
|
1836
|
+
nonVendorSpecificName = "@".concat(name.slice(name.indexOf('-', 2) + 1));
|
|
1795
1837
|
}
|
|
1796
1838
|
switch (nonVendorSpecificName) {
|
|
1797
1839
|
case '@charset':
|
|
@@ -1819,13 +1861,13 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1819
1861
|
if (hasIdentifier) {
|
|
1820
1862
|
value = this.entity();
|
|
1821
1863
|
if (!value) {
|
|
1822
|
-
error("expected "
|
|
1864
|
+
error("expected ".concat(name, " identifier"));
|
|
1823
1865
|
}
|
|
1824
1866
|
}
|
|
1825
1867
|
else if (hasExpression) {
|
|
1826
1868
|
value = this.expression();
|
|
1827
1869
|
if (!value) {
|
|
1828
|
-
error("expected "
|
|
1870
|
+
error("expected ".concat(name, " expression"));
|
|
1829
1871
|
}
|
|
1830
1872
|
}
|
|
1831
1873
|
else if (hasUnknown) {
|
|
@@ -1833,7 +1875,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1833
1875
|
hasBlock = (parserInput.currentChar() === '{');
|
|
1834
1876
|
if (!value) {
|
|
1835
1877
|
if (!hasBlock && parserInput.currentChar() !== ';') {
|
|
1836
|
-
error(name
|
|
1878
|
+
error("".concat(name, " rule is missing block or ending semi-colon"));
|
|
1837
1879
|
}
|
|
1838
1880
|
}
|
|
1839
1881
|
else if (!value.value) {
|
|
@@ -1845,7 +1887,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1845
1887
|
}
|
|
1846
1888
|
if (rules || (!hasBlock && value && parserInput.$char(';'))) {
|
|
1847
1889
|
parserInput.forget();
|
|
1848
|
-
return new (tree_1.default.AtRule)(name, value, rules, index, fileInfo, context.dumpLineNumbers ? getDebugInfo(index) : null, isRooted);
|
|
1890
|
+
return new (tree_1.default.AtRule)(name, value, rules, index + currentIndex, fileInfo, context.dumpLineNumbers ? getDebugInfo(index) : null, isRooted);
|
|
1849
1891
|
}
|
|
1850
1892
|
parserInput.restore('at-rule options not recognised');
|
|
1851
1893
|
},
|
|
@@ -1871,7 +1913,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1871
1913
|
}
|
|
1872
1914
|
} while (e);
|
|
1873
1915
|
if (expressions.length > 0) {
|
|
1874
|
-
return new (tree_1.default.Value)(expressions, index);
|
|
1916
|
+
return new (tree_1.default.Value)(expressions, index + currentIndex);
|
|
1875
1917
|
}
|
|
1876
1918
|
},
|
|
1877
1919
|
important: function () {
|
|
@@ -1906,7 +1948,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1906
1948
|
if (m) {
|
|
1907
1949
|
isSpaced = parserInput.isWhitespace(-1);
|
|
1908
1950
|
while (true) {
|
|
1909
|
-
if (parserInput.peek(/^\/[
|
|
1951
|
+
if (parserInput.peek(/^\/[*/]/)) {
|
|
1910
1952
|
break;
|
|
1911
1953
|
}
|
|
1912
1954
|
parserInput.save();
|
|
@@ -1970,7 +2012,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1970
2012
|
if (!b) {
|
|
1971
2013
|
break;
|
|
1972
2014
|
}
|
|
1973
|
-
condition = new (tree_1.default.Condition)('or', condition || a, b, index);
|
|
2015
|
+
condition = new (tree_1.default.Condition)('or', condition || a, b, index + currentIndex);
|
|
1974
2016
|
}
|
|
1975
2017
|
return condition || a;
|
|
1976
2018
|
}
|
|
@@ -2071,24 +2113,28 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
2071
2113
|
return;
|
|
2072
2114
|
}
|
|
2073
2115
|
if (!parserInput.$char(')')) {
|
|
2074
|
-
parserInput.restore("expected ')' got '"
|
|
2116
|
+
parserInput.restore("expected ')' got '".concat(parserInput.currentChar(), "'"));
|
|
2075
2117
|
return;
|
|
2076
2118
|
}
|
|
2077
2119
|
parserInput.forget();
|
|
2078
2120
|
return body;
|
|
2079
2121
|
},
|
|
2080
|
-
atomicCondition: function (needsParens) {
|
|
2122
|
+
atomicCondition: function (needsParens, preparsedCond) {
|
|
2081
2123
|
var entities = this.entities;
|
|
2082
2124
|
var index = parserInput.i;
|
|
2083
2125
|
var a;
|
|
2084
2126
|
var b;
|
|
2085
2127
|
var c;
|
|
2086
2128
|
var op;
|
|
2087
|
-
|
|
2129
|
+
var cond = (function () {
|
|
2088
2130
|
return this.addition() || entities.keyword() || entities.quoted() || entities.mixinLookup();
|
|
2131
|
+
}).bind(this);
|
|
2132
|
+
if (preparsedCond) {
|
|
2133
|
+
a = preparsedCond;
|
|
2134
|
+
}
|
|
2135
|
+
else {
|
|
2136
|
+
a = cond();
|
|
2089
2137
|
}
|
|
2090
|
-
cond = cond.bind(this);
|
|
2091
|
-
a = cond();
|
|
2092
2138
|
if (a) {
|
|
2093
2139
|
if (parserInput.$char('>')) {
|
|
2094
2140
|
if (parserInput.$char('=')) {
|
|
@@ -2120,14 +2166,14 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
2120
2166
|
if (op) {
|
|
2121
2167
|
b = cond();
|
|
2122
2168
|
if (b) {
|
|
2123
|
-
c = new (tree_1.default.Condition)(op, a, b, index, false);
|
|
2169
|
+
c = new (tree_1.default.Condition)(op, a, b, index + currentIndex, false);
|
|
2124
2170
|
}
|
|
2125
2171
|
else {
|
|
2126
2172
|
error('expected expression');
|
|
2127
2173
|
}
|
|
2128
2174
|
}
|
|
2129
|
-
else {
|
|
2130
|
-
c = new (tree_1.default.Condition)('=', a, new (tree_1.default.Keyword)('true'), index, false);
|
|
2175
|
+
else if (!preparsedCond) {
|
|
2176
|
+
c = new (tree_1.default.Condition)('=', a, new (tree_1.default.Keyword)('true'), index + currentIndex, false);
|
|
2131
2177
|
}
|
|
2132
2178
|
return c;
|
|
2133
2179
|
}
|
|
@@ -2139,7 +2185,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
2139
2185
|
operand: function () {
|
|
2140
2186
|
var entities = this.entities;
|
|
2141
2187
|
var negate;
|
|
2142
|
-
if (parserInput.peek(/^-[
|
|
2188
|
+
if (parserInput.peek(/^-[@$(]/)) {
|
|
2143
2189
|
negate = parserInput.$char('-');
|
|
2144
2190
|
}
|
|
2145
2191
|
var o = this.sub() || entities.dimension() ||
|
|
@@ -2178,10 +2224,10 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
2178
2224
|
if (e) {
|
|
2179
2225
|
entities.push(e);
|
|
2180
2226
|
// operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here
|
|
2181
|
-
if (!parserInput.peek(/^\/[
|
|
2227
|
+
if (!parserInput.peek(/^\/[/*]/)) {
|
|
2182
2228
|
delim = parserInput.$char('/');
|
|
2183
2229
|
if (delim) {
|
|
2184
|
-
entities.push(new (tree_1.default.Anonymous)(delim, index));
|
|
2230
|
+
entities.push(new (tree_1.default.Anonymous)(delim, index + currentIndex));
|
|
2185
2231
|
}
|
|
2186
2232
|
}
|
|
2187
2233
|
}
|
|
@@ -2218,7 +2264,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
2218
2264
|
}
|
|
2219
2265
|
match(/^(\*?)/);
|
|
2220
2266
|
while (true) {
|
|
2221
|
-
if (!match(/^((?:[\w-]+)|(?:[
|
|
2267
|
+
if (!match(/^((?:[\w-]+)|(?:[@$]\{[\w-]+\}))/)) {
|
|
2222
2268
|
break;
|
|
2223
2269
|
}
|
|
2224
2270
|
}
|
|
@@ -2235,8 +2281,8 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
2235
2281
|
name[k] = (s.charAt(0) !== '@' && s.charAt(0) !== '$') ?
|
|
2236
2282
|
new (tree_1.default.Keyword)(s) :
|
|
2237
2283
|
(s.charAt(0) === '@' ?
|
|
2238
|
-
new (tree_1.default.Variable)("@"
|
|
2239
|
-
new (tree_1.default.Property)("$"
|
|
2284
|
+
new (tree_1.default.Variable)("@".concat(s.slice(2, -1)), index[k] + currentIndex, fileInfo) :
|
|
2285
|
+
new (tree_1.default.Property)("$".concat(s.slice(2, -1)), index[k] + currentIndex, fileInfo));
|
|
2240
2286
|
}
|
|
2241
2287
|
return name;
|
|
2242
2288
|
}
|
|
@@ -2250,7 +2296,7 @@ Parser.serializeVars = function (vars) {
|
|
|
2250
2296
|
for (var name_1 in vars) {
|
|
2251
2297
|
if (Object.hasOwnProperty.call(vars, name_1)) {
|
|
2252
2298
|
var value = vars[name_1];
|
|
2253
|
-
s += ((name_1[0] === '@') ? '' : '@') + name_1
|
|
2299
|
+
s += "".concat(((name_1[0] === '@') ? '' : '@') + name_1, ": ").concat(value).concat((String(value).slice(-1) === ';') ? '' : ';');
|
|
2254
2300
|
}
|
|
2255
2301
|
}
|
|
2256
2302
|
return s;
|