Skip to content

Commit

Permalink
[less] Adjust less variable declaration & atrule parsing priority, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang authored and tonyganch committed Nov 3, 2016
1 parent da53185 commit 952e715
Show file tree
Hide file tree
Showing 4 changed files with 604 additions and 116 deletions.
10 changes: 5 additions & 5 deletions src/less/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -3180,11 +3180,11 @@ function checkStylesheet(i) {
// Check every token:
while (i < tokensLength) {
if (l = checkSC(i) ||
checkAtrule(i) ||
checkRuleset(i) ||
checkMixin(i) ||
checkDeclaration(i) ||
checkDeclDelim(i)) i += l;
checkDeclDelim(i) ||
checkAtrule(i) ||
checkMixin(i)) i += l;
else throwError(i);
}

Expand All @@ -3201,11 +3201,11 @@ function getStylesheet() {

while (pos < tokensLength) {
if (checkSC(pos)) x = x.concat(getSC());
else if (checkAtrule(pos)) x.push(getAtrule());
else if (checkRuleset(pos)) x.push(getRuleset());
else if (checkMixin(pos)) x.push(getMixin());
else if (checkDeclaration(pos)) x.push(getDeclaration());
else if (checkDeclDelim(pos)) x.push(getDeclDelim());
else if (checkAtrule(pos)) x.push(getAtrule());
else if (checkMixin(pos)) x.push(getMixin());
else throwError(pos);
}

Expand Down
234 changes: 123 additions & 111 deletions test/less/stylesheet/issue104.json
Original file line number Diff line number Diff line change
@@ -1,133 +1,145 @@
{
"type": "stylesheet",
"content": [
{
"type": "atrule",
"content": [
{
"type": "atkeyword",
"content": [
{
"type": "ident",
"content": "image-url",
"syntax": "less",
"start": {
"type": "stylesheet",
"content": [{
"type": "declaration",
"content": [{
"type": "property",
"content": [{
"type": "variable",
"content": [{
"type": "ident",
"content": "image-url",
"syntax": "less",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 10
}
}],
"syntax": "less",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 10
}
}],
"syntax": "less",
"start": {
"line": 1,
"column": 2
},
"end": {
"column": 1
},
"end": {
"line": 1,
"column": 10
}
}
],
"syntax": "less",
"start": {
}, {
"type": "propertyDelimiter",
"content": ":",
"syntax": "less",
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 11
}
}, {
"type": "space",
"content": " ",
"syntax": "less",
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 12
}
}, {
"type": "value",
"content": [{
"type": "string",
"content": "'../image'",
"syntax": "less",
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 22
}
}],
"syntax": "less",
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 22
}
}],
"syntax": "less",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 10
}
},
{
"type": "operator",
"content": ":",
"syntax": "less",
"start": {
"end": {
"line": 1,
"column": 11
},
"end": {
"column": 22
}
}, {
"type": "declarationDelimiter",
"content": ";",
"syntax": "less",
"start": {
"line": 1,
"column": 11
}
"column": 23
},
{
"type": "space",
"content": " ",
"syntax": "less",
"start": {
"end": {
"line": 1,
"column": 12
},
"end": {
"column": 23
}
}, {
"type": "space",
"content": "\n",
"syntax": "less",
"start": {
"line": 1,
"column": 12
}
"column": 24
},
{
"type": "string",
"content": "'../image'",
"syntax": "less",
"start": {
"line": 1,
"column": 13
},
"end": {
"end": {
"line": 1,
"column": 22
}
"column": 24
}
],
"syntax": "less",
"start": {
}, {
"type": "singlelineComment",
"content": " Comment",
"syntax": "less",
"start": {
"line": 2,
"column": 1
},
"end": {
"line": 2,
"column": 10
}
}],
"syntax": "less",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 22
}
},
{
"type": "declarationDelimiter",
"content": ";",
"syntax": "less",
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 23
}
},
{
"type": "space",
"content": "\n",
"syntax": "less",
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 24
}
},
{
"type": "singlelineComment",
"content": " Comment",
"syntax": "less",
"start": {
"line": 2,
"column": 1
},
"end": {
"end": {
"line": 2,
"column": 10
}
}
],
"syntax": "less",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 2,
"column": 10
}
}
}
Loading

0 comments on commit 952e715

Please sign in to comment.