Doesn't parse number sign character
radarfox opened this issue · comments
radarfox commented
From the CSS specification:
The format of a length value is an optional sign character ('+' or '-', with '+' being the default) immediately followed by a number...
Current output:
-1px
=>[{"type":"ident","string":"-1px"}]
-1
=>[{"type":"ident","string":"-1"}]
-0
=>[{"type":"ident","string":"-0"}]
+0
=> throwsfailed to parse near +0...
+1
=> throwsfailed to parse near +1...
+1px
=> throwsfailed to parse near +1px...
Expected output:
-1px
=>{ type: 'number', string: '-1px', unit: 'px', value: -1 }
-1
=>{ type: 'number', string: '-1', unit: '', value: -1 }
-0
=>{ type: 'number', string: '-0', unit: '', value: -0 }
+0
=>{ type: 'number', string: '+0', unit: '', value: 0 }
+1
=>{ type: 'number', string: '+1', unit: '', value: 1 }
+1px
=>{ type: 'number', string: '+1px', unit: 'px', value: 1 }
TJ Holowaychuk commented
Post CSS is more or less the same as Rework (but actively maintained), you might be better off using that these days
radarfox commented
Thanks for the response, but it seem to me, that Rework doesn't parse the values. All I need is to convert "-1px"
into {value: -1, unit: "px"}
.
In Rework i need to do something like * {top: -12px}
and all I get is {property: "top", type: "declaration", value: "-12px"}
which i useless to me.
Or am I missing something?