less 4.2.1 → 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 +731 -495
- package/dist/less.min.js +3 -3
- 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 +112 -22
- 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/nested-at-rule.js +4 -0
- package/lib/less/tree/nested-at-rule.js.map +1 -1
- package/lib/less/tree/query-in-parens.js +32 -1
- package/lib/less/tree/query-in-parens.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/browser/generator/generate.js +2 -2
- package/test/less-test.js +3 -1
- package/test/mocha-playwright/runner.js +210 -0
package/dist/less.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Less - Leaner CSS v4.
|
|
2
|
+
* Less - Leaner CSS v4.3.0
|
|
3
3
|
* http://lesscss.org
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c) 2009-
|
|
5
|
+
* Copyright (c) 2009-2025, Alexis Sellier <self@cloudhead.net>
|
|
6
6
|
* Licensed under the Apache-2.0 License.
|
|
7
7
|
*
|
|
8
8
|
* @license Apache-2.0
|
|
@@ -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
|
};
|
|
@@ -3238,6 +3263,34 @@
|
|
|
3238
3263
|
queryInParens: true
|
|
3239
3264
|
};
|
|
3240
3265
|
|
|
3266
|
+
var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) {
|
|
3267
|
+
this.value = value;
|
|
3268
|
+
this._index = index;
|
|
3269
|
+
this._fileInfo = currentFileInfo;
|
|
3270
|
+
this.mapLines = mapLines;
|
|
3271
|
+
this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike;
|
|
3272
|
+
this.allowRoot = true;
|
|
3273
|
+
this.copyVisibilityInfo(visibilityInfo);
|
|
3274
|
+
};
|
|
3275
|
+
Anonymous.prototype = Object.assign(new Node(), {
|
|
3276
|
+
type: 'Anonymous',
|
|
3277
|
+
eval: function () {
|
|
3278
|
+
return new Anonymous(this.value, this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo());
|
|
3279
|
+
},
|
|
3280
|
+
compare: function (other) {
|
|
3281
|
+
return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;
|
|
3282
|
+
},
|
|
3283
|
+
isRulesetLike: function () {
|
|
3284
|
+
return this.rulesetLike;
|
|
3285
|
+
},
|
|
3286
|
+
genCSS: function (context, output) {
|
|
3287
|
+
this.nodeVisible = Boolean(this.value);
|
|
3288
|
+
if (this.nodeVisible) {
|
|
3289
|
+
output.add(this.value, this._fileInfo, this._index, this.mapLines);
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
});
|
|
3293
|
+
|
|
3241
3294
|
//
|
|
3242
3295
|
// less.js - parser
|
|
3243
3296
|
//
|
|
@@ -3282,6 +3335,22 @@
|
|
|
3282
3335
|
message: msg
|
|
3283
3336
|
}, imports);
|
|
3284
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
|
+
}
|
|
3285
3354
|
function expect(arg, msg) {
|
|
3286
3355
|
// some older browsers return typeof 'function' for RegExp
|
|
3287
3356
|
var result = (arg instanceof Function) ? arg.call(parsers) : parserInput.$re(arg);
|
|
@@ -3989,11 +4058,20 @@
|
|
|
3989
4058
|
do {
|
|
3990
4059
|
option = null;
|
|
3991
4060
|
elements = null;
|
|
3992
|
-
|
|
4061
|
+
var first = true;
|
|
4062
|
+
while (!(option = parserInput.$re(/^(!?all)(?=\s*(\)|,))/))) {
|
|
3993
4063
|
e = this.element();
|
|
3994
4064
|
if (!e) {
|
|
3995
4065
|
break;
|
|
3996
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;
|
|
3997
4075
|
if (elements) {
|
|
3998
4076
|
elements.push(e);
|
|
3999
4077
|
}
|
|
@@ -4053,16 +4131,23 @@
|
|
|
4053
4131
|
var elements;
|
|
4054
4132
|
var args;
|
|
4055
4133
|
var hasParens;
|
|
4134
|
+
var parensIndex;
|
|
4135
|
+
var parensWS = false;
|
|
4056
4136
|
if (s !== '.' && s !== '#') {
|
|
4057
4137
|
return;
|
|
4058
4138
|
}
|
|
4059
4139
|
parserInput.save(); // stop us absorbing part of an invalid selector
|
|
4060
4140
|
elements = this.elements();
|
|
4061
4141
|
if (elements) {
|
|
4142
|
+
parensIndex = parserInput.i;
|
|
4062
4143
|
if (parserInput.$char('(')) {
|
|
4144
|
+
parensWS = parserInput.isWhitespace(-2);
|
|
4063
4145
|
args = this.args(true).args;
|
|
4064
4146
|
expectChar(')');
|
|
4065
4147
|
hasParens = true;
|
|
4148
|
+
if (parensWS) {
|
|
4149
|
+
warn('Whitespace between a mixin name and parentheses for a mixin call is deprecated', parensIndex, 'DEPRECATED');
|
|
4150
|
+
}
|
|
4066
4151
|
}
|
|
4067
4152
|
if (getLookup !== false) {
|
|
4068
4153
|
lookups = this.ruleLookups();
|
|
@@ -4086,6 +4171,9 @@
|
|
|
4086
4171
|
return new tree.NamespaceValue(mixin, lookups);
|
|
4087
4172
|
}
|
|
4088
4173
|
else {
|
|
4174
|
+
if (!hasParens) {
|
|
4175
|
+
warn('Calling a mixin without parentheses is deprecated', parensIndex, 'DEPRECATED');
|
|
4176
|
+
}
|
|
4089
4177
|
return mixin;
|
|
4090
4178
|
}
|
|
4091
4179
|
}
|
|
@@ -4375,24 +4463,25 @@
|
|
|
4375
4463
|
expectChar(')');
|
|
4376
4464
|
return new tree.Quoted('', "alpha(opacity=".concat(value, ")"));
|
|
4377
4465
|
},
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
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
|
+
*/
|
|
4390
4478
|
element: function () {
|
|
4391
4479
|
var e;
|
|
4392
4480
|
var c;
|
|
4393
4481
|
var v;
|
|
4394
4482
|
var index = parserInput.i;
|
|
4395
4483
|
c = this.combinator();
|
|
4484
|
+
/** This selector parser is quite simplistic and will pass a number of invalid selectors. */
|
|
4396
4485
|
e = parserInput.$re(/^(?:\d+\.\d+|\d+)%/) ||
|
|
4397
4486
|
// eslint-disable-next-line no-control-regex
|
|
4398
4487
|
parserInput.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||
|
|
@@ -4402,9 +4491,26 @@
|
|
|
4402
4491
|
if (!e) {
|
|
4403
4492
|
parserInput.save();
|
|
4404
4493
|
if (parserInput.$char('(')) {
|
|
4405
|
-
if ((v = this.selector(false))
|
|
4406
|
-
|
|
4407
|
-
parserInput
|
|
4494
|
+
if ((v = this.selector(false))) {
|
|
4495
|
+
var selectors = [];
|
|
4496
|
+
while (parserInput.$char(',')) {
|
|
4497
|
+
selectors.push(v);
|
|
4498
|
+
selectors.push(new Anonymous(','));
|
|
4499
|
+
v = this.selector(false);
|
|
4500
|
+
}
|
|
4501
|
+
selectors.push(v);
|
|
4502
|
+
if (parserInput.$char(')')) {
|
|
4503
|
+
if (selectors.length > 1) {
|
|
4504
|
+
e = new (tree.Paren)(new Selector(selectors));
|
|
4505
|
+
}
|
|
4506
|
+
else {
|
|
4507
|
+
e = new (tree.Paren)(v);
|
|
4508
|
+
}
|
|
4509
|
+
parserInput.forget();
|
|
4510
|
+
}
|
|
4511
|
+
else {
|
|
4512
|
+
parserInput.restore('Missing closing \')\'');
|
|
4513
|
+
}
|
|
4408
4514
|
}
|
|
4409
4515
|
else {
|
|
4410
4516
|
parserInput.restore('Missing closing \')\'');
|
|
@@ -4495,6 +4601,9 @@
|
|
|
4495
4601
|
error('Extend can only be used at the end of selector');
|
|
4496
4602
|
}
|
|
4497
4603
|
c = parserInput.currentChar();
|
|
4604
|
+
if (Array.isArray(e)) {
|
|
4605
|
+
e.forEach(function (ele) { return elements.push(ele); });
|
|
4606
|
+
}
|
|
4498
4607
|
if (elements) {
|
|
4499
4608
|
elements.push(e);
|
|
4500
4609
|
}
|
|
@@ -4669,7 +4778,12 @@
|
|
|
4669
4778
|
merge = !isVariable && name.length > 1 && name.pop().value;
|
|
4670
4779
|
// Custom property values get permissive parsing
|
|
4671
4780
|
if (name[0].value && name[0].value.slice(0, 2) === '--') {
|
|
4672
|
-
|
|
4781
|
+
if (parserInput.$char(';')) {
|
|
4782
|
+
value = new Anonymous('');
|
|
4783
|
+
}
|
|
4784
|
+
else {
|
|
4785
|
+
value = this.permissiveValue(/[;}]/, true);
|
|
4786
|
+
}
|
|
4673
4787
|
}
|
|
4674
4788
|
// Try to store values as anonymous
|
|
4675
4789
|
// If we need the value later we'll re-parse it in ruleset.parseValue
|
|
@@ -4688,7 +4802,12 @@
|
|
|
4688
4802
|
important = this.important();
|
|
4689
4803
|
}
|
|
4690
4804
|
else if (isVariable) {
|
|
4691
|
-
|
|
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
|
+
*/
|
|
4692
4811
|
value = this.permissiveValue();
|
|
4693
4812
|
}
|
|
4694
4813
|
}
|
|
@@ -4719,6 +4838,8 @@
|
|
|
4719
4838
|
* First, it will try to parse comments and entities to reach
|
|
4720
4839
|
* the end. This is mostly like the Expression parser except no
|
|
4721
4840
|
* math is allowed.
|
|
4841
|
+
*
|
|
4842
|
+
* @param {RexExp} untilTokens - Characters to stop parsing at
|
|
4722
4843
|
*/
|
|
4723
4844
|
permissiveValue: function (untilTokens) {
|
|
4724
4845
|
var i;
|
|
@@ -4780,6 +4901,7 @@
|
|
|
4780
4901
|
parserInput.forget();
|
|
4781
4902
|
return new tree.Anonymous('', index);
|
|
4782
4903
|
}
|
|
4904
|
+
/** @type {string} */
|
|
4783
4905
|
var item = void 0;
|
|
4784
4906
|
for (i = 0; i < value.length; i++) {
|
|
4785
4907
|
item = value[i];
|
|
@@ -4793,8 +4915,16 @@
|
|
|
4793
4915
|
}
|
|
4794
4916
|
// Treat like quoted values, but replace vars like unquoted expressions
|
|
4795
4917
|
var quote = new tree.Quoted('\'', item, true, index, fileInfo);
|
|
4796
|
-
|
|
4797
|
-
|
|
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');
|
|
4922
|
+
}
|
|
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;
|
|
4798
4928
|
result.push(quote);
|
|
4799
4929
|
}
|
|
4800
4930
|
}
|
|
@@ -5083,6 +5213,9 @@
|
|
|
5083
5213
|
hasUnknown = true;
|
|
5084
5214
|
isRooted = false;
|
|
5085
5215
|
break;
|
|
5216
|
+
case '@starting-style':
|
|
5217
|
+
isRooted = false;
|
|
5218
|
+
break;
|
|
5086
5219
|
default:
|
|
5087
5220
|
hasUnknown = true;
|
|
5088
5221
|
break;
|
|
@@ -5182,7 +5315,14 @@
|
|
|
5182
5315
|
break;
|
|
5183
5316
|
}
|
|
5184
5317
|
parserInput.save();
|
|
5185
|
-
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
|
+
}
|
|
5186
5326
|
if (!op) {
|
|
5187
5327
|
parserInput.forget();
|
|
5188
5328
|
break;
|
|
@@ -5443,7 +5583,7 @@
|
|
|
5443
5583
|
var index = parserInput.i;
|
|
5444
5584
|
do {
|
|
5445
5585
|
e = this.comment();
|
|
5446
|
-
if (e) {
|
|
5586
|
+
if (e && !e.isLineComment) {
|
|
5447
5587
|
entities.push(e);
|
|
5448
5588
|
continue;
|
|
5449
5589
|
}
|
|
@@ -5704,34 +5844,6 @@
|
|
|
5704
5844
|
Keyword.True = new Keyword('true');
|
|
5705
5845
|
Keyword.False = new Keyword('false');
|
|
5706
5846
|
|
|
5707
|
-
var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) {
|
|
5708
|
-
this.value = value;
|
|
5709
|
-
this._index = index;
|
|
5710
|
-
this._fileInfo = currentFileInfo;
|
|
5711
|
-
this.mapLines = mapLines;
|
|
5712
|
-
this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike;
|
|
5713
|
-
this.allowRoot = true;
|
|
5714
|
-
this.copyVisibilityInfo(visibilityInfo);
|
|
5715
|
-
};
|
|
5716
|
-
Anonymous.prototype = Object.assign(new Node(), {
|
|
5717
|
-
type: 'Anonymous',
|
|
5718
|
-
eval: function () {
|
|
5719
|
-
return new Anonymous(this.value, this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo());
|
|
5720
|
-
},
|
|
5721
|
-
compare: function (other) {
|
|
5722
|
-
return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;
|
|
5723
|
-
},
|
|
5724
|
-
isRulesetLike: function () {
|
|
5725
|
-
return this.rulesetLike;
|
|
5726
|
-
},
|
|
5727
|
-
genCSS: function (context, output) {
|
|
5728
|
-
this.nodeVisible = Boolean(this.value);
|
|
5729
|
-
if (this.nodeVisible) {
|
|
5730
|
-
output.add(this.value, this._fileInfo, this._index, this.mapLines);
|
|
5731
|
-
}
|
|
5732
|
-
}
|
|
5733
|
-
});
|
|
5734
|
-
|
|
5735
5847
|
var MATH$1 = Math$1;
|
|
5736
5848
|
function evalName(context, name) {
|
|
5737
5849
|
var value = '';
|
|
@@ -6627,179 +6739,32 @@
|
|
|
6627
6739
|
}
|
|
6628
6740
|
});
|
|
6629
6741
|
|
|
6630
|
-
var
|
|
6631
|
-
|
|
6632
|
-
this.
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
else {
|
|
6639
|
-
this.rules = [rules];
|
|
6640
|
-
this.rules[0].selectors = (new Selector([], null, null, index, currentFileInfo)).createEmptySelectors();
|
|
6641
|
-
}
|
|
6642
|
-
for (i = 0; i < this.rules.length; i++) {
|
|
6643
|
-
this.rules[i].allowImports = true;
|
|
6644
|
-
}
|
|
6645
|
-
this.setParent(this.rules, this);
|
|
6742
|
+
var Unit = function (numerator, denominator, backupUnit) {
|
|
6743
|
+
this.numerator = numerator ? copyArray(numerator).sort() : [];
|
|
6744
|
+
this.denominator = denominator ? copyArray(denominator).sort() : [];
|
|
6745
|
+
if (backupUnit) {
|
|
6746
|
+
this.backupUnit = backupUnit;
|
|
6747
|
+
}
|
|
6748
|
+
else if (numerator && numerator.length) {
|
|
6749
|
+
this.backupUnit = numerator[0];
|
|
6646
6750
|
}
|
|
6647
|
-
this._index = index;
|
|
6648
|
-
this._fileInfo = currentFileInfo;
|
|
6649
|
-
this.debugInfo = debugInfo;
|
|
6650
|
-
this.isRooted = isRooted || false;
|
|
6651
|
-
this.copyVisibilityInfo(visibilityInfo);
|
|
6652
|
-
this.allowRoot = true;
|
|
6653
6751
|
};
|
|
6654
|
-
|
|
6655
|
-
type: '
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
if (rules) {
|
|
6659
|
-
this.rules = visitor.visitArray(rules);
|
|
6660
|
-
}
|
|
6661
|
-
if (value) {
|
|
6662
|
-
this.value = visitor.visit(value);
|
|
6663
|
-
}
|
|
6664
|
-
},
|
|
6665
|
-
isRulesetLike: function () {
|
|
6666
|
-
return this.rules || !this.isCharset();
|
|
6667
|
-
},
|
|
6668
|
-
isCharset: function () {
|
|
6669
|
-
return '@charset' === this.name;
|
|
6752
|
+
Unit.prototype = Object.assign(new Node(), {
|
|
6753
|
+
type: 'Unit',
|
|
6754
|
+
clone: function () {
|
|
6755
|
+
return new Unit(copyArray(this.numerator), copyArray(this.denominator), this.backupUnit);
|
|
6670
6756
|
},
|
|
6671
6757
|
genCSS: function (context, output) {
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
if (
|
|
6675
|
-
output.add(
|
|
6676
|
-
value.genCSS(context, output);
|
|
6758
|
+
// Dimension checks the unit is singular and throws an error if in strict math mode.
|
|
6759
|
+
var strictUnits = context && context.strictUnits;
|
|
6760
|
+
if (this.numerator.length === 1) {
|
|
6761
|
+
output.add(this.numerator[0]); // the ideal situation
|
|
6677
6762
|
}
|
|
6678
|
-
if (
|
|
6679
|
-
this.
|
|
6763
|
+
else if (!strictUnits && this.backupUnit) {
|
|
6764
|
+
output.add(this.backupUnit);
|
|
6680
6765
|
}
|
|
6681
|
-
else {
|
|
6682
|
-
output.add(
|
|
6683
|
-
}
|
|
6684
|
-
},
|
|
6685
|
-
eval: function (context) {
|
|
6686
|
-
var mediaPathBackup, mediaBlocksBackup, value = this.value, rules = this.rules;
|
|
6687
|
-
// media stored inside other atrule should not bubble over it
|
|
6688
|
-
// backpup media bubbling information
|
|
6689
|
-
mediaPathBackup = context.mediaPath;
|
|
6690
|
-
mediaBlocksBackup = context.mediaBlocks;
|
|
6691
|
-
// deleted media bubbling information
|
|
6692
|
-
context.mediaPath = [];
|
|
6693
|
-
context.mediaBlocks = [];
|
|
6694
|
-
if (value) {
|
|
6695
|
-
value = value.eval(context);
|
|
6696
|
-
}
|
|
6697
|
-
if (rules) {
|
|
6698
|
-
// assuming that there is only one rule at this point - that is how parser constructs the rule
|
|
6699
|
-
rules = [rules[0].eval(context)];
|
|
6700
|
-
rules[0].root = true;
|
|
6701
|
-
}
|
|
6702
|
-
// restore media bubbling information
|
|
6703
|
-
context.mediaPath = mediaPathBackup;
|
|
6704
|
-
context.mediaBlocks = mediaBlocksBackup;
|
|
6705
|
-
return new AtRule(this.name, value, rules, this.getIndex(), this.fileInfo(), this.debugInfo, this.isRooted, this.visibilityInfo());
|
|
6706
|
-
},
|
|
6707
|
-
variable: function (name) {
|
|
6708
|
-
if (this.rules) {
|
|
6709
|
-
// assuming that there is only one rule at this point - that is how parser constructs the rule
|
|
6710
|
-
return Ruleset.prototype.variable.call(this.rules[0], name);
|
|
6711
|
-
}
|
|
6712
|
-
},
|
|
6713
|
-
find: function () {
|
|
6714
|
-
if (this.rules) {
|
|
6715
|
-
// assuming that there is only one rule at this point - that is how parser constructs the rule
|
|
6716
|
-
return Ruleset.prototype.find.apply(this.rules[0], arguments);
|
|
6717
|
-
}
|
|
6718
|
-
},
|
|
6719
|
-
rulesets: function () {
|
|
6720
|
-
if (this.rules) {
|
|
6721
|
-
// assuming that there is only one rule at this point - that is how parser constructs the rule
|
|
6722
|
-
return Ruleset.prototype.rulesets.apply(this.rules[0]);
|
|
6723
|
-
}
|
|
6724
|
-
},
|
|
6725
|
-
outputRuleset: function (context, output, rules) {
|
|
6726
|
-
var ruleCnt = rules.length;
|
|
6727
|
-
var i;
|
|
6728
|
-
context.tabLevel = (context.tabLevel | 0) + 1;
|
|
6729
|
-
// Compressed
|
|
6730
|
-
if (context.compress) {
|
|
6731
|
-
output.add('{');
|
|
6732
|
-
for (i = 0; i < ruleCnt; i++) {
|
|
6733
|
-
rules[i].genCSS(context, output);
|
|
6734
|
-
}
|
|
6735
|
-
output.add('}');
|
|
6736
|
-
context.tabLevel--;
|
|
6737
|
-
return;
|
|
6738
|
-
}
|
|
6739
|
-
// Non-compressed
|
|
6740
|
-
var tabSetStr = "\n".concat(Array(context.tabLevel).join(' ')), tabRuleStr = "".concat(tabSetStr, " ");
|
|
6741
|
-
if (!ruleCnt) {
|
|
6742
|
-
output.add(" {".concat(tabSetStr, "}"));
|
|
6743
|
-
}
|
|
6744
|
-
else {
|
|
6745
|
-
output.add(" {".concat(tabRuleStr));
|
|
6746
|
-
rules[0].genCSS(context, output);
|
|
6747
|
-
for (i = 1; i < ruleCnt; i++) {
|
|
6748
|
-
output.add(tabRuleStr);
|
|
6749
|
-
rules[i].genCSS(context, output);
|
|
6750
|
-
}
|
|
6751
|
-
output.add("".concat(tabSetStr, "}"));
|
|
6752
|
-
}
|
|
6753
|
-
context.tabLevel--;
|
|
6754
|
-
}
|
|
6755
|
-
});
|
|
6756
|
-
|
|
6757
|
-
var DetachedRuleset = function (ruleset, frames) {
|
|
6758
|
-
this.ruleset = ruleset;
|
|
6759
|
-
this.frames = frames;
|
|
6760
|
-
this.setParent(this.ruleset, this);
|
|
6761
|
-
};
|
|
6762
|
-
DetachedRuleset.prototype = Object.assign(new Node(), {
|
|
6763
|
-
type: 'DetachedRuleset',
|
|
6764
|
-
evalFirst: true,
|
|
6765
|
-
accept: function (visitor) {
|
|
6766
|
-
this.ruleset = visitor.visit(this.ruleset);
|
|
6767
|
-
},
|
|
6768
|
-
eval: function (context) {
|
|
6769
|
-
var frames = this.frames || copyArray(context.frames);
|
|
6770
|
-
return new DetachedRuleset(this.ruleset, frames);
|
|
6771
|
-
},
|
|
6772
|
-
callEval: function (context) {
|
|
6773
|
-
return this.ruleset.eval(this.frames ? new contexts.Eval(context, this.frames.concat(context.frames)) : context);
|
|
6774
|
-
}
|
|
6775
|
-
});
|
|
6776
|
-
|
|
6777
|
-
var Unit = function (numerator, denominator, backupUnit) {
|
|
6778
|
-
this.numerator = numerator ? copyArray(numerator).sort() : [];
|
|
6779
|
-
this.denominator = denominator ? copyArray(denominator).sort() : [];
|
|
6780
|
-
if (backupUnit) {
|
|
6781
|
-
this.backupUnit = backupUnit;
|
|
6782
|
-
}
|
|
6783
|
-
else if (numerator && numerator.length) {
|
|
6784
|
-
this.backupUnit = numerator[0];
|
|
6785
|
-
}
|
|
6786
|
-
};
|
|
6787
|
-
Unit.prototype = Object.assign(new Node(), {
|
|
6788
|
-
type: 'Unit',
|
|
6789
|
-
clone: function () {
|
|
6790
|
-
return new Unit(copyArray(this.numerator), copyArray(this.denominator), this.backupUnit);
|
|
6791
|
-
},
|
|
6792
|
-
genCSS: function (context, output) {
|
|
6793
|
-
// Dimension checks the unit is singular and throws an error if in strict math mode.
|
|
6794
|
-
var strictUnits = context && context.strictUnits;
|
|
6795
|
-
if (this.numerator.length === 1) {
|
|
6796
|
-
output.add(this.numerator[0]); // the ideal situation
|
|
6797
|
-
}
|
|
6798
|
-
else if (!strictUnits && this.backupUnit) {
|
|
6799
|
-
output.add(this.backupUnit);
|
|
6800
|
-
}
|
|
6801
|
-
else if (!strictUnits && this.denominator.length) {
|
|
6802
|
-
output.add(this.denominator[0]);
|
|
6766
|
+
else if (!strictUnits && this.denominator.length) {
|
|
6767
|
+
output.add(this.denominator[0]);
|
|
6803
6768
|
}
|
|
6804
6769
|
},
|
|
6805
6770
|
toString: function () {
|
|
@@ -6980,61 +6945,444 @@
|
|
|
6980
6945
|
if (!(other instanceof Dimension)) {
|
|
6981
6946
|
return undefined;
|
|
6982
6947
|
}
|
|
6983
|
-
if (this.unit.isEmpty() || other.unit.isEmpty()) {
|
|
6984
|
-
a = this;
|
|
6985
|
-
b = other;
|
|
6948
|
+
if (this.unit.isEmpty() || other.unit.isEmpty()) {
|
|
6949
|
+
a = this;
|
|
6950
|
+
b = other;
|
|
6951
|
+
}
|
|
6952
|
+
else {
|
|
6953
|
+
a = this.unify();
|
|
6954
|
+
b = other.unify();
|
|
6955
|
+
if (a.unit.compare(b.unit) !== 0) {
|
|
6956
|
+
return undefined;
|
|
6957
|
+
}
|
|
6958
|
+
}
|
|
6959
|
+
return Node.numericCompare(a.value, b.value);
|
|
6960
|
+
},
|
|
6961
|
+
unify: function () {
|
|
6962
|
+
return this.convertTo({ length: 'px', duration: 's', angle: 'rad' });
|
|
6963
|
+
},
|
|
6964
|
+
convertTo: function (conversions) {
|
|
6965
|
+
var value = this.value;
|
|
6966
|
+
var unit = this.unit.clone();
|
|
6967
|
+
var i;
|
|
6968
|
+
var groupName;
|
|
6969
|
+
var group;
|
|
6970
|
+
var targetUnit;
|
|
6971
|
+
var derivedConversions = {};
|
|
6972
|
+
var applyUnit;
|
|
6973
|
+
if (typeof conversions === 'string') {
|
|
6974
|
+
for (i in unitConversions) {
|
|
6975
|
+
if (unitConversions[i].hasOwnProperty(conversions)) {
|
|
6976
|
+
derivedConversions = {};
|
|
6977
|
+
derivedConversions[i] = conversions;
|
|
6978
|
+
}
|
|
6979
|
+
}
|
|
6980
|
+
conversions = derivedConversions;
|
|
6981
|
+
}
|
|
6982
|
+
applyUnit = function (atomicUnit, denominator) {
|
|
6983
|
+
if (group.hasOwnProperty(atomicUnit)) {
|
|
6984
|
+
if (denominator) {
|
|
6985
|
+
value = value / (group[atomicUnit] / group[targetUnit]);
|
|
6986
|
+
}
|
|
6987
|
+
else {
|
|
6988
|
+
value = value * (group[atomicUnit] / group[targetUnit]);
|
|
6989
|
+
}
|
|
6990
|
+
return targetUnit;
|
|
6991
|
+
}
|
|
6992
|
+
return atomicUnit;
|
|
6993
|
+
};
|
|
6994
|
+
for (groupName in conversions) {
|
|
6995
|
+
if (conversions.hasOwnProperty(groupName)) {
|
|
6996
|
+
targetUnit = conversions[groupName];
|
|
6997
|
+
group = unitConversions[groupName];
|
|
6998
|
+
unit.map(applyUnit);
|
|
6999
|
+
}
|
|
7000
|
+
}
|
|
7001
|
+
unit.cancel();
|
|
7002
|
+
return new Dimension(value, unit);
|
|
7003
|
+
}
|
|
7004
|
+
});
|
|
7005
|
+
|
|
7006
|
+
var Expression = function (value, noSpacing) {
|
|
7007
|
+
this.value = value;
|
|
7008
|
+
this.noSpacing = noSpacing;
|
|
7009
|
+
if (!value) {
|
|
7010
|
+
throw new Error('Expression requires an array parameter');
|
|
7011
|
+
}
|
|
7012
|
+
};
|
|
7013
|
+
Expression.prototype = Object.assign(new Node(), {
|
|
7014
|
+
type: 'Expression',
|
|
7015
|
+
accept: function (visitor) {
|
|
7016
|
+
this.value = visitor.visitArray(this.value);
|
|
7017
|
+
},
|
|
7018
|
+
eval: function (context) {
|
|
7019
|
+
var returnValue;
|
|
7020
|
+
var mathOn = context.isMathOn();
|
|
7021
|
+
var inParenthesis = this.parens;
|
|
7022
|
+
var doubleParen = false;
|
|
7023
|
+
if (inParenthesis) {
|
|
7024
|
+
context.inParenthesis();
|
|
7025
|
+
}
|
|
7026
|
+
if (this.value.length > 1) {
|
|
7027
|
+
returnValue = new Expression(this.value.map(function (e) {
|
|
7028
|
+
if (!e.eval) {
|
|
7029
|
+
return e;
|
|
7030
|
+
}
|
|
7031
|
+
return e.eval(context);
|
|
7032
|
+
}), this.noSpacing);
|
|
7033
|
+
}
|
|
7034
|
+
else if (this.value.length === 1) {
|
|
7035
|
+
if (this.value[0].parens && !this.value[0].parensInOp && !context.inCalc) {
|
|
7036
|
+
doubleParen = true;
|
|
7037
|
+
}
|
|
7038
|
+
returnValue = this.value[0].eval(context);
|
|
7039
|
+
}
|
|
7040
|
+
else {
|
|
7041
|
+
returnValue = this;
|
|
7042
|
+
}
|
|
7043
|
+
if (inParenthesis) {
|
|
7044
|
+
context.outOfParenthesis();
|
|
7045
|
+
}
|
|
7046
|
+
if (this.parens && this.parensInOp && !mathOn && !doubleParen
|
|
7047
|
+
&& (!(returnValue instanceof Dimension))) {
|
|
7048
|
+
returnValue = new Paren(returnValue);
|
|
7049
|
+
}
|
|
7050
|
+
return returnValue;
|
|
7051
|
+
},
|
|
7052
|
+
genCSS: function (context, output) {
|
|
7053
|
+
for (var i_1 = 0; i_1 < this.value.length; i_1++) {
|
|
7054
|
+
this.value[i_1].genCSS(context, output);
|
|
7055
|
+
if (!this.noSpacing && i_1 + 1 < this.value.length) {
|
|
7056
|
+
if (i_1 + 1 < this.value.length && !(this.value[i_1 + 1] instanceof Anonymous) ||
|
|
7057
|
+
this.value[i_1 + 1] instanceof Anonymous && this.value[i_1 + 1].value !== ',') {
|
|
7058
|
+
output.add(' ');
|
|
7059
|
+
}
|
|
7060
|
+
}
|
|
7061
|
+
}
|
|
7062
|
+
},
|
|
7063
|
+
throwAwayComments: function () {
|
|
7064
|
+
this.value = this.value.filter(function (v) {
|
|
7065
|
+
return !(v instanceof Comment);
|
|
7066
|
+
});
|
|
7067
|
+
}
|
|
7068
|
+
});
|
|
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, "}"));
|
|
6986
7356
|
}
|
|
6987
7357
|
else {
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
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);
|
|
6992
7363
|
}
|
|
7364
|
+
output.add("".concat(tabSetStr, "}"));
|
|
6993
7365
|
}
|
|
6994
|
-
|
|
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);
|
|
6995
7379
|
},
|
|
6996
|
-
|
|
6997
|
-
|
|
7380
|
+
eval: function (context) {
|
|
7381
|
+
var frames = this.frames || copyArray(context.frames);
|
|
7382
|
+
return new DetachedRuleset(this.ruleset, frames);
|
|
6998
7383
|
},
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
var unit = this.unit.clone();
|
|
7002
|
-
var i;
|
|
7003
|
-
var groupName;
|
|
7004
|
-
var group;
|
|
7005
|
-
var targetUnit;
|
|
7006
|
-
var derivedConversions = {};
|
|
7007
|
-
var applyUnit;
|
|
7008
|
-
if (typeof conversions === 'string') {
|
|
7009
|
-
for (i in unitConversions) {
|
|
7010
|
-
if (unitConversions[i].hasOwnProperty(conversions)) {
|
|
7011
|
-
derivedConversions = {};
|
|
7012
|
-
derivedConversions[i] = conversions;
|
|
7013
|
-
}
|
|
7014
|
-
}
|
|
7015
|
-
conversions = derivedConversions;
|
|
7016
|
-
}
|
|
7017
|
-
applyUnit = function (atomicUnit, denominator) {
|
|
7018
|
-
if (group.hasOwnProperty(atomicUnit)) {
|
|
7019
|
-
if (denominator) {
|
|
7020
|
-
value = value / (group[atomicUnit] / group[targetUnit]);
|
|
7021
|
-
}
|
|
7022
|
-
else {
|
|
7023
|
-
value = value * (group[atomicUnit] / group[targetUnit]);
|
|
7024
|
-
}
|
|
7025
|
-
return targetUnit;
|
|
7026
|
-
}
|
|
7027
|
-
return atomicUnit;
|
|
7028
|
-
};
|
|
7029
|
-
for (groupName in conversions) {
|
|
7030
|
-
if (conversions.hasOwnProperty(groupName)) {
|
|
7031
|
-
targetUnit = conversions[groupName];
|
|
7032
|
-
group = unitConversions[groupName];
|
|
7033
|
-
unit.map(applyUnit);
|
|
7034
|
-
}
|
|
7035
|
-
}
|
|
7036
|
-
unit.cancel();
|
|
7037
|
-
return new Dimension(value, unit);
|
|
7384
|
+
callEval: function (context) {
|
|
7385
|
+
return this.ruleset.eval(this.frames ? new contexts.Eval(context, this.frames.concat(context.frames)) : context);
|
|
7038
7386
|
}
|
|
7039
7387
|
});
|
|
7040
7388
|
|
|
@@ -7086,70 +7434,6 @@
|
|
|
7086
7434
|
}
|
|
7087
7435
|
});
|
|
7088
7436
|
|
|
7089
|
-
var Expression = function (value, noSpacing) {
|
|
7090
|
-
this.value = value;
|
|
7091
|
-
this.noSpacing = noSpacing;
|
|
7092
|
-
if (!value) {
|
|
7093
|
-
throw new Error('Expression requires an array parameter');
|
|
7094
|
-
}
|
|
7095
|
-
};
|
|
7096
|
-
Expression.prototype = Object.assign(new Node(), {
|
|
7097
|
-
type: 'Expression',
|
|
7098
|
-
accept: function (visitor) {
|
|
7099
|
-
this.value = visitor.visitArray(this.value);
|
|
7100
|
-
},
|
|
7101
|
-
eval: function (context) {
|
|
7102
|
-
var returnValue;
|
|
7103
|
-
var mathOn = context.isMathOn();
|
|
7104
|
-
var inParenthesis = this.parens;
|
|
7105
|
-
var doubleParen = false;
|
|
7106
|
-
if (inParenthesis) {
|
|
7107
|
-
context.inParenthesis();
|
|
7108
|
-
}
|
|
7109
|
-
if (this.value.length > 1) {
|
|
7110
|
-
returnValue = new Expression(this.value.map(function (e) {
|
|
7111
|
-
if (!e.eval) {
|
|
7112
|
-
return e;
|
|
7113
|
-
}
|
|
7114
|
-
return e.eval(context);
|
|
7115
|
-
}), this.noSpacing);
|
|
7116
|
-
}
|
|
7117
|
-
else if (this.value.length === 1) {
|
|
7118
|
-
if (this.value[0].parens && !this.value[0].parensInOp && !context.inCalc) {
|
|
7119
|
-
doubleParen = true;
|
|
7120
|
-
}
|
|
7121
|
-
returnValue = this.value[0].eval(context);
|
|
7122
|
-
}
|
|
7123
|
-
else {
|
|
7124
|
-
returnValue = this;
|
|
7125
|
-
}
|
|
7126
|
-
if (inParenthesis) {
|
|
7127
|
-
context.outOfParenthesis();
|
|
7128
|
-
}
|
|
7129
|
-
if (this.parens && this.parensInOp && !mathOn && !doubleParen
|
|
7130
|
-
&& (!(returnValue instanceof Dimension))) {
|
|
7131
|
-
returnValue = new Paren(returnValue);
|
|
7132
|
-
}
|
|
7133
|
-
return returnValue;
|
|
7134
|
-
},
|
|
7135
|
-
genCSS: function (context, output) {
|
|
7136
|
-
for (var i_1 = 0; i_1 < this.value.length; i_1++) {
|
|
7137
|
-
this.value[i_1].genCSS(context, output);
|
|
7138
|
-
if (!this.noSpacing && i_1 + 1 < this.value.length) {
|
|
7139
|
-
if (i_1 + 1 < this.value.length && !(this.value[i_1 + 1] instanceof Anonymous) ||
|
|
7140
|
-
this.value[i_1 + 1] instanceof Anonymous && this.value[i_1 + 1].value !== ',') {
|
|
7141
|
-
output.add(' ');
|
|
7142
|
-
}
|
|
7143
|
-
}
|
|
7144
|
-
}
|
|
7145
|
-
},
|
|
7146
|
-
throwAwayComments: function () {
|
|
7147
|
-
this.value = this.value.filter(function (v) {
|
|
7148
|
-
return !(v instanceof Comment);
|
|
7149
|
-
});
|
|
7150
|
-
}
|
|
7151
|
-
});
|
|
7152
|
-
|
|
7153
7437
|
var functionCaller = /** @class */ (function () {
|
|
7154
7438
|
function functionCaller(name, context, index, currentFileInfo) {
|
|
7155
7439
|
this.name = name.toLowerCase();
|
|
@@ -7466,12 +7750,12 @@
|
|
|
7466
7750
|
eval: function (context) {
|
|
7467
7751
|
var that = this;
|
|
7468
7752
|
var value = this.value;
|
|
7469
|
-
var variableReplacement = function (_,
|
|
7470
|
-
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);
|
|
7471
7755
|
return (v instanceof Quoted) ? v.value : v.toCSS();
|
|
7472
7756
|
};
|
|
7473
|
-
var propertyReplacement = function (_,
|
|
7474
|
-
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);
|
|
7475
7759
|
return (v instanceof Quoted) ? v.value : v.toCSS();
|
|
7476
7760
|
};
|
|
7477
7761
|
function iterativeReplace(value, regexp, replacementFnc) {
|
|
@@ -7551,87 +7835,6 @@
|
|
|
7551
7835
|
}
|
|
7552
7836
|
});
|
|
7553
7837
|
|
|
7554
|
-
var NestableAtRulePrototype = {
|
|
7555
|
-
isRulesetLike: function () {
|
|
7556
|
-
return true;
|
|
7557
|
-
},
|
|
7558
|
-
accept: function (visitor) {
|
|
7559
|
-
if (this.features) {
|
|
7560
|
-
this.features = visitor.visit(this.features);
|
|
7561
|
-
}
|
|
7562
|
-
if (this.rules) {
|
|
7563
|
-
this.rules = visitor.visitArray(this.rules);
|
|
7564
|
-
}
|
|
7565
|
-
},
|
|
7566
|
-
evalTop: function (context) {
|
|
7567
|
-
var result = this;
|
|
7568
|
-
// Render all dependent Media blocks.
|
|
7569
|
-
if (context.mediaBlocks.length > 1) {
|
|
7570
|
-
var selectors = (new Selector([], null, null, this.getIndex(), this.fileInfo())).createEmptySelectors();
|
|
7571
|
-
result = new Ruleset(selectors, context.mediaBlocks);
|
|
7572
|
-
result.multiMedia = true;
|
|
7573
|
-
result.copyVisibilityInfo(this.visibilityInfo());
|
|
7574
|
-
this.setParent(result, this);
|
|
7575
|
-
}
|
|
7576
|
-
delete context.mediaBlocks;
|
|
7577
|
-
delete context.mediaPath;
|
|
7578
|
-
return result;
|
|
7579
|
-
},
|
|
7580
|
-
evalNested: function (context) {
|
|
7581
|
-
var i;
|
|
7582
|
-
var value;
|
|
7583
|
-
var path = context.mediaPath.concat([this]);
|
|
7584
|
-
// Extract the media-query conditions separated with `,` (OR).
|
|
7585
|
-
for (i = 0; i < path.length; i++) {
|
|
7586
|
-
value = path[i].features instanceof Value ?
|
|
7587
|
-
path[i].features.value : path[i].features;
|
|
7588
|
-
path[i] = Array.isArray(value) ? value : [value];
|
|
7589
|
-
}
|
|
7590
|
-
// Trace all permutations to generate the resulting media-query.
|
|
7591
|
-
//
|
|
7592
|
-
// (a, b and c) with nested (d, e) ->
|
|
7593
|
-
// a and d
|
|
7594
|
-
// a and e
|
|
7595
|
-
// b and c and d
|
|
7596
|
-
// b and c and e
|
|
7597
|
-
this.features = new Value(this.permute(path).map(function (path) {
|
|
7598
|
-
path = path.map(function (fragment) { return fragment.toCSS ? fragment : new Anonymous(fragment); });
|
|
7599
|
-
for (i = path.length - 1; i > 0; i--) {
|
|
7600
|
-
path.splice(i, 0, new Anonymous('and'));
|
|
7601
|
-
}
|
|
7602
|
-
return new Expression(path);
|
|
7603
|
-
}));
|
|
7604
|
-
this.setParent(this.features, this);
|
|
7605
|
-
// Fake a tree-node that doesn't output anything.
|
|
7606
|
-
return new Ruleset([], []);
|
|
7607
|
-
},
|
|
7608
|
-
permute: function (arr) {
|
|
7609
|
-
if (arr.length === 0) {
|
|
7610
|
-
return [];
|
|
7611
|
-
}
|
|
7612
|
-
else if (arr.length === 1) {
|
|
7613
|
-
return arr[0];
|
|
7614
|
-
}
|
|
7615
|
-
else {
|
|
7616
|
-
var result = [];
|
|
7617
|
-
var rest = this.permute(arr.slice(1));
|
|
7618
|
-
for (var i_1 = 0; i_1 < rest.length; i_1++) {
|
|
7619
|
-
for (var j = 0; j < arr[0].length; j++) {
|
|
7620
|
-
result.push([arr[0][j]].concat(rest[i_1]));
|
|
7621
|
-
}
|
|
7622
|
-
}
|
|
7623
|
-
return result;
|
|
7624
|
-
}
|
|
7625
|
-
},
|
|
7626
|
-
bubbleSelectors: function (selectors) {
|
|
7627
|
-
if (!selectors) {
|
|
7628
|
-
return;
|
|
7629
|
-
}
|
|
7630
|
-
this.rules = [new Ruleset(copyArray(selectors), [this.rules[0]])];
|
|
7631
|
-
this.setParent(this.rules, this);
|
|
7632
|
-
}
|
|
7633
|
-
};
|
|
7634
|
-
|
|
7635
7838
|
var Media = function (value, features, index, currentFileInfo, visibilityInfo) {
|
|
7636
7839
|
this._index = index;
|
|
7637
7840
|
this._fileInfo = currentFileInfo;
|
|
@@ -7978,6 +8181,7 @@
|
|
|
7978
8181
|
this.op2 = op2 ? op2.trim() : null;
|
|
7979
8182
|
this.rvalue = r;
|
|
7980
8183
|
this._index = i;
|
|
8184
|
+
this.mvalues = [];
|
|
7981
8185
|
};
|
|
7982
8186
|
QueryInParens.prototype = Object.assign(new Node(), {
|
|
7983
8187
|
type: 'QueryInParens',
|
|
@@ -7990,7 +8194,32 @@
|
|
|
7990
8194
|
},
|
|
7991
8195
|
eval: function (context) {
|
|
7992
8196
|
this.lvalue = this.lvalue.eval(context);
|
|
7993
|
-
|
|
8197
|
+
var variableDeclaration;
|
|
8198
|
+
var rule;
|
|
8199
|
+
for (var i_1 = 0; (rule = context.frames[i_1]); i_1++) {
|
|
8200
|
+
if (rule.type === 'Ruleset') {
|
|
8201
|
+
variableDeclaration = rule.rules.find(function (r) {
|
|
8202
|
+
if ((r instanceof Declaration) && r.variable) {
|
|
8203
|
+
return true;
|
|
8204
|
+
}
|
|
8205
|
+
return false;
|
|
8206
|
+
});
|
|
8207
|
+
if (variableDeclaration) {
|
|
8208
|
+
break;
|
|
8209
|
+
}
|
|
8210
|
+
}
|
|
8211
|
+
}
|
|
8212
|
+
if (!this.mvalueCopy) {
|
|
8213
|
+
this.mvalueCopy = copy(this.mvalue);
|
|
8214
|
+
}
|
|
8215
|
+
if (variableDeclaration) {
|
|
8216
|
+
this.mvalue = this.mvalueCopy;
|
|
8217
|
+
this.mvalue = this.mvalue.eval(context);
|
|
8218
|
+
this.mvalues.push(this.mvalue);
|
|
8219
|
+
}
|
|
8220
|
+
else {
|
|
8221
|
+
this.mvalue = this.mvalue.eval(context);
|
|
8222
|
+
}
|
|
7994
8223
|
if (this.rvalue) {
|
|
7995
8224
|
this.rvalue = this.rvalue.eval(context);
|
|
7996
8225
|
}
|
|
@@ -7999,6 +8228,9 @@
|
|
|
7999
8228
|
genCSS: function (context, output) {
|
|
8000
8229
|
this.lvalue.genCSS(context, output);
|
|
8001
8230
|
output.add(' ' + this.op + ' ');
|
|
8231
|
+
if (this.mvalues.length > 0) {
|
|
8232
|
+
this.mvalue = this.mvalues.shift();
|
|
8233
|
+
}
|
|
8002
8234
|
this.mvalue.genCSS(context, output);
|
|
8003
8235
|
if (this.rvalue) {
|
|
8004
8236
|
output.add(' ' + this.op2 + ' ');
|
|
@@ -8080,6 +8312,7 @@
|
|
|
8080
8312
|
this.copyVisibilityInfo(visibilityInfo);
|
|
8081
8313
|
this.allowRoot = true;
|
|
8082
8314
|
switch (option) {
|
|
8315
|
+
case '!all':
|
|
8083
8316
|
case 'all':
|
|
8084
8317
|
this.allowBefore = true;
|
|
8085
8318
|
this.allowAfter = true;
|
|
@@ -10792,22 +11025,25 @@
|
|
|
10792
11025
|
return render;
|
|
10793
11026
|
}
|
|
10794
11027
|
|
|
10795
|
-
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
|
+
}
|
|
10796
11046
|
|
|
10797
|
-
function parseNodeVersion(version) {
|
|
10798
|
-
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
|
|
10799
|
-
if (!match) {
|
|
10800
|
-
throw new Error('Unable to parse: ' + version);
|
|
10801
|
-
}
|
|
10802
|
-
var res = {
|
|
10803
|
-
major: parseInt(match[1], 10),
|
|
10804
|
-
minor: parseInt(match[2], 10),
|
|
10805
|
-
patch: parseInt(match[3], 10),
|
|
10806
|
-
pre: match[4] || '',
|
|
10807
|
-
build: match[5] || '',
|
|
10808
|
-
};
|
|
10809
|
-
return res;
|
|
10810
|
-
}
|
|
10811
11047
|
var parseNodeVersion_1 = parseNodeVersion;
|
|
10812
11048
|
|
|
10813
11049
|
function lessRoot (environment, fileManagers) {
|