Skip to content

Commit

Permalink
syntax generic: <id-selector> fix, add test for <number-one-or-greater>
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Oct 17, 2016
1 parent 72c83e3 commit 5f63b94
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
19 changes: 5 additions & 14 deletions lib/syntax/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,12 @@ function hexColor(node) {
}

function idSelector(node) {
if (!node || node.data.type !== 'Hash') {
return;
}

var cursor = node.next;
var match = [node.data];
while (cursor && (cursor.data.type === 'Number' || cursor.data.type === 'Identifier')) {
match.push(cursor.data);
cursor = cursor.next;
if (node && node.data.type === 'Hash') {
return {
next: node.next,
match: [node.data]
};
}

return {
next: cursor,
match: match
};
}

function expression(node) {
Expand Down
18 changes: 18 additions & 0 deletions test/fixture/syntax/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,24 @@
"123"
]
},
"<number-one-or-greater>": {
"syntax": {
"generic": true,
"properties": {
"test": "<number-one-or-greater>"
}
},
"valid": [
"1",
"1.0",
"123.456"
],
"invalid:Mismatch": [
"-1",
"0.01",
".999"
]
},
"<integer>": {
"syntax": {
"generic": true,
Expand Down

0 comments on commit 5f63b94

Please sign in to comment.