Skip to content

Commit 97f7082

Browse files
joeyparrishlumburr
authored andcommitted
fix: Fix https failures on macOS (less#3716)
The issue was traced upstream to needle, and resolved in: - tomas/needle#392 - tomas/needle#394 - tomas/needle#396 - tomas/needle#398 Closes less#3693
1 parent 3f05b5c commit 97f7082

File tree

6 files changed

+73
-13
lines changed

6 files changed

+73
-13
lines changed

packages/less/package-lock.json

+15-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/less/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"image-size": "~0.5.0",
5151
"make-dir": "^2.1.0",
5252
"mime": "^1.4.1",
53-
"needle": "^2.5.2",
53+
"needle": "^3.1.0",
5454
"source-map": "~0.6.0"
5555
},
5656
"devDependencies": {

packages/less/src/less/tree/ruleset.js

+24-7
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ Ruleset.prototype = Object.assign(new Node(), {
8181
}
8282
this.parse.parseNode(
8383
toParseSelectors.join(','),
84-
["selectors"],
85-
selectors[0].getIndex(),
86-
selectors[0].fileInfo(),
84+
["selectors"],
85+
selectors[0].getIndex(),
86+
selectors[0].fileInfo(),
8787
function(err, result) {
8888
if (result) {
8989
selectors = utils.flattenArray(result);
@@ -230,17 +230,34 @@ Ruleset.prototype = Object.assign(new Node(), {
230230
let i;
231231
let importRules;
232232
if (!rules) { return; }
233-
233+
const importDecl = {};
234234
for (i = 0; i < rules.length; i++) {
235235
if (rules[i].type === 'Import') {
236236
importRules = rules[i].eval(context);
237237
if (importRules && (importRules.length || importRules.length === 0)) {
238+
// fix: #3563
239+
importRules.forEach((node, index) => {
240+
if (node instanceof Declaration) {
241+
if (!importDecl[node.name]) {
242+
importDecl[node.name] = [i + index]
243+
} else {
244+
importDecl[node.name].push(i + index)
245+
}
246+
}
247+
})
238248
rules.splice.apply(rules, [i, 1].concat(importRules));
239249
i += importRules.length - 1;
240250
} else {
241251
rules.splice(i, 1, importRules);
242252
}
243253
this.resetCache();
254+
} else if (rules[i] instanceof Declaration && importDecl[rules[i].name]) {
255+
const name = rules[i].name
256+
importDecl[name].forEach(e => {
257+
if (rules[e].name === name) {
258+
rules[e].value = rules[i].value
259+
}
260+
})
244261
}
245262
}
246263
},
@@ -356,9 +373,9 @@ Ruleset.prototype = Object.assign(new Node(), {
356373
if (typeof decl.value.value === 'string') {
357374
this.parse.parseNode(
358375
decl.value.value,
359-
['value', 'important'],
360-
decl.value.getIndex(),
361-
decl.fileInfo(),
376+
['value', 'important'],
377+
decl.value.getIndex(),
378+
decl.fileInfo(),
362379
function(err, result) {
363380
if (err) {
364381
decl.parsed = true;

packages/test-data/css/_main/import.css

+12
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,15 @@
4747
width: 100%;
4848
}
4949
}
50+
.some-class {
51+
color: var(--primary-color);
52+
backgroundColor: var(--bg-color);
53+
}
54+
:root {
55+
--primary-color: #fff;
56+
--bg-color: #000;
57+
}
58+
html[data-theme="dark"] {
59+
--primary-color: #000;
60+
--bg-color: #fff;
61+
}

packages/test-data/less/_main/import.less

+14
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,17 @@
3030

3131
@charset "UTF-8"; // climb on top #2126
3232

33+
// #3563
34+
@import "import/import-style.less";
35+
@base-color: var(--primary-color);
36+
@dark-color: var(--bg-color);
37+
38+
:root {
39+
--primary-color: #fff;
40+
--bg-color: #000;
41+
}
42+
43+
html[data-theme="dark"] {
44+
--primary-color: #000;
45+
--bg-color: #fff;
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@base-color: green;
2+
@dark-color: darken(@base-color, 50%);
3+
4+
.some-class {
5+
color: @base-color;
6+
backgroundColor: @dark-color;
7+
}

0 commit comments

Comments
 (0)