less 4.2.2 → 4.3.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.
- package/Gruntfile.js +0 -2
- package/LICENSE +177 -0
- package/bin/lessc +30 -23
- package/dist/less.js +557 -381
- package/dist/less.min.js +2 -2
- package/dist/less.min.js.map +1 -1
- package/lib/less/contexts.js +2 -1
- package/lib/less/contexts.js.map +1 -1
- package/lib/less/less-error.js +12 -8
- package/lib/less/less-error.js.map +1 -1
- package/lib/less/parser/parser.js +80 -19
- package/lib/less/parser/parser.js.map +1 -1
- package/lib/less/tree/atrule.js +121 -33
- package/lib/less/tree/atrule.js.map +1 -1
- package/lib/less/tree/extend.js +1 -0
- package/lib/less/tree/extend.js.map +1 -1
- package/lib/less/tree/quoted.js +4 -4
- package/lib/less/tree/quoted.js.map +1 -1
- package/lib/less/visitors/extend-visitor.js +6 -1
- package/lib/less/visitors/extend-visitor.js.map +1 -1
- package/lib/less/visitors/import-visitor.js +14 -1
- package/lib/less/visitors/import-visitor.js.map +1 -1
- package/lib/less/visitors/join-selector-visitor.js +4 -1
- package/lib/less/visitors/join-selector-visitor.js.map +1 -1
- package/lib/less-node/lessc-helper.js +1 -0
- package/lib/less-node/lessc-helper.js.map +1 -1
- package/package.json +138 -140
- package/test/less-test.js +3 -1
package/dist/less.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Less - Leaner CSS v4.
|
|
2
|
+
* Less - Leaner CSS v4.3.0
|
|
3
3
|
* http://lesscss.org
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2009-2025, Alexis Sellier <self@cloudhead.net>
|
|
@@ -856,6 +856,47 @@
|
|
|
856
856
|
}).join(''));
|
|
857
857
|
}
|
|
858
858
|
|
|
859
|
+
/******************************************************************************
|
|
860
|
+
Copyright (c) Microsoft Corporation.
|
|
861
|
+
|
|
862
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
863
|
+
purpose with or without fee is hereby granted.
|
|
864
|
+
|
|
865
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
866
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
867
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
868
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
869
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
870
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
871
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
872
|
+
***************************************************************************** */
|
|
873
|
+
|
|
874
|
+
var __assign = function() {
|
|
875
|
+
__assign = Object.assign || function __assign(t) {
|
|
876
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
877
|
+
s = arguments[i];
|
|
878
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
879
|
+
}
|
|
880
|
+
return t;
|
|
881
|
+
};
|
|
882
|
+
return __assign.apply(this, arguments);
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
function __spreadArray(to, from, pack) {
|
|
886
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
887
|
+
if (ar || !(i in from)) {
|
|
888
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
889
|
+
ar[i] = from[i];
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
896
|
+
var e = new Error(message);
|
|
897
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
898
|
+
};
|
|
899
|
+
|
|
859
900
|
var Paren = function (node) {
|
|
860
901
|
this.value = node;
|
|
861
902
|
};
|
|
@@ -962,47 +1003,6 @@
|
|
|
962
1003
|
ALL: 2
|
|
963
1004
|
};
|
|
964
1005
|
|
|
965
|
-
/******************************************************************************
|
|
966
|
-
Copyright (c) Microsoft Corporation.
|
|
967
|
-
|
|
968
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
969
|
-
purpose with or without fee is hereby granted.
|
|
970
|
-
|
|
971
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
972
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
973
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
974
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
975
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
976
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
977
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
978
|
-
***************************************************************************** */
|
|
979
|
-
|
|
980
|
-
var __assign = function() {
|
|
981
|
-
__assign = Object.assign || function __assign(t) {
|
|
982
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
983
|
-
s = arguments[i];
|
|
984
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
985
|
-
}
|
|
986
|
-
return t;
|
|
987
|
-
};
|
|
988
|
-
return __assign.apply(this, arguments);
|
|
989
|
-
};
|
|
990
|
-
|
|
991
|
-
function __spreadArray(to, from, pack) {
|
|
992
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
993
|
-
if (ar || !(i in from)) {
|
|
994
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
995
|
-
ar[i] = from[i];
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1002
|
-
var e = new Error(message);
|
|
1003
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1004
|
-
};
|
|
1005
|
-
|
|
1006
1006
|
/**
|
|
1007
1007
|
* Returns the object type of the given payload
|
|
1008
1008
|
*
|
|
@@ -1034,7 +1034,7 @@
|
|
|
1034
1034
|
}
|
|
1035
1035
|
|
|
1036
1036
|
function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
|
|
1037
|
-
|
|
1037
|
+
const propType = {}.propertyIsEnumerable.call(originalObject, key)
|
|
1038
1038
|
? 'enumerable'
|
|
1039
1039
|
: 'nonenumerable';
|
|
1040
1040
|
if (propType === 'enumerable')
|
|
@@ -1058,22 +1058,21 @@
|
|
|
1058
1058
|
* @returns {T} the target with replaced values
|
|
1059
1059
|
* @export
|
|
1060
1060
|
*/
|
|
1061
|
-
function copy(target, options) {
|
|
1062
|
-
if (options === void 0) { options = {}; }
|
|
1061
|
+
function copy(target, options = {}) {
|
|
1063
1062
|
if (isArray(target)) {
|
|
1064
|
-
return target.map(
|
|
1063
|
+
return target.map((item) => copy(item, options));
|
|
1065
1064
|
}
|
|
1066
1065
|
if (!isPlainObject(target)) {
|
|
1067
1066
|
return target;
|
|
1068
1067
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
return
|
|
1068
|
+
const props = Object.getOwnPropertyNames(target);
|
|
1069
|
+
const symbols = Object.getOwnPropertySymbols(target);
|
|
1070
|
+
return [...props, ...symbols].reduce((carry, key) => {
|
|
1072
1071
|
if (isArray(options.props) && !options.props.includes(key)) {
|
|
1073
1072
|
return carry;
|
|
1074
1073
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1074
|
+
const val = target[key];
|
|
1075
|
+
const newVal = copy(val, options);
|
|
1077
1076
|
assignProp(carry, key, newVal, target, options.nonenumerable);
|
|
1078
1077
|
return carry;
|
|
1079
1078
|
}, {});
|
|
@@ -1299,20 +1298,24 @@
|
|
|
1299
1298
|
* @returns {string}
|
|
1300
1299
|
*/
|
|
1301
1300
|
LessError.prototype.toString = function (options) {
|
|
1301
|
+
var _a;
|
|
1302
1302
|
options = options || {};
|
|
1303
|
+
var isWarning = ((_a = this.type) !== null && _a !== void 0 ? _a : '').toLowerCase().includes('warning');
|
|
1304
|
+
var type = isWarning ? this.type : "".concat(this.type, "Error");
|
|
1305
|
+
var color = isWarning ? 'yellow' : 'red';
|
|
1303
1306
|
var message = '';
|
|
1304
1307
|
var extract = this.extract || [];
|
|
1305
1308
|
var error = [];
|
|
1306
1309
|
var stylize = function (str) { return str; };
|
|
1307
1310
|
if (options.stylize) {
|
|
1308
|
-
var
|
|
1309
|
-
if (
|
|
1310
|
-
throw Error("options.stylize should be a function, got a ".concat(
|
|
1311
|
+
var type_1 = typeof options.stylize;
|
|
1312
|
+
if (type_1 !== 'function') {
|
|
1313
|
+
throw Error("options.stylize should be a function, got a ".concat(type_1, "!"));
|
|
1311
1314
|
}
|
|
1312
1315
|
stylize = options.stylize;
|
|
1313
1316
|
}
|
|
1314
1317
|
if (this.line !== null) {
|
|
1315
|
-
if (typeof extract[0] === 'string') {
|
|
1318
|
+
if (!isWarning && typeof extract[0] === 'string') {
|
|
1316
1319
|
error.push(stylize("".concat(this.line - 1, " ").concat(extract[0]), 'grey'));
|
|
1317
1320
|
}
|
|
1318
1321
|
if (typeof extract[1] === 'string') {
|
|
@@ -1324,21 +1327,21 @@
|
|
|
1324
1327
|
}
|
|
1325
1328
|
error.push(errorTxt);
|
|
1326
1329
|
}
|
|
1327
|
-
if (typeof extract[2] === 'string') {
|
|
1330
|
+
if (!isWarning && typeof extract[2] === 'string') {
|
|
1328
1331
|
error.push(stylize("".concat(this.line + 1, " ").concat(extract[2]), 'grey'));
|
|
1329
1332
|
}
|
|
1330
1333
|
error = "".concat(error.join('\n') + stylize('', 'reset'), "\n");
|
|
1331
1334
|
}
|
|
1332
|
-
message += stylize("".concat(
|
|
1335
|
+
message += stylize("".concat(type, ": ").concat(this.message), color);
|
|
1333
1336
|
if (this.filename) {
|
|
1334
|
-
message += stylize(' in ',
|
|
1337
|
+
message += stylize(' in ', color) + this.filename;
|
|
1335
1338
|
}
|
|
1336
1339
|
if (this.line) {
|
|
1337
1340
|
message += stylize(" on line ".concat(this.line, ", column ").concat(this.column + 1, ":"), 'grey');
|
|
1338
1341
|
}
|
|
1339
1342
|
message += "\n".concat(error);
|
|
1340
1343
|
if (this.callLine) {
|
|
1341
|
-
message += "".concat(stylize('from ',
|
|
1344
|
+
message += "".concat(stylize('from ', color) + (this.filename || ''), "/n");
|
|
1342
1345
|
message += "".concat(stylize(this.callLine, 'grey'), " ").concat(this.callExtract, "/n");
|
|
1343
1346
|
}
|
|
1344
1347
|
return message;
|
|
@@ -1519,7 +1522,8 @@
|
|
|
1519
1522
|
// context
|
|
1520
1523
|
'processImports',
|
|
1521
1524
|
// Used by the import manager to stop multiple import visitors being created.
|
|
1522
|
-
'pluginManager'
|
|
1525
|
+
'pluginManager',
|
|
1526
|
+
'quiet', // option - whether to log warnings
|
|
1523
1527
|
];
|
|
1524
1528
|
contexts.Parse = function (options) {
|
|
1525
1529
|
copyFromOriginal(options, this, parseCopyProperties);
|
|
@@ -1830,7 +1834,20 @@
|
|
|
1830
1834
|
}
|
|
1831
1835
|
},
|
|
1832
1836
|
visitAtRule: function (atRuleNode, visitArgs) {
|
|
1833
|
-
|
|
1837
|
+
if (atRuleNode.value) {
|
|
1838
|
+
this.context.frames.unshift(atRuleNode);
|
|
1839
|
+
}
|
|
1840
|
+
else if (atRuleNode.declarations && atRuleNode.declarations.length) {
|
|
1841
|
+
if (atRuleNode.isRooted) {
|
|
1842
|
+
this.context.frames.unshift(atRuleNode);
|
|
1843
|
+
}
|
|
1844
|
+
else {
|
|
1845
|
+
this.context.frames.unshift(atRuleNode.declarations[0]);
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
else if (atRuleNode.rules && atRuleNode.rules.length) {
|
|
1849
|
+
this.context.frames.unshift(atRuleNode);
|
|
1850
|
+
}
|
|
1834
1851
|
},
|
|
1835
1852
|
visitAtRuleOut: function (atRuleNode) {
|
|
1836
1853
|
this.context.frames.shift();
|
|
@@ -2006,7 +2023,12 @@
|
|
|
2006
2023
|
catch (_) { }
|
|
2007
2024
|
if (!indices["".concat(extend.index, " ").concat(selector)]) {
|
|
2008
2025
|
indices["".concat(extend.index, " ").concat(selector)] = true;
|
|
2009
|
-
|
|
2026
|
+
/**
|
|
2027
|
+
* @todo Shouldn't this be an error? To alert the developer
|
|
2028
|
+
* that they may have made an error in the selector they are
|
|
2029
|
+
* targeting?
|
|
2030
|
+
*/
|
|
2031
|
+
logger$1.warn("WARNING: extend '".concat(selector, "' has no matches"));
|
|
2010
2032
|
}
|
|
2011
2033
|
});
|
|
2012
2034
|
};
|
|
@@ -2367,7 +2389,10 @@
|
|
|
2367
2389
|
};
|
|
2368
2390
|
JoinSelectorVisitor.prototype.visitAtRule = function (atRuleNode, visitArgs) {
|
|
2369
2391
|
var context = this.contexts[this.contexts.length - 1];
|
|
2370
|
-
if (atRuleNode.
|
|
2392
|
+
if (atRuleNode.declarations && atRuleNode.declarations.length) {
|
|
2393
|
+
atRuleNode.declarations[0].root = (context.length === 0 || context[0].multiMedia);
|
|
2394
|
+
}
|
|
2395
|
+
else if (atRuleNode.rules && atRuleNode.rules.length) {
|
|
2371
2396
|
atRuleNode.rules[0].root = (atRuleNode.isRooted || context.length === 0 || null);
|
|
2372
2397
|
}
|
|
2373
2398
|
};
|
|
@@ -3310,6 +3335,22 @@
|
|
|
3310
3335
|
message: msg
|
|
3311
3336
|
}, imports);
|
|
3312
3337
|
}
|
|
3338
|
+
/**
|
|
3339
|
+
*
|
|
3340
|
+
* @param {string} msg
|
|
3341
|
+
* @param {number} index
|
|
3342
|
+
* @param {string} type
|
|
3343
|
+
*/
|
|
3344
|
+
function warn(msg, index, type) {
|
|
3345
|
+
if (!context.quiet) {
|
|
3346
|
+
logger$1.warn((new LessError({
|
|
3347
|
+
index: index !== null && index !== void 0 ? index : parserInput.i,
|
|
3348
|
+
filename: fileInfo.filename,
|
|
3349
|
+
type: type ? "".concat(type.toUpperCase(), " WARNING") : 'WARNING',
|
|
3350
|
+
message: msg
|
|
3351
|
+
}, imports)).toString());
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3313
3354
|
function expect(arg, msg) {
|
|
3314
3355
|
// some older browsers return typeof 'function' for RegExp
|
|
3315
3356
|
var result = (arg instanceof Function) ? arg.call(parsers) : parserInput.$re(arg);
|
|
@@ -4017,11 +4058,20 @@
|
|
|
4017
4058
|
do {
|
|
4018
4059
|
option = null;
|
|
4019
4060
|
elements = null;
|
|
4020
|
-
|
|
4061
|
+
var first = true;
|
|
4062
|
+
while (!(option = parserInput.$re(/^(!?all)(?=\s*(\)|,))/))) {
|
|
4021
4063
|
e = this.element();
|
|
4022
4064
|
if (!e) {
|
|
4023
4065
|
break;
|
|
4024
4066
|
}
|
|
4067
|
+
/**
|
|
4068
|
+
* @note - This will not catch selectors in pseudos like :is() and :where() because
|
|
4069
|
+
* they don't currently parse their contents as selectors.
|
|
4070
|
+
*/
|
|
4071
|
+
if (!first && e.combinator.value) {
|
|
4072
|
+
warn('Targeting complex selectors can have unexpected behavior, and this behavior may change in the future.', index);
|
|
4073
|
+
}
|
|
4074
|
+
first = false;
|
|
4025
4075
|
if (elements) {
|
|
4026
4076
|
elements.push(e);
|
|
4027
4077
|
}
|
|
@@ -4081,16 +4131,23 @@
|
|
|
4081
4131
|
var elements;
|
|
4082
4132
|
var args;
|
|
4083
4133
|
var hasParens;
|
|
4134
|
+
var parensIndex;
|
|
4135
|
+
var parensWS = false;
|
|
4084
4136
|
if (s !== '.' && s !== '#') {
|
|
4085
4137
|
return;
|
|
4086
4138
|
}
|
|
4087
4139
|
parserInput.save(); // stop us absorbing part of an invalid selector
|
|
4088
4140
|
elements = this.elements();
|
|
4089
4141
|
if (elements) {
|
|
4142
|
+
parensIndex = parserInput.i;
|
|
4090
4143
|
if (parserInput.$char('(')) {
|
|
4144
|
+
parensWS = parserInput.isWhitespace(-2);
|
|
4091
4145
|
args = this.args(true).args;
|
|
4092
4146
|
expectChar(')');
|
|
4093
4147
|
hasParens = true;
|
|
4148
|
+
if (parensWS) {
|
|
4149
|
+
warn('Whitespace between a mixin name and parentheses for a mixin call is deprecated', parensIndex, 'DEPRECATED');
|
|
4150
|
+
}
|
|
4094
4151
|
}
|
|
4095
4152
|
if (getLookup !== false) {
|
|
4096
4153
|
lookups = this.ruleLookups();
|
|
@@ -4114,6 +4171,9 @@
|
|
|
4114
4171
|
return new tree.NamespaceValue(mixin, lookups);
|
|
4115
4172
|
}
|
|
4116
4173
|
else {
|
|
4174
|
+
if (!hasParens) {
|
|
4175
|
+
warn('Calling a mixin without parentheses is deprecated', parensIndex, 'DEPRECATED');
|
|
4176
|
+
}
|
|
4117
4177
|
return mixin;
|
|
4118
4178
|
}
|
|
4119
4179
|
}
|
|
@@ -4403,24 +4463,25 @@
|
|
|
4403
4463
|
expectChar(')');
|
|
4404
4464
|
return new tree.Quoted('', "alpha(opacity=".concat(value, ")"));
|
|
4405
4465
|
},
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4466
|
+
/**
|
|
4467
|
+
* A Selector Element
|
|
4468
|
+
*
|
|
4469
|
+
* div
|
|
4470
|
+
* + h1
|
|
4471
|
+
* #socks
|
|
4472
|
+
* input[type="text"]
|
|
4473
|
+
*
|
|
4474
|
+
* Elements are the building blocks for Selectors,
|
|
4475
|
+
* they are made out of a `Combinator` (see combinator rule),
|
|
4476
|
+
* and an element name, such as a tag a class, or `*`.
|
|
4477
|
+
*/
|
|
4418
4478
|
element: function () {
|
|
4419
4479
|
var e;
|
|
4420
4480
|
var c;
|
|
4421
4481
|
var v;
|
|
4422
4482
|
var index = parserInput.i;
|
|
4423
4483
|
c = this.combinator();
|
|
4484
|
+
/** This selector parser is quite simplistic and will pass a number of invalid selectors. */
|
|
4424
4485
|
e = parserInput.$re(/^(?:\d+\.\d+|\d+)%/) ||
|
|
4425
4486
|
// eslint-disable-next-line no-control-regex
|
|
4426
4487
|
parserInput.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||
|
|
@@ -4721,7 +4782,7 @@
|
|
|
4721
4782
|
value = new Anonymous('');
|
|
4722
4783
|
}
|
|
4723
4784
|
else {
|
|
4724
|
-
value = this.permissiveValue(/[;}]
|
|
4785
|
+
value = this.permissiveValue(/[;}]/, true);
|
|
4725
4786
|
}
|
|
4726
4787
|
}
|
|
4727
4788
|
// Try to store values as anonymous
|
|
@@ -4741,7 +4802,12 @@
|
|
|
4741
4802
|
important = this.important();
|
|
4742
4803
|
}
|
|
4743
4804
|
else if (isVariable) {
|
|
4744
|
-
|
|
4805
|
+
/**
|
|
4806
|
+
* As a last resort, try permissiveValue
|
|
4807
|
+
*
|
|
4808
|
+
* @todo - This has created some knock-on problems of not
|
|
4809
|
+
* flagging incorrect syntax or detecting user intent.
|
|
4810
|
+
*/
|
|
4745
4811
|
value = this.permissiveValue();
|
|
4746
4812
|
}
|
|
4747
4813
|
}
|
|
@@ -4772,6 +4838,8 @@
|
|
|
4772
4838
|
* First, it will try to parse comments and entities to reach
|
|
4773
4839
|
* the end. This is mostly like the Expression parser except no
|
|
4774
4840
|
* math is allowed.
|
|
4841
|
+
*
|
|
4842
|
+
* @param {RexExp} untilTokens - Characters to stop parsing at
|
|
4775
4843
|
*/
|
|
4776
4844
|
permissiveValue: function (untilTokens) {
|
|
4777
4845
|
var i;
|
|
@@ -4833,6 +4901,7 @@
|
|
|
4833
4901
|
parserInput.forget();
|
|
4834
4902
|
return new tree.Anonymous('', index);
|
|
4835
4903
|
}
|
|
4904
|
+
/** @type {string} */
|
|
4836
4905
|
var item = void 0;
|
|
4837
4906
|
for (i = 0; i < value.length; i++) {
|
|
4838
4907
|
item = value[i];
|
|
@@ -4846,10 +4915,16 @@
|
|
|
4846
4915
|
}
|
|
4847
4916
|
// Treat like quoted values, but replace vars like unquoted expressions
|
|
4848
4917
|
var quote = new tree.Quoted('\'', item, true, index, fileInfo);
|
|
4849
|
-
|
|
4850
|
-
|
|
4918
|
+
var variableRegex = /@([\w-]+)/g;
|
|
4919
|
+
var propRegex = /\$([\w-]+)/g;
|
|
4920
|
+
if (variableRegex.test(item)) {
|
|
4921
|
+
warn('@[ident] in unknown values will not be evaluated as variables in the future. Use @{[ident]}', index, 'DEPRECATED');
|
|
4851
4922
|
}
|
|
4852
|
-
|
|
4923
|
+
if (propRegex.test(item)) {
|
|
4924
|
+
warn('$[ident] in unknown values will not be evaluated as property references in the future. Use ${[ident]}', index, 'DEPRECATED');
|
|
4925
|
+
}
|
|
4926
|
+
quote.variableRegex = /@([\w-]+)|@{([\w-]+)}/g;
|
|
4927
|
+
quote.propRegex = /\$([\w-]+)|\${([\w-]+)}/g;
|
|
4853
4928
|
result.push(quote);
|
|
4854
4929
|
}
|
|
4855
4930
|
}
|
|
@@ -5138,6 +5213,9 @@
|
|
|
5138
5213
|
hasUnknown = true;
|
|
5139
5214
|
isRooted = false;
|
|
5140
5215
|
break;
|
|
5216
|
+
case '@starting-style':
|
|
5217
|
+
isRooted = false;
|
|
5218
|
+
break;
|
|
5141
5219
|
default:
|
|
5142
5220
|
hasUnknown = true;
|
|
5143
5221
|
break;
|
|
@@ -5237,7 +5315,14 @@
|
|
|
5237
5315
|
break;
|
|
5238
5316
|
}
|
|
5239
5317
|
parserInput.save();
|
|
5240
|
-
op = parserInput.$char('/') || parserInput.$char('*')
|
|
5318
|
+
op = parserInput.$char('/') || parserInput.$char('*');
|
|
5319
|
+
if (!op) {
|
|
5320
|
+
var index = parserInput.i;
|
|
5321
|
+
op = parserInput.$str('./');
|
|
5322
|
+
if (op) {
|
|
5323
|
+
warn('./ operator is deprecated', index, 'DEPRECATED');
|
|
5324
|
+
}
|
|
5325
|
+
}
|
|
5241
5326
|
if (!op) {
|
|
5242
5327
|
parserInput.forget();
|
|
5243
5328
|
break;
|
|
@@ -6654,153 +6739,6 @@
|
|
|
6654
6739
|
}
|
|
6655
6740
|
});
|
|
6656
6741
|
|
|
6657
|
-
var AtRule = function (name, value, rules, index, currentFileInfo, debugInfo, isRooted, visibilityInfo) {
|
|
6658
|
-
var i;
|
|
6659
|
-
this.name = name;
|
|
6660
|
-
this.value = (value instanceof Node) ? value : (value ? new Anonymous(value) : value);
|
|
6661
|
-
if (rules) {
|
|
6662
|
-
if (Array.isArray(rules)) {
|
|
6663
|
-
this.rules = rules;
|
|
6664
|
-
}
|
|
6665
|
-
else {
|
|
6666
|
-
this.rules = [rules];
|
|
6667
|
-
this.rules[0].selectors = (new Selector([], null, null, index, currentFileInfo)).createEmptySelectors();
|
|
6668
|
-
}
|
|
6669
|
-
for (i = 0; i < this.rules.length; i++) {
|
|
6670
|
-
this.rules[i].allowImports = true;
|
|
6671
|
-
}
|
|
6672
|
-
this.setParent(this.rules, this);
|
|
6673
|
-
}
|
|
6674
|
-
this._index = index;
|
|
6675
|
-
this._fileInfo = currentFileInfo;
|
|
6676
|
-
this.debugInfo = debugInfo;
|
|
6677
|
-
this.isRooted = isRooted || false;
|
|
6678
|
-
this.copyVisibilityInfo(visibilityInfo);
|
|
6679
|
-
this.allowRoot = true;
|
|
6680
|
-
};
|
|
6681
|
-
AtRule.prototype = Object.assign(new Node(), {
|
|
6682
|
-
type: 'AtRule',
|
|
6683
|
-
accept: function (visitor) {
|
|
6684
|
-
var value = this.value, rules = this.rules;
|
|
6685
|
-
if (rules) {
|
|
6686
|
-
this.rules = visitor.visitArray(rules);
|
|
6687
|
-
}
|
|
6688
|
-
if (value) {
|
|
6689
|
-
this.value = visitor.visit(value);
|
|
6690
|
-
}
|
|
6691
|
-
},
|
|
6692
|
-
isRulesetLike: function () {
|
|
6693
|
-
return this.rules || !this.isCharset();
|
|
6694
|
-
},
|
|
6695
|
-
isCharset: function () {
|
|
6696
|
-
return '@charset' === this.name;
|
|
6697
|
-
},
|
|
6698
|
-
genCSS: function (context, output) {
|
|
6699
|
-
var value = this.value, rules = this.rules;
|
|
6700
|
-
output.add(this.name, this.fileInfo(), this.getIndex());
|
|
6701
|
-
if (value) {
|
|
6702
|
-
output.add(' ');
|
|
6703
|
-
value.genCSS(context, output);
|
|
6704
|
-
}
|
|
6705
|
-
if (rules) {
|
|
6706
|
-
this.outputRuleset(context, output, rules);
|
|
6707
|
-
}
|
|
6708
|
-
else {
|
|
6709
|
-
output.add(';');
|
|
6710
|
-
}
|
|
6711
|
-
},
|
|
6712
|
-
eval: function (context) {
|
|
6713
|
-
var mediaPathBackup, mediaBlocksBackup, value = this.value, rules = this.rules;
|
|
6714
|
-
// media stored inside other atrule should not bubble over it
|
|
6715
|
-
// backpup media bubbling information
|
|
6716
|
-
mediaPathBackup = context.mediaPath;
|
|
6717
|
-
mediaBlocksBackup = context.mediaBlocks;
|
|
6718
|
-
// deleted media bubbling information
|
|
6719
|
-
context.mediaPath = [];
|
|
6720
|
-
context.mediaBlocks = [];
|
|
6721
|
-
if (value) {
|
|
6722
|
-
value = value.eval(context);
|
|
6723
|
-
}
|
|
6724
|
-
if (rules) {
|
|
6725
|
-
// assuming that there is only one rule at this point - that is how parser constructs the rule
|
|
6726
|
-
rules = [rules[0].eval(context)];
|
|
6727
|
-
rules[0].root = true;
|
|
6728
|
-
}
|
|
6729
|
-
// restore media bubbling information
|
|
6730
|
-
context.mediaPath = mediaPathBackup;
|
|
6731
|
-
context.mediaBlocks = mediaBlocksBackup;
|
|
6732
|
-
return new AtRule(this.name, value, rules, this.getIndex(), this.fileInfo(), this.debugInfo, this.isRooted, this.visibilityInfo());
|
|
6733
|
-
},
|
|
6734
|
-
variable: function (name) {
|
|
6735
|
-
if (this.rules) {
|
|
6736
|
-
// assuming that there is only one rule at this point - that is how parser constructs the rule
|
|
6737
|
-
return Ruleset.prototype.variable.call(this.rules[0], name);
|
|
6738
|
-
}
|
|
6739
|
-
},
|
|
6740
|
-
find: function () {
|
|
6741
|
-
if (this.rules) {
|
|
6742
|
-
// assuming that there is only one rule at this point - that is how parser constructs the rule
|
|
6743
|
-
return Ruleset.prototype.find.apply(this.rules[0], arguments);
|
|
6744
|
-
}
|
|
6745
|
-
},
|
|
6746
|
-
rulesets: function () {
|
|
6747
|
-
if (this.rules) {
|
|
6748
|
-
// assuming that there is only one rule at this point - that is how parser constructs the rule
|
|
6749
|
-
return Ruleset.prototype.rulesets.apply(this.rules[0]);
|
|
6750
|
-
}
|
|
6751
|
-
},
|
|
6752
|
-
outputRuleset: function (context, output, rules) {
|
|
6753
|
-
var ruleCnt = rules.length;
|
|
6754
|
-
var i;
|
|
6755
|
-
context.tabLevel = (context.tabLevel | 0) + 1;
|
|
6756
|
-
// Compressed
|
|
6757
|
-
if (context.compress) {
|
|
6758
|
-
output.add('{');
|
|
6759
|
-
for (i = 0; i < ruleCnt; i++) {
|
|
6760
|
-
rules[i].genCSS(context, output);
|
|
6761
|
-
}
|
|
6762
|
-
output.add('}');
|
|
6763
|
-
context.tabLevel--;
|
|
6764
|
-
return;
|
|
6765
|
-
}
|
|
6766
|
-
// Non-compressed
|
|
6767
|
-
var tabSetStr = "\n".concat(Array(context.tabLevel).join(' ')), tabRuleStr = "".concat(tabSetStr, " ");
|
|
6768
|
-
if (!ruleCnt) {
|
|
6769
|
-
output.add(" {".concat(tabSetStr, "}"));
|
|
6770
|
-
}
|
|
6771
|
-
else {
|
|
6772
|
-
output.add(" {".concat(tabRuleStr));
|
|
6773
|
-
rules[0].genCSS(context, output);
|
|
6774
|
-
for (i = 1; i < ruleCnt; i++) {
|
|
6775
|
-
output.add(tabRuleStr);
|
|
6776
|
-
rules[i].genCSS(context, output);
|
|
6777
|
-
}
|
|
6778
|
-
output.add("".concat(tabSetStr, "}"));
|
|
6779
|
-
}
|
|
6780
|
-
context.tabLevel--;
|
|
6781
|
-
}
|
|
6782
|
-
});
|
|
6783
|
-
|
|
6784
|
-
var DetachedRuleset = function (ruleset, frames) {
|
|
6785
|
-
this.ruleset = ruleset;
|
|
6786
|
-
this.frames = frames;
|
|
6787
|
-
this.setParent(this.ruleset, this);
|
|
6788
|
-
};
|
|
6789
|
-
DetachedRuleset.prototype = Object.assign(new Node(), {
|
|
6790
|
-
type: 'DetachedRuleset',
|
|
6791
|
-
evalFirst: true,
|
|
6792
|
-
accept: function (visitor) {
|
|
6793
|
-
this.ruleset = visitor.visit(this.ruleset);
|
|
6794
|
-
},
|
|
6795
|
-
eval: function (context) {
|
|
6796
|
-
var frames = this.frames || copyArray(context.frames);
|
|
6797
|
-
return new DetachedRuleset(this.ruleset, frames);
|
|
6798
|
-
},
|
|
6799
|
-
callEval: function (context) {
|
|
6800
|
-
return this.ruleset.eval(this.frames ? new contexts.Eval(context, this.frames.concat(context.frames)) : context);
|
|
6801
|
-
}
|
|
6802
|
-
});
|
|
6803
|
-
|
|
6804
6742
|
var Unit = function (numerator, denominator, backupUnit) {
|
|
6805
6743
|
this.numerator = numerator ? copyArray(numerator).sort() : [];
|
|
6806
6744
|
this.denominator = denominator ? copyArray(denominator).sort() : [];
|
|
@@ -7065,54 +7003,6 @@
|
|
|
7065
7003
|
}
|
|
7066
7004
|
});
|
|
7067
7005
|
|
|
7068
|
-
var MATH = Math$1;
|
|
7069
|
-
var Operation = function (op, operands, isSpaced) {
|
|
7070
|
-
this.op = op.trim();
|
|
7071
|
-
this.operands = operands;
|
|
7072
|
-
this.isSpaced = isSpaced;
|
|
7073
|
-
};
|
|
7074
|
-
Operation.prototype = Object.assign(new Node(), {
|
|
7075
|
-
type: 'Operation',
|
|
7076
|
-
accept: function (visitor) {
|
|
7077
|
-
this.operands = visitor.visitArray(this.operands);
|
|
7078
|
-
},
|
|
7079
|
-
eval: function (context) {
|
|
7080
|
-
var a = this.operands[0].eval(context), b = this.operands[1].eval(context), op;
|
|
7081
|
-
if (context.isMathOn(this.op)) {
|
|
7082
|
-
op = this.op === './' ? '/' : this.op;
|
|
7083
|
-
if (a instanceof Dimension && b instanceof Color) {
|
|
7084
|
-
a = a.toColor();
|
|
7085
|
-
}
|
|
7086
|
-
if (b instanceof Dimension && a instanceof Color) {
|
|
7087
|
-
b = b.toColor();
|
|
7088
|
-
}
|
|
7089
|
-
if (!a.operate || !b.operate) {
|
|
7090
|
-
if ((a instanceof Operation || b instanceof Operation)
|
|
7091
|
-
&& a.op === '/' && context.math === MATH.PARENS_DIVISION) {
|
|
7092
|
-
return new Operation(this.op, [a, b], this.isSpaced);
|
|
7093
|
-
}
|
|
7094
|
-
throw { type: 'Operation',
|
|
7095
|
-
message: 'Operation on an invalid type' };
|
|
7096
|
-
}
|
|
7097
|
-
return a.operate(context, op, b);
|
|
7098
|
-
}
|
|
7099
|
-
else {
|
|
7100
|
-
return new Operation(this.op, [a, b], this.isSpaced);
|
|
7101
|
-
}
|
|
7102
|
-
},
|
|
7103
|
-
genCSS: function (context, output) {
|
|
7104
|
-
this.operands[0].genCSS(context, output);
|
|
7105
|
-
if (this.isSpaced) {
|
|
7106
|
-
output.add(' ');
|
|
7107
|
-
}
|
|
7108
|
-
output.add(this.op);
|
|
7109
|
-
if (this.isSpaced) {
|
|
7110
|
-
output.add(' ');
|
|
7111
|
-
}
|
|
7112
|
-
this.operands[1].genCSS(context, output);
|
|
7113
|
-
}
|
|
7114
|
-
});
|
|
7115
|
-
|
|
7116
7006
|
var Expression = function (value, noSpacing) {
|
|
7117
7007
|
this.value = value;
|
|
7118
7008
|
this.noSpacing = noSpacing;
|
|
@@ -7177,6 +7067,373 @@
|
|
|
7177
7067
|
}
|
|
7178
7068
|
});
|
|
7179
7069
|
|
|
7070
|
+
var NestableAtRulePrototype = {
|
|
7071
|
+
isRulesetLike: function () {
|
|
7072
|
+
return true;
|
|
7073
|
+
},
|
|
7074
|
+
accept: function (visitor) {
|
|
7075
|
+
if (this.features) {
|
|
7076
|
+
this.features = visitor.visit(this.features);
|
|
7077
|
+
}
|
|
7078
|
+
if (this.rules) {
|
|
7079
|
+
this.rules = visitor.visitArray(this.rules);
|
|
7080
|
+
}
|
|
7081
|
+
},
|
|
7082
|
+
evalTop: function (context) {
|
|
7083
|
+
var result = this;
|
|
7084
|
+
// Render all dependent Media blocks.
|
|
7085
|
+
if (context.mediaBlocks.length > 1) {
|
|
7086
|
+
var selectors = (new Selector([], null, null, this.getIndex(), this.fileInfo())).createEmptySelectors();
|
|
7087
|
+
result = new Ruleset(selectors, context.mediaBlocks);
|
|
7088
|
+
result.multiMedia = true;
|
|
7089
|
+
result.copyVisibilityInfo(this.visibilityInfo());
|
|
7090
|
+
this.setParent(result, this);
|
|
7091
|
+
}
|
|
7092
|
+
delete context.mediaBlocks;
|
|
7093
|
+
delete context.mediaPath;
|
|
7094
|
+
return result;
|
|
7095
|
+
},
|
|
7096
|
+
evalNested: function (context) {
|
|
7097
|
+
var i;
|
|
7098
|
+
var value;
|
|
7099
|
+
var path = context.mediaPath.concat([this]);
|
|
7100
|
+
// Extract the media-query conditions separated with `,` (OR).
|
|
7101
|
+
for (i = 0; i < path.length; i++) {
|
|
7102
|
+
if (path[i].type !== this.type) {
|
|
7103
|
+
context.mediaBlocks.splice(i, 1);
|
|
7104
|
+
return this;
|
|
7105
|
+
}
|
|
7106
|
+
value = path[i].features instanceof Value ?
|
|
7107
|
+
path[i].features.value : path[i].features;
|
|
7108
|
+
path[i] = Array.isArray(value) ? value : [value];
|
|
7109
|
+
}
|
|
7110
|
+
// Trace all permutations to generate the resulting media-query.
|
|
7111
|
+
//
|
|
7112
|
+
// (a, b and c) with nested (d, e) ->
|
|
7113
|
+
// a and d
|
|
7114
|
+
// a and e
|
|
7115
|
+
// b and c and d
|
|
7116
|
+
// b and c and e
|
|
7117
|
+
this.features = new Value(this.permute(path).map(function (path) {
|
|
7118
|
+
path = path.map(function (fragment) { return fragment.toCSS ? fragment : new Anonymous(fragment); });
|
|
7119
|
+
for (i = path.length - 1; i > 0; i--) {
|
|
7120
|
+
path.splice(i, 0, new Anonymous('and'));
|
|
7121
|
+
}
|
|
7122
|
+
return new Expression(path);
|
|
7123
|
+
}));
|
|
7124
|
+
this.setParent(this.features, this);
|
|
7125
|
+
// Fake a tree-node that doesn't output anything.
|
|
7126
|
+
return new Ruleset([], []);
|
|
7127
|
+
},
|
|
7128
|
+
permute: function (arr) {
|
|
7129
|
+
if (arr.length === 0) {
|
|
7130
|
+
return [];
|
|
7131
|
+
}
|
|
7132
|
+
else if (arr.length === 1) {
|
|
7133
|
+
return arr[0];
|
|
7134
|
+
}
|
|
7135
|
+
else {
|
|
7136
|
+
var result = [];
|
|
7137
|
+
var rest = this.permute(arr.slice(1));
|
|
7138
|
+
for (var i_1 = 0; i_1 < rest.length; i_1++) {
|
|
7139
|
+
for (var j = 0; j < arr[0].length; j++) {
|
|
7140
|
+
result.push([arr[0][j]].concat(rest[i_1]));
|
|
7141
|
+
}
|
|
7142
|
+
}
|
|
7143
|
+
return result;
|
|
7144
|
+
}
|
|
7145
|
+
},
|
|
7146
|
+
bubbleSelectors: function (selectors) {
|
|
7147
|
+
if (!selectors) {
|
|
7148
|
+
return;
|
|
7149
|
+
}
|
|
7150
|
+
this.rules = [new Ruleset(copyArray(selectors), [this.rules[0]])];
|
|
7151
|
+
this.setParent(this.rules, this);
|
|
7152
|
+
}
|
|
7153
|
+
};
|
|
7154
|
+
|
|
7155
|
+
var AtRule = function (name, value, rules, index, currentFileInfo, debugInfo, isRooted, visibilityInfo) {
|
|
7156
|
+
var _this = this;
|
|
7157
|
+
var i;
|
|
7158
|
+
var selectors = (new Selector([], null, null, this._index, this._fileInfo)).createEmptySelectors();
|
|
7159
|
+
this.name = name;
|
|
7160
|
+
this.value = (value instanceof Node) ? value : (value ? new Anonymous(value) : value);
|
|
7161
|
+
if (rules) {
|
|
7162
|
+
if (Array.isArray(rules)) {
|
|
7163
|
+
var allDeclarations = this.declarationsBlock(rules);
|
|
7164
|
+
var allRulesetDeclarations_1 = true;
|
|
7165
|
+
rules.forEach(function (rule) {
|
|
7166
|
+
if (rule.type === 'Ruleset' && rule.rules)
|
|
7167
|
+
allRulesetDeclarations_1 = allRulesetDeclarations_1 && _this.declarationsBlock(rule.rules, true);
|
|
7168
|
+
});
|
|
7169
|
+
if (allDeclarations && !isRooted) {
|
|
7170
|
+
this.simpleBlock = true;
|
|
7171
|
+
this.declarations = rules;
|
|
7172
|
+
}
|
|
7173
|
+
else if (allRulesetDeclarations_1 && rules.length === 1 && !isRooted && !value) {
|
|
7174
|
+
this.simpleBlock = true;
|
|
7175
|
+
this.declarations = rules[0].rules ? rules[0].rules : rules;
|
|
7176
|
+
}
|
|
7177
|
+
else {
|
|
7178
|
+
this.rules = rules;
|
|
7179
|
+
}
|
|
7180
|
+
}
|
|
7181
|
+
else {
|
|
7182
|
+
var allDeclarations = this.declarationsBlock(rules.rules);
|
|
7183
|
+
if (allDeclarations && !isRooted && !value) {
|
|
7184
|
+
this.simpleBlock = true;
|
|
7185
|
+
this.declarations = rules.rules;
|
|
7186
|
+
}
|
|
7187
|
+
else {
|
|
7188
|
+
this.rules = [rules];
|
|
7189
|
+
this.rules[0].selectors = (new Selector([], null, null, index, currentFileInfo)).createEmptySelectors();
|
|
7190
|
+
}
|
|
7191
|
+
}
|
|
7192
|
+
if (!this.simpleBlock) {
|
|
7193
|
+
for (i = 0; i < this.rules.length; i++) {
|
|
7194
|
+
this.rules[i].allowImports = true;
|
|
7195
|
+
}
|
|
7196
|
+
}
|
|
7197
|
+
this.setParent(selectors, this);
|
|
7198
|
+
this.setParent(this.rules, this);
|
|
7199
|
+
}
|
|
7200
|
+
this._index = index;
|
|
7201
|
+
this._fileInfo = currentFileInfo;
|
|
7202
|
+
this.debugInfo = debugInfo;
|
|
7203
|
+
this.isRooted = isRooted || false;
|
|
7204
|
+
this.copyVisibilityInfo(visibilityInfo);
|
|
7205
|
+
this.allowRoot = true;
|
|
7206
|
+
};
|
|
7207
|
+
AtRule.prototype = Object.assign(new Node(), __assign(__assign({ type: 'AtRule' }, NestableAtRulePrototype), { declarationsBlock: function (rules, mergeable) {
|
|
7208
|
+
if (mergeable === void 0) { mergeable = false; }
|
|
7209
|
+
if (!mergeable) {
|
|
7210
|
+
return rules.filter(function (node) { return (node.type === 'Declaration' || node.type === 'Comment') && !node.merge; }).length === rules.length;
|
|
7211
|
+
}
|
|
7212
|
+
else {
|
|
7213
|
+
return rules.filter(function (node) { return (node.type === 'Declaration' || node.type === 'Comment'); }).length === rules.length;
|
|
7214
|
+
}
|
|
7215
|
+
}, accept: function (visitor) {
|
|
7216
|
+
var value = this.value, rules = this.rules, declarations = this.declarations;
|
|
7217
|
+
if (rules) {
|
|
7218
|
+
this.rules = visitor.visitArray(rules);
|
|
7219
|
+
}
|
|
7220
|
+
else if (declarations) {
|
|
7221
|
+
this.declarations = visitor.visitArray(declarations);
|
|
7222
|
+
}
|
|
7223
|
+
if (value) {
|
|
7224
|
+
this.value = visitor.visit(value);
|
|
7225
|
+
}
|
|
7226
|
+
}, isRulesetLike: function () {
|
|
7227
|
+
return this.rules || !this.isCharset();
|
|
7228
|
+
}, isCharset: function () {
|
|
7229
|
+
return '@charset' === this.name;
|
|
7230
|
+
}, genCSS: function (context, output) {
|
|
7231
|
+
var value = this.value, rules = this.rules || this.declarations;
|
|
7232
|
+
output.add(this.name, this.fileInfo(), this.getIndex());
|
|
7233
|
+
if (value) {
|
|
7234
|
+
output.add(' ');
|
|
7235
|
+
value.genCSS(context, output);
|
|
7236
|
+
}
|
|
7237
|
+
if (this.simpleBlock) {
|
|
7238
|
+
this.outputRuleset(context, output, this.declarations);
|
|
7239
|
+
}
|
|
7240
|
+
else if (rules) {
|
|
7241
|
+
this.outputRuleset(context, output, rules);
|
|
7242
|
+
}
|
|
7243
|
+
else {
|
|
7244
|
+
output.add(';');
|
|
7245
|
+
}
|
|
7246
|
+
}, eval: function (context) {
|
|
7247
|
+
var mediaPathBackup, mediaBlocksBackup, value = this.value, rules = this.rules || this.declarations;
|
|
7248
|
+
// media stored inside other atrule should not bubble over it
|
|
7249
|
+
// backpup media bubbling information
|
|
7250
|
+
mediaPathBackup = context.mediaPath;
|
|
7251
|
+
mediaBlocksBackup = context.mediaBlocks;
|
|
7252
|
+
// deleted media bubbling information
|
|
7253
|
+
context.mediaPath = [];
|
|
7254
|
+
context.mediaBlocks = [];
|
|
7255
|
+
if (value) {
|
|
7256
|
+
value = value.eval(context);
|
|
7257
|
+
}
|
|
7258
|
+
if (rules) {
|
|
7259
|
+
rules = this.evalRoot(context, rules);
|
|
7260
|
+
}
|
|
7261
|
+
if (Array.isArray(rules) && rules[0].rules && Array.isArray(rules[0].rules) && rules[0].rules.length) {
|
|
7262
|
+
var allMergeableDeclarations = this.declarationsBlock(rules[0].rules, true);
|
|
7263
|
+
if (allMergeableDeclarations && !this.isRooted && !value) {
|
|
7264
|
+
var mergeRules = context.pluginManager.less.visitors.ToCSSVisitor.prototype._mergeRules;
|
|
7265
|
+
mergeRules(rules[0].rules);
|
|
7266
|
+
rules = rules[0].rules;
|
|
7267
|
+
rules.forEach(function (rule) { return rule.merge = false; });
|
|
7268
|
+
}
|
|
7269
|
+
}
|
|
7270
|
+
if (this.simpleBlock && rules) {
|
|
7271
|
+
rules[0].functionRegistry = context.frames[0].functionRegistry.inherit();
|
|
7272
|
+
rules = rules.map(function (rule) { return rule.eval(context); });
|
|
7273
|
+
}
|
|
7274
|
+
// restore media bubbling information
|
|
7275
|
+
context.mediaPath = mediaPathBackup;
|
|
7276
|
+
context.mediaBlocks = mediaBlocksBackup;
|
|
7277
|
+
return new AtRule(this.name, value, rules, this.getIndex(), this.fileInfo(), this.debugInfo, this.isRooted, this.visibilityInfo());
|
|
7278
|
+
}, evalRoot: function (context, rules) {
|
|
7279
|
+
var ampersandCount = 0;
|
|
7280
|
+
var noAmpersandCount = 0;
|
|
7281
|
+
var noAmpersands = true;
|
|
7282
|
+
var allAmpersands = false;
|
|
7283
|
+
if (!this.simpleBlock) {
|
|
7284
|
+
rules = [rules[0].eval(context)];
|
|
7285
|
+
}
|
|
7286
|
+
var precedingSelectors = [];
|
|
7287
|
+
if (context.frames.length > 0) {
|
|
7288
|
+
var _loop_1 = function (index) {
|
|
7289
|
+
var frame = context.frames[index];
|
|
7290
|
+
if (frame.type === 'Ruleset' &&
|
|
7291
|
+
frame.rules &&
|
|
7292
|
+
frame.rules.length > 0) {
|
|
7293
|
+
if (frame && !frame.root && frame.selectors && frame.selectors.length > 0) {
|
|
7294
|
+
precedingSelectors = precedingSelectors.concat(frame.selectors);
|
|
7295
|
+
}
|
|
7296
|
+
}
|
|
7297
|
+
if (precedingSelectors.length > 0) {
|
|
7298
|
+
var value_1 = '';
|
|
7299
|
+
var output = { add: function (s) { value_1 += s; } };
|
|
7300
|
+
for (var i_1 = 0; i_1 < precedingSelectors.length; i_1++) {
|
|
7301
|
+
precedingSelectors[i_1].genCSS(context, output);
|
|
7302
|
+
}
|
|
7303
|
+
if (/^&+$/.test(value_1.replace(/\s+/g, ''))) {
|
|
7304
|
+
noAmpersands = false;
|
|
7305
|
+
noAmpersandCount++;
|
|
7306
|
+
}
|
|
7307
|
+
else {
|
|
7308
|
+
allAmpersands = false;
|
|
7309
|
+
ampersandCount++;
|
|
7310
|
+
}
|
|
7311
|
+
}
|
|
7312
|
+
};
|
|
7313
|
+
for (var index = 0; index < context.frames.length; index++) {
|
|
7314
|
+
_loop_1(index);
|
|
7315
|
+
}
|
|
7316
|
+
}
|
|
7317
|
+
var mixedAmpersands = ampersandCount > 0 && noAmpersandCount > 0 && !allAmpersands && !noAmpersands;
|
|
7318
|
+
if ((this.isRooted && ampersandCount > 0 && noAmpersandCount === 0 && !allAmpersands && noAmpersands)
|
|
7319
|
+
|| !mixedAmpersands) {
|
|
7320
|
+
rules[0].root = true;
|
|
7321
|
+
}
|
|
7322
|
+
return rules;
|
|
7323
|
+
}, variable: function (name) {
|
|
7324
|
+
if (this.rules) {
|
|
7325
|
+
// assuming that there is only one rule at this point - that is how parser constructs the rule
|
|
7326
|
+
return Ruleset.prototype.variable.call(this.rules[0], name);
|
|
7327
|
+
}
|
|
7328
|
+
}, find: function () {
|
|
7329
|
+
if (this.rules) {
|
|
7330
|
+
// assuming that there is only one rule at this point - that is how parser constructs the rule
|
|
7331
|
+
return Ruleset.prototype.find.apply(this.rules[0], arguments);
|
|
7332
|
+
}
|
|
7333
|
+
}, rulesets: function () {
|
|
7334
|
+
if (this.rules) {
|
|
7335
|
+
// assuming that there is only one rule at this point - that is how parser constructs the rule
|
|
7336
|
+
return Ruleset.prototype.rulesets.apply(this.rules[0]);
|
|
7337
|
+
}
|
|
7338
|
+
}, outputRuleset: function (context, output, rules) {
|
|
7339
|
+
var ruleCnt = rules.length;
|
|
7340
|
+
var i;
|
|
7341
|
+
context.tabLevel = (context.tabLevel | 0) + 1;
|
|
7342
|
+
// Compressed
|
|
7343
|
+
if (context.compress) {
|
|
7344
|
+
output.add('{');
|
|
7345
|
+
for (i = 0; i < ruleCnt; i++) {
|
|
7346
|
+
rules[i].genCSS(context, output);
|
|
7347
|
+
}
|
|
7348
|
+
output.add('}');
|
|
7349
|
+
context.tabLevel--;
|
|
7350
|
+
return;
|
|
7351
|
+
}
|
|
7352
|
+
// Non-compressed
|
|
7353
|
+
var tabSetStr = "\n".concat(Array(context.tabLevel).join(' ')), tabRuleStr = "".concat(tabSetStr, " ");
|
|
7354
|
+
if (!ruleCnt) {
|
|
7355
|
+
output.add(" {".concat(tabSetStr, "}"));
|
|
7356
|
+
}
|
|
7357
|
+
else {
|
|
7358
|
+
output.add(" {".concat(tabRuleStr));
|
|
7359
|
+
rules[0].genCSS(context, output);
|
|
7360
|
+
for (i = 1; i < ruleCnt; i++) {
|
|
7361
|
+
output.add(tabRuleStr);
|
|
7362
|
+
rules[i].genCSS(context, output);
|
|
7363
|
+
}
|
|
7364
|
+
output.add("".concat(tabSetStr, "}"));
|
|
7365
|
+
}
|
|
7366
|
+
context.tabLevel--;
|
|
7367
|
+
} }));
|
|
7368
|
+
|
|
7369
|
+
var DetachedRuleset = function (ruleset, frames) {
|
|
7370
|
+
this.ruleset = ruleset;
|
|
7371
|
+
this.frames = frames;
|
|
7372
|
+
this.setParent(this.ruleset, this);
|
|
7373
|
+
};
|
|
7374
|
+
DetachedRuleset.prototype = Object.assign(new Node(), {
|
|
7375
|
+
type: 'DetachedRuleset',
|
|
7376
|
+
evalFirst: true,
|
|
7377
|
+
accept: function (visitor) {
|
|
7378
|
+
this.ruleset = visitor.visit(this.ruleset);
|
|
7379
|
+
},
|
|
7380
|
+
eval: function (context) {
|
|
7381
|
+
var frames = this.frames || copyArray(context.frames);
|
|
7382
|
+
return new DetachedRuleset(this.ruleset, frames);
|
|
7383
|
+
},
|
|
7384
|
+
callEval: function (context) {
|
|
7385
|
+
return this.ruleset.eval(this.frames ? new contexts.Eval(context, this.frames.concat(context.frames)) : context);
|
|
7386
|
+
}
|
|
7387
|
+
});
|
|
7388
|
+
|
|
7389
|
+
var MATH = Math$1;
|
|
7390
|
+
var Operation = function (op, operands, isSpaced) {
|
|
7391
|
+
this.op = op.trim();
|
|
7392
|
+
this.operands = operands;
|
|
7393
|
+
this.isSpaced = isSpaced;
|
|
7394
|
+
};
|
|
7395
|
+
Operation.prototype = Object.assign(new Node(), {
|
|
7396
|
+
type: 'Operation',
|
|
7397
|
+
accept: function (visitor) {
|
|
7398
|
+
this.operands = visitor.visitArray(this.operands);
|
|
7399
|
+
},
|
|
7400
|
+
eval: function (context) {
|
|
7401
|
+
var a = this.operands[0].eval(context), b = this.operands[1].eval(context), op;
|
|
7402
|
+
if (context.isMathOn(this.op)) {
|
|
7403
|
+
op = this.op === './' ? '/' : this.op;
|
|
7404
|
+
if (a instanceof Dimension && b instanceof Color) {
|
|
7405
|
+
a = a.toColor();
|
|
7406
|
+
}
|
|
7407
|
+
if (b instanceof Dimension && a instanceof Color) {
|
|
7408
|
+
b = b.toColor();
|
|
7409
|
+
}
|
|
7410
|
+
if (!a.operate || !b.operate) {
|
|
7411
|
+
if ((a instanceof Operation || b instanceof Operation)
|
|
7412
|
+
&& a.op === '/' && context.math === MATH.PARENS_DIVISION) {
|
|
7413
|
+
return new Operation(this.op, [a, b], this.isSpaced);
|
|
7414
|
+
}
|
|
7415
|
+
throw { type: 'Operation',
|
|
7416
|
+
message: 'Operation on an invalid type' };
|
|
7417
|
+
}
|
|
7418
|
+
return a.operate(context, op, b);
|
|
7419
|
+
}
|
|
7420
|
+
else {
|
|
7421
|
+
return new Operation(this.op, [a, b], this.isSpaced);
|
|
7422
|
+
}
|
|
7423
|
+
},
|
|
7424
|
+
genCSS: function (context, output) {
|
|
7425
|
+
this.operands[0].genCSS(context, output);
|
|
7426
|
+
if (this.isSpaced) {
|
|
7427
|
+
output.add(' ');
|
|
7428
|
+
}
|
|
7429
|
+
output.add(this.op);
|
|
7430
|
+
if (this.isSpaced) {
|
|
7431
|
+
output.add(' ');
|
|
7432
|
+
}
|
|
7433
|
+
this.operands[1].genCSS(context, output);
|
|
7434
|
+
}
|
|
7435
|
+
});
|
|
7436
|
+
|
|
7180
7437
|
var functionCaller = /** @class */ (function () {
|
|
7181
7438
|
function functionCaller(name, context, index, currentFileInfo) {
|
|
7182
7439
|
this.name = name.toLowerCase();
|
|
@@ -7493,12 +7750,12 @@
|
|
|
7493
7750
|
eval: function (context) {
|
|
7494
7751
|
var that = this;
|
|
7495
7752
|
var value = this.value;
|
|
7496
|
-
var variableReplacement = function (_,
|
|
7497
|
-
var v = new Variable("@".concat(
|
|
7753
|
+
var variableReplacement = function (_, name1, name2) {
|
|
7754
|
+
var v = new Variable("@".concat(name1 !== null && name1 !== void 0 ? name1 : name2), that.getIndex(), that.fileInfo()).eval(context, true);
|
|
7498
7755
|
return (v instanceof Quoted) ? v.value : v.toCSS();
|
|
7499
7756
|
};
|
|
7500
|
-
var propertyReplacement = function (_,
|
|
7501
|
-
var v = new Property("$".concat(
|
|
7757
|
+
var propertyReplacement = function (_, name1, name2) {
|
|
7758
|
+
var v = new Property("$".concat(name1 !== null && name1 !== void 0 ? name1 : name2), that.getIndex(), that.fileInfo()).eval(context, true);
|
|
7502
7759
|
return (v instanceof Quoted) ? v.value : v.toCSS();
|
|
7503
7760
|
};
|
|
7504
7761
|
function iterativeReplace(value, regexp, replacementFnc) {
|
|
@@ -7578,91 +7835,6 @@
|
|
|
7578
7835
|
}
|
|
7579
7836
|
});
|
|
7580
7837
|
|
|
7581
|
-
var NestableAtRulePrototype = {
|
|
7582
|
-
isRulesetLike: function () {
|
|
7583
|
-
return true;
|
|
7584
|
-
},
|
|
7585
|
-
accept: function (visitor) {
|
|
7586
|
-
if (this.features) {
|
|
7587
|
-
this.features = visitor.visit(this.features);
|
|
7588
|
-
}
|
|
7589
|
-
if (this.rules) {
|
|
7590
|
-
this.rules = visitor.visitArray(this.rules);
|
|
7591
|
-
}
|
|
7592
|
-
},
|
|
7593
|
-
evalTop: function (context) {
|
|
7594
|
-
var result = this;
|
|
7595
|
-
// Render all dependent Media blocks.
|
|
7596
|
-
if (context.mediaBlocks.length > 1) {
|
|
7597
|
-
var selectors = (new Selector([], null, null, this.getIndex(), this.fileInfo())).createEmptySelectors();
|
|
7598
|
-
result = new Ruleset(selectors, context.mediaBlocks);
|
|
7599
|
-
result.multiMedia = true;
|
|
7600
|
-
result.copyVisibilityInfo(this.visibilityInfo());
|
|
7601
|
-
this.setParent(result, this);
|
|
7602
|
-
}
|
|
7603
|
-
delete context.mediaBlocks;
|
|
7604
|
-
delete context.mediaPath;
|
|
7605
|
-
return result;
|
|
7606
|
-
},
|
|
7607
|
-
evalNested: function (context) {
|
|
7608
|
-
var i;
|
|
7609
|
-
var value;
|
|
7610
|
-
var path = context.mediaPath.concat([this]);
|
|
7611
|
-
// Extract the media-query conditions separated with `,` (OR).
|
|
7612
|
-
for (i = 0; i < path.length; i++) {
|
|
7613
|
-
if (path[i].type !== this.type) {
|
|
7614
|
-
context.mediaBlocks.splice(i, 1);
|
|
7615
|
-
return this;
|
|
7616
|
-
}
|
|
7617
|
-
value = path[i].features instanceof Value ?
|
|
7618
|
-
path[i].features.value : path[i].features;
|
|
7619
|
-
path[i] = Array.isArray(value) ? value : [value];
|
|
7620
|
-
}
|
|
7621
|
-
// Trace all permutations to generate the resulting media-query.
|
|
7622
|
-
//
|
|
7623
|
-
// (a, b and c) with nested (d, e) ->
|
|
7624
|
-
// a and d
|
|
7625
|
-
// a and e
|
|
7626
|
-
// b and c and d
|
|
7627
|
-
// b and c and e
|
|
7628
|
-
this.features = new Value(this.permute(path).map(function (path) {
|
|
7629
|
-
path = path.map(function (fragment) { return fragment.toCSS ? fragment : new Anonymous(fragment); });
|
|
7630
|
-
for (i = path.length - 1; i > 0; i--) {
|
|
7631
|
-
path.splice(i, 0, new Anonymous('and'));
|
|
7632
|
-
}
|
|
7633
|
-
return new Expression(path);
|
|
7634
|
-
}));
|
|
7635
|
-
this.setParent(this.features, this);
|
|
7636
|
-
// Fake a tree-node that doesn't output anything.
|
|
7637
|
-
return new Ruleset([], []);
|
|
7638
|
-
},
|
|
7639
|
-
permute: function (arr) {
|
|
7640
|
-
if (arr.length === 0) {
|
|
7641
|
-
return [];
|
|
7642
|
-
}
|
|
7643
|
-
else if (arr.length === 1) {
|
|
7644
|
-
return arr[0];
|
|
7645
|
-
}
|
|
7646
|
-
else {
|
|
7647
|
-
var result = [];
|
|
7648
|
-
var rest = this.permute(arr.slice(1));
|
|
7649
|
-
for (var i_1 = 0; i_1 < rest.length; i_1++) {
|
|
7650
|
-
for (var j = 0; j < arr[0].length; j++) {
|
|
7651
|
-
result.push([arr[0][j]].concat(rest[i_1]));
|
|
7652
|
-
}
|
|
7653
|
-
}
|
|
7654
|
-
return result;
|
|
7655
|
-
}
|
|
7656
|
-
},
|
|
7657
|
-
bubbleSelectors: function (selectors) {
|
|
7658
|
-
if (!selectors) {
|
|
7659
|
-
return;
|
|
7660
|
-
}
|
|
7661
|
-
this.rules = [new Ruleset(copyArray(selectors), [this.rules[0]])];
|
|
7662
|
-
this.setParent(this.rules, this);
|
|
7663
|
-
}
|
|
7664
|
-
};
|
|
7665
|
-
|
|
7666
7838
|
var Media = function (value, features, index, currentFileInfo, visibilityInfo) {
|
|
7667
7839
|
this._index = index;
|
|
7668
7840
|
this._fileInfo = currentFileInfo;
|
|
@@ -8140,6 +8312,7 @@
|
|
|
8140
8312
|
this.copyVisibilityInfo(visibilityInfo);
|
|
8141
8313
|
this.allowRoot = true;
|
|
8142
8314
|
switch (option) {
|
|
8315
|
+
case '!all':
|
|
8143
8316
|
case 'all':
|
|
8144
8317
|
this.allowBefore = true;
|
|
8145
8318
|
this.allowAfter = true;
|
|
@@ -10852,22 +11025,25 @@
|
|
|
10852
11025
|
return render;
|
|
10853
11026
|
}
|
|
10854
11027
|
|
|
10855
|
-
var version = "4.
|
|
11028
|
+
var version = "4.3.0";
|
|
11029
|
+
|
|
11030
|
+
function parseNodeVersion(version) {
|
|
11031
|
+
var match = version.match(/^v(\d{1,2})\.(\d{1,2})\.(\d{1,2})(?:-([0-9A-Za-z-.]+))?(?:\+([0-9A-Za-z-.]+))?$/); // eslint-disable-line max-len
|
|
11032
|
+
if (!match) {
|
|
11033
|
+
throw new Error('Unable to parse: ' + version);
|
|
11034
|
+
}
|
|
11035
|
+
|
|
11036
|
+
var res = {
|
|
11037
|
+
major: parseInt(match[1], 10),
|
|
11038
|
+
minor: parseInt(match[2], 10),
|
|
11039
|
+
patch: parseInt(match[3], 10),
|
|
11040
|
+
pre: match[4] || '',
|
|
11041
|
+
build: match[5] || '',
|
|
11042
|
+
};
|
|
11043
|
+
|
|
11044
|
+
return res;
|
|
11045
|
+
}
|
|
10856
11046
|
|
|
10857
|
-
function parseNodeVersion(version) {
|
|
10858
|
-
var match = version.match(/^v(\d{1,2})\.(\d{1,2})\.(\d{1,2})(?:-([0-9A-Za-z-.]+))?(?:\+([0-9A-Za-z-.]+))?$/); // eslint-disable-line max-len
|
|
10859
|
-
if (!match) {
|
|
10860
|
-
throw new Error('Unable to parse: ' + version);
|
|
10861
|
-
}
|
|
10862
|
-
var res = {
|
|
10863
|
-
major: parseInt(match[1], 10),
|
|
10864
|
-
minor: parseInt(match[2], 10),
|
|
10865
|
-
patch: parseInt(match[3], 10),
|
|
10866
|
-
pre: match[4] || '',
|
|
10867
|
-
build: match[5] || '',
|
|
10868
|
-
};
|
|
10869
|
-
return res;
|
|
10870
|
-
}
|
|
10871
11047
|
var parseNodeVersion_1 = parseNodeVersion;
|
|
10872
11048
|
|
|
10873
11049
|
function lessRoot (environment, fileManagers) {
|