Skip to content

Commit

Permalink
[sass] Fix nested multiline selectors groups
Browse files Browse the repository at this point in the history
See #119
  • Loading branch information
tonyganch committed Apr 28, 2016
1 parent 9465031 commit 910d717
Show file tree
Hide file tree
Showing 5 changed files with 942 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/sass/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -4250,7 +4250,8 @@ function checkSelectorsGroup(i) {
let c = checkDelim(i + sb);
if (!c) break;
let sa = checkSC(i + sb + c);
if (l = checkSelector(i + sb + c + sa)) i += sb + c + sa + l;
let saa = sa ? checkSC(i + sb + c + sa) : 0;
if (l = checkSelector(i + sb + c + sa + saa)) i += sb + c + sa + saa + l;
else break;
}

Expand All @@ -4268,6 +4269,7 @@ function getSelectorsGroup() {
selectorsGroup = selectorsGroup.concat(getSC());
selectorsGroup.push(getDelim());
selectorsGroup = selectorsGroup.concat(getSC());
selectorsGroup = selectorsGroup.concat(getSC());
selectorsGroup.push(getSelector());
}

Expand Down
364 changes: 364 additions & 0 deletions test/sass/ruleset/issue-119-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,364 @@
{
"type": "ruleset",
"content": [
{
"type": "selector",
"content": [
{
"type": "class",
"content": [
{
"type": "ident",
"content": "foo",
"syntax": "sass",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 4
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 4
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 4
}
},
{
"type": "space",
"content": "\n",
"syntax": "sass",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
},
{
"type": "block",
"content": [
{
"type": "space",
"content": " ",
"syntax": "sass",
"start": {
"line": 2,
"column": 1
},
"end": {
"line": 2,
"column": 2
}
},
{
"type": "ruleset",
"content": [
{
"type": "selector",
"content": [
{
"type": "class",
"content": [
{
"type": "ident",
"content": "bar",
"syntax": "sass",
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 6
}
}
],
"syntax": "sass",
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 6
}
}
],
"syntax": "sass",
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 6
}
},
{
"type": "delimiter",
"content": ",",
"syntax": "sass",
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 7
}
},
{
"type": "space",
"content": "\n",
"syntax": "sass",
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 8
}
},
{
"type": "space",
"content": " ",
"syntax": "sass",
"start": {
"line": 3,
"column": 1
},
"end": {
"line": 3,
"column": 2
}
},
{
"type": "selector",
"content": [
{
"type": "class",
"content": [
{
"type": "ident",
"content": "qux",
"syntax": "sass",
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 6
}
}
],
"syntax": "sass",
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 6
}
}
],
"syntax": "sass",
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 6
}
},
{
"type": "space",
"content": "\n",
"syntax": "sass",
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 7
}
},
{
"type": "block",
"content": [
{
"type": "space",
"content": " ",
"syntax": "sass",
"start": {
"line": 4,
"column": 1
},
"end": {
"line": 4,
"column": 4
}
},
{
"type": "declaration",
"content": [
{
"type": "property",
"content": [
{
"type": "ident",
"content": "content",
"syntax": "sass",
"start": {
"line": 4,
"column": 5
},
"end": {
"line": 4,
"column": 11
}
}
],
"syntax": "sass",
"start": {
"line": 4,
"column": 5
},
"end": {
"line": 4,
"column": 11
}
},
{
"type": "propertyDelimiter",
"content": ":",
"syntax": "sass",
"start": {
"line": 4,
"column": 12
},
"end": {
"line": 4,
"column": 12
}
},
{
"type": "space",
"content": " ",
"syntax": "sass",
"start": {
"line": 4,
"column": 13
},
"end": {
"line": 4,
"column": 13
}
},
{
"type": "value",
"content": [
{
"type": "string",
"content": "'fail'",
"syntax": "sass",
"start": {
"line": 4,
"column": 14
},
"end": {
"line": 4,
"column": 19
}
}
],
"syntax": "sass",
"start": {
"line": 4,
"column": 14
},
"end": {
"line": 4,
"column": 19
}
}
],
"syntax": "sass",
"start": {
"line": 4,
"column": 5
},
"end": {
"line": 4,
"column": 19
}
}
],
"syntax": "sass",
"start": {
"line": 4,
"column": 1
},
"end": {
"line": 4,
"column": 19
}
}
],
"syntax": "sass",
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 4,
"column": 19
}
}
],
"syntax": "sass",
"start": {
"line": 2,
"column": 1
},
"end": {
"line": 4,
"column": 19
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 4,
"column": 19
}
}
4 changes: 4 additions & 0 deletions test/sass/ruleset/issue-119-1.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.foo
.bar,
.qux
content: 'fail'
Loading

0 comments on commit 910d717

Please sign in to comment.