Skip to content

Commit

Permalink
make a <number> that is equal to zero is allowed value for <angle> (f…
Browse files Browse the repository at this point in the history
…ixes #30)
  • Loading branch information
lahmatiy committed Dec 21, 2016
1 parent d7bb0df commit 981fca6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions lib/syntax/generic.js
Expand Up @@ -97,10 +97,12 @@ function dimension(type) {
};
}

function length(node) {
return isCalc(node) ||
(node.data.type === 'Dimension' && LENGTH.hasOwnProperty(node.data.unit.toLowerCase())) ||
(node.data.type === 'Number' && Number(node.data.value) === 0);
function zeroUnitlessDimension(type) {
return function(node) {
return isCalc(node) ||
(node.data.type === 'Dimension' && type.hasOwnProperty(node.data.unit.toLowerCase())) ||
(node.data.type === 'Number' && Number(node.data.value) === 0);
};
}

function attr(node) {
Expand Down Expand Up @@ -180,7 +182,7 @@ function customIdent(node) {
}

module.exports = {
'angle': dimension(ANGLE),
'angle': zeroUnitlessDimension(ANGLE),
'attr()': attr,
'custom-ident': customIdent,
'decibel': dimension(DECIBEL),
Expand All @@ -191,7 +193,7 @@ module.exports = {
'id-selector': astNode('Hash'), // element( <id-selector> )
'ident': astNode('Identifier'),
'integer': integer,
'length': length,
'length': zeroUnitlessDimension(LENGTH),
'number': number,
'number-zero-one': numberZeroOne,
'number-one-or-greater': numberOneOrGreater,
Expand Down
3 changes: 2 additions & 1 deletion test/fixture/syntax/generic.json
Expand Up @@ -15,7 +15,8 @@
"1RAD",
"1turn",
"1TURN",
"calc(2 * 1deg)"
"calc(2 * 1deg)",
"0"
],
"invalid:Mismatch": [
"",
Expand Down

0 comments on commit 981fca6

Please sign in to comment.