Skip to content

Commit aeca875

Browse files
committed
restore compat with extremely old node versions
1 parent f0a2de2 commit aeca875

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

index.js

+28-27
Original file line numberDiff line numberDiff line change
@@ -24,50 +24,51 @@ module.exports = function resolveNestedSelector(selector, node) {
2424
return resolvedSelectors;
2525
}
2626

27+
var blockPairs = {
28+
'(': ')',
29+
'[': ']',
30+
'{': '}'
31+
};
32+
2733
function split(string, separator, splitFunctions) {
28-
var blockPairs = {
29-
'(': ')',
30-
'[': ']',
31-
'{': '}'
32-
}
33-
var array = []
34-
var current = ''
35-
var split = false
34+
var array = [];
35+
var current = '';
36+
var split = false;
3637

37-
var blockClose = []
38-
var inQuote = false
39-
var prevQuote = ''
40-
var escape = false
38+
var blockClose = [];
39+
var inQuote = false;
40+
var prevQuote = '';
41+
var escape = false;
4142

42-
for (let letter of string) {
43+
for (var letter of string) {
4344
if (escape) {
44-
escape = false
45+
escape = false;
4546
} else if (letter === '\\') {
46-
escape = true
47+
escape = true;
4748
} else if (inQuote) {
4849
if (letter === prevQuote) {
49-
inQuote = false
50+
inQuote = false;
5051
}
5152
} else if (letter === '"' || letter === "'") {
52-
inQuote = true
53-
prevQuote = letter
53+
inQuote = true;
54+
prevQuote = letter;
5455
} else if (letter === '(' || letter === '[' || letter === '{') {
55-
blockClose.push(blockPairs[letter])
56+
blockClose.push(blockPairs[letter]);
5657
} else if (letter === blockClose[blockClose.length - 1]) {
57-
blockClose.pop()
58+
blockClose.pop();
5859
} else if (blockClose.length === 0 || (splitFunctions && blockClose.every((x) => x === ')'))) {
59-
if (letter === separator) split = true
60+
if (letter === separator) split = true;
6061
}
6162

6263
if (split) {
63-
array.push(current)
64-
current = ''
65-
split = false
64+
array.push(current);
65+
current = '';
66+
split = false;
6667
} else {
67-
current += letter
68+
current += letter;
6869
}
6970
}
7071

71-
array.push(current)
72-
return array
72+
array.push(current);
73+
return array;
7374
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcss-resolve-nested-selector",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"description": "Resolve a nested selector in a PostCSS AST",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)