|
1 | 1 | /** |
2 | | - * Less - Leaner CSS v4.1.2 |
| 2 | + * Less - Leaner CSS v4.1.3 |
3 | 3 | * http://lesscss.org |
4 | 4 | * |
5 | | - * Copyright (c) 2009-2021, Alexis Sellier <[email protected]> |
| 5 | + * Copyright (c) 2009-2022, Alexis Sellier <[email protected]> |
6 | 6 | * Licensed under the Apache-2.0 License. |
7 | 7 | * |
8 | 8 | * @license Apache-2.0 |
|
80 | 80 | .replace(/\./g, ':'); // Replace dots with colons(for valid id) |
81 | 81 | } |
82 | 82 | function addDataAttr(options, tag) { |
| 83 | + if (!tag) { |
| 84 | + return; |
| 85 | + } // in case of tag is null or undefined |
83 | 86 | for (var opt in tag.dataset) { |
84 | 87 | if (tag.dataset.hasOwnProperty(opt)) { |
85 | 88 | if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') { |
|
1599 | 1602 | } |
1600 | 1603 | }); |
1601 | 1604 |
|
1602 | | - var debugInfo = /** @class */ (function () { |
1603 | | - function debugInfo(context, ctx, lineSeparator) { |
1604 | | - var result = ''; |
1605 | | - if (context.dumpLineNumbers && !context.compress) { |
1606 | | - switch (context.dumpLineNumbers) { |
1607 | | - case 'comments': |
1608 | | - result = debugInfo.asComment(ctx); |
1609 | | - break; |
1610 | | - case 'mediaquery': |
1611 | | - result = debugInfo.asMediaQuery(ctx); |
1612 | | - break; |
1613 | | - case 'all': |
1614 | | - result = debugInfo.asComment(ctx) + (lineSeparator || '') + debugInfo.asMediaQuery(ctx); |
1615 | | - break; |
1616 | | - } |
1617 | | - } |
1618 | | - return result; |
| 1605 | + function asComment(ctx) { |
| 1606 | + return "/* line " + ctx.debugInfo.lineNumber + ", " + ctx.debugInfo.fileName + " */\n"; |
| 1607 | + } |
| 1608 | + function asMediaQuery(ctx) { |
| 1609 | + var filenameWithProtocol = ctx.debugInfo.fileName; |
| 1610 | + if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) { |
| 1611 | + filenameWithProtocol = "file://" + filenameWithProtocol; |
1619 | 1612 | } |
1620 | | - debugInfo.asComment = function (ctx) { |
1621 | | - return "/* line " + ctx.debugInfo.lineNumber + ", " + ctx.debugInfo.fileName + " */\n"; |
1622 | | - }; |
1623 | | - debugInfo.asMediaQuery = function (ctx) { |
1624 | | - var filenameWithProtocol = ctx.debugInfo.fileName; |
1625 | | - if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) { |
1626 | | - filenameWithProtocol = "file://" + filenameWithProtocol; |
| 1613 | + return "@media -sass-debug-info{filename{font-family:" + filenameWithProtocol.replace(/([.:\/\\])/g, function (a) { |
| 1614 | + if (a == '\\') { |
| 1615 | + a = '\/'; |
1627 | 1616 | } |
1628 | | - return "@media -sass-debug-info{filename{font-family:" + filenameWithProtocol.replace(/([.:\/\\])/g, function (a) { |
1629 | | - if (a == '\\') { |
1630 | | - a = '\/'; |
1631 | | - } |
1632 | | - return "\\" + a; |
1633 | | - }) + "}line{font-family:\\00003" + ctx.debugInfo.lineNumber + "}}\n"; |
1634 | | - }; |
1635 | | - return debugInfo; |
1636 | | - }()); |
| 1617 | + return "\\" + a; |
| 1618 | + }) + "}line{font-family:\\00003" + ctx.debugInfo.lineNumber + "}}\n"; |
| 1619 | + } |
| 1620 | + function debugInfo(context, ctx, lineSeparator) { |
| 1621 | + var result = ''; |
| 1622 | + if (context.dumpLineNumbers && !context.compress) { |
| 1623 | + switch (context.dumpLineNumbers) { |
| 1624 | + case 'comments': |
| 1625 | + result = asComment(ctx); |
| 1626 | + break; |
| 1627 | + case 'mediaquery': |
| 1628 | + result = asMediaQuery(ctx); |
| 1629 | + break; |
| 1630 | + case 'all': |
| 1631 | + result = asComment(ctx) + (lineSeparator || '') + asMediaQuery(ctx); |
| 1632 | + break; |
| 1633 | + } |
| 1634 | + } |
| 1635 | + return result; |
| 1636 | + } |
1637 | 1637 |
|
1638 | 1638 | var Comment = function (value, isLineComment, index, currentFileInfo) { |
1639 | 1639 | this.value = value; |
|
3387 | 3387 | } |
3388 | 3388 | }); |
3389 | 3389 |
|
3390 | | - var Attribute = function (key, op, value) { |
| 3390 | + var Attribute = function (key, op, value, cif) { |
3391 | 3391 | this.key = key; |
3392 | 3392 | this.op = op; |
3393 | 3393 | this.value = value; |
| 3394 | + this.cif = cif; |
3394 | 3395 | }; |
3395 | 3396 | Attribute.prototype = Object.assign(new Node(), { |
3396 | 3397 | type: 'Attribute', |
3397 | 3398 | eval: function (context) { |
3398 | | - return new Attribute(this.key.eval ? this.key.eval(context) : this.key, this.op, (this.value && this.value.eval) ? this.value.eval(context) : this.value); |
| 3399 | + return new Attribute(this.key.eval ? this.key.eval(context) : this.key, this.op, (this.value && this.value.eval) ? this.value.eval(context) : this.value, this.cif); |
3399 | 3400 | }, |
3400 | 3401 | genCSS: function (context, output) { |
3401 | 3402 | output.add(this.toCSS(context)); |
|
3406 | 3407 | value += this.op; |
3407 | 3408 | value += (this.value.toCSS ? this.value.toCSS(context) : this.value); |
3408 | 3409 | } |
| 3410 | + if (this.cif) { |
| 3411 | + value = value + " " + this.cif; |
| 3412 | + } |
3409 | 3413 | return "[" + value + "]"; |
3410 | 3414 | } |
3411 | 3415 | }); |
|
6654 | 6658 | // |
6655 | 6659 | parse: function (str, callback, additionalData) { |
6656 | 6660 | var root; |
6657 | | - var error = null; |
| 6661 | + var err = null; |
6658 | 6662 | var globalVars; |
6659 | 6663 | var modifyVars; |
6660 | 6664 | var ignored; |
6661 | 6665 | var preText = ''; |
| 6666 | + // Optionally disable @plugin parsing |
| 6667 | + if (additionalData && additionalData.disablePluginRule) { |
| 6668 | + parsers.plugin = function () { |
| 6669 | + var dir = parserInput.$re(/^@plugin?\s+/); |
| 6670 | + if (dir) { |
| 6671 | + error('@plugin statements are not allowed when disablePluginRule is set to true'); |
| 6672 | + } |
| 6673 | + }; |
| 6674 | + } |
6662 | 6675 | globalVars = (additionalData && additionalData.globalVars) ? Parser.serializeVars(additionalData.globalVars) + "\n" : ''; |
6663 | 6676 | modifyVars = (additionalData && additionalData.modifyVars) ? "\n" + Parser.serializeVars(additionalData.modifyVars) : ''; |
6664 | 6677 | if (context.pluginManager) { |
|
6723 | 6736 | message += '. Possibly missing something'; |
6724 | 6737 | } |
6725 | 6738 | } |
6726 | | - error = new LessError({ |
| 6739 | + err = new LessError({ |
6727 | 6740 | type: 'Parse', |
6728 | 6741 | message: message, |
6729 | 6742 | index: endInfo.furthest, |
6730 | 6743 | filename: fileInfo.filename |
6731 | 6744 | }, imports); |
6732 | 6745 | } |
6733 | 6746 | var finish = function (e) { |
6734 | | - e = error || e || imports.error; |
| 6747 | + e = err || e || imports.error; |
6735 | 6748 | if (e) { |
6736 | 6749 | if (!(e instanceof LessError)) { |
6737 | 6750 | e = new LessError(e, imports, fileInfo.filename); |
|
7808 | 7821 | var key; |
7809 | 7822 | var val; |
7810 | 7823 | var op; |
| 7824 | + // |
| 7825 | + // case-insensitive flag |
| 7826 | + // e.g. [attr operator value i] |
| 7827 | + // |
| 7828 | + var cif; |
7811 | 7829 | if (!(key = entities.variableCurly())) { |
7812 | 7830 | key = expect(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/); |
7813 | 7831 | } |
7814 | 7832 | op = parserInput.$re(/^[|~*$^]?=/); |
7815 | 7833 | if (op) { |
7816 | 7834 | val = entities.quoted() || parserInput.$re(/^[0-9]+%/) || parserInput.$re(/^[\w-]+/) || entities.variableCurly(); |
| 7835 | + if (val) { |
| 7836 | + cif = parserInput.$re(/^[iIsS]/); |
| 7837 | + } |
7817 | 7838 | } |
7818 | 7839 | expectChar(']'); |
7819 | | - return new (tree.Attribute)(key, op, val); |
| 7840 | + return new (tree.Attribute)(key, op, val, cif); |
7820 | 7841 | }, |
7821 | 7842 | // |
7822 | 7843 | // The `block` rule is used by `ruleset` and `mixin.definition`. |
|
8063 | 8084 | var path; |
8064 | 8085 | var features; |
8065 | 8086 | var index = parserInput.i; |
8066 | | - var dir = parserInput.$re(/^@import?\s+/); |
| 8087 | + var dir = parserInput.$re(/^@import\s+/); |
8067 | 8088 | if (dir) { |
8068 | 8089 | var options = (dir ? this.importOptions() : null) || {}; |
8069 | 8090 | if ((path = this.entities.quoted() || this.entities.url())) { |
|
8214 | 8235 | var args; |
8215 | 8236 | var options; |
8216 | 8237 | var index = parserInput.i; |
8217 | | - var dir = parserInput.$re(/^@plugin?\s+/); |
| 8238 | + var dir = parserInput.$re(/^@plugin\s+/); |
8218 | 8239 | if (dir) { |
8219 | 8240 | args = this.pluginArgs(); |
8220 | 8241 | if (args) { |
|
10575 | 10596 | return render; |
10576 | 10597 | } |
10577 | 10598 |
|
10578 | | - var version = "4.1.2"; |
| 10599 | + var version = "4.1.3"; |
10579 | 10600 |
|
10580 | 10601 | function parseNodeVersion(version) { |
10581 | 10602 | 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 |
|
0 commit comments