Skip to content

Commit

Permalink
[scss] Fix namespace attribute selector
Browse files Browse the repository at this point in the history
  • Loading branch information
bgriffith authored and tonyganch committed Jun 21, 2016
1 parent 1cdecd2 commit 9e9b89f
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/scss/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -4548,8 +4548,12 @@ function getNamespacePrefix() {
function checkNamespaceSeparator(i) {
if (i >= tokensLength) return 0;

if (tokens[i].type === TokenType.VerticalLine) return 1;
else return 0;
if (tokens[i].type !== TokenType.VerticalLine) return 0;

// Return false if `|=` - [attr|=value]
if (tokens[i + 1] && tokens[i + 1].type === TokenType.EqualsSign) return 0;

return 1;
}

function getNamespaceSeparator() {
Expand Down
95 changes: 95 additions & 0 deletions test/scss/selector/15.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"type": "selector",
"content": [
{
"type": "attributeSelector",
"content": [
{
"type": "attributeName",
"content": [
{
"type": "ident",
"content": "a",
"syntax": "scss",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 2
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 2
}
},
{
"type": "attributeMatch",
"content": "|=",
"syntax": "scss",
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 4
}
},
{
"type": "attributeValue",
"content": [
{
"type": "ident",
"content": "b",
"syntax": "scss",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
1 change: 1 addition & 0 deletions test/scss/selector/15.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[a|=b]
95 changes: 95 additions & 0 deletions test/scss/selector/16.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"type": "selector",
"content": [
{
"type": "attributeSelector",
"content": [
{
"type": "attributeName",
"content": [
{
"type": "ident",
"content": "a",
"syntax": "scss",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 2
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 2
}
},
{
"type": "attributeMatch",
"content": "^=",
"syntax": "scss",
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 4
}
},
{
"type": "attributeValue",
"content": [
{
"type": "ident",
"content": "b",
"syntax": "scss",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
1 change: 1 addition & 0 deletions test/scss/selector/16.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[a^=b]
95 changes: 95 additions & 0 deletions test/scss/selector/17.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"type": "selector",
"content": [
{
"type": "attributeSelector",
"content": [
{
"type": "attributeName",
"content": [
{
"type": "ident",
"content": "a",
"syntax": "scss",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 2
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 2
}
},
{
"type": "attributeMatch",
"content": "~=",
"syntax": "scss",
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 4
}
},
{
"type": "attributeValue",
"content": [
{
"type": "ident",
"content": "b",
"syntax": "scss",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
1 change: 1 addition & 0 deletions test/scss/selector/17.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[a~=b]
3 changes: 3 additions & 0 deletions test/scss/selector/test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ describe 'scss/selector >>', ->
it '12', -> this.shouldBeOk()
it '13', -> this.shouldBeOk()
it '14', -> this.shouldBeOk()
it '15', -> this.shouldBeOk()
it '16', -> this.shouldBeOk()
it '17', -> this.shouldBeOk()

it 'c.0', -> this.shouldBeOk()
it 'c.1', -> this.shouldBeOk()
Expand Down

0 comments on commit 9e9b89f

Please sign in to comment.