Skip to content

Commit

Permalink
[sass] 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 537845f commit 1cdecd2
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/sass/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -4959,8 +4959,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/sass/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": "sass",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 2
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 2
}
},
{
"type": "attributeMatch",
"content": "|=",
"syntax": "sass",
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 4
}
},
{
"type": "attributeValue",
"content": [
{
"type": "ident",
"content": "b",
"syntax": "sass",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
1 change: 1 addition & 0 deletions test/sass/selector/15.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[a|=b]
95 changes: 95 additions & 0 deletions test/sass/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": "sass",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 2
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 2
}
},
{
"type": "attributeMatch",
"content": "^=",
"syntax": "sass",
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 4
}
},
{
"type": "attributeValue",
"content": [
{
"type": "ident",
"content": "b",
"syntax": "sass",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
1 change: 1 addition & 0 deletions test/sass/selector/16.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[a^=b]
95 changes: 95 additions & 0 deletions test/sass/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": "sass",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 2
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 2
}
},
{
"type": "attributeMatch",
"content": "~=",
"syntax": "sass",
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 4
}
},
{
"type": "attributeValue",
"content": [
{
"type": "ident",
"content": "b",
"syntax": "sass",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 5
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
],
"syntax": "sass",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
1 change: 1 addition & 0 deletions test/sass/selector/17.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[a~=b]
3 changes: 3 additions & 0 deletions test/sass/selector/test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ describe 'sass/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 's.0', -> this.shouldBeOk()
it 's.1', -> this.shouldBeOk()
Expand Down

0 comments on commit 1cdecd2

Please sign in to comment.