Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/parse/tokenize.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ function consumeNumber(chars) {
['types', ['<number-token>']],
]
let number = ''
let type = 'integer'
if (chars.next() === '+' || chars.next() === '-') {
entries.push(['sign', number += chars.consume()])
}
Expand All @@ -328,8 +329,9 @@ function consumeNumber(chars) {
|| startsWithExponent(...chars.next(3))
) {
number += chars.consume(2) + chars.consumeRunOf(isDigit)
type = 'number'
}
entries.push(['end', chars.index + 1], ['value', convertStringToNumber(number)])
entries.push(['end', chars.index + 1], ['value', convertStringToNumber(number)], ['type', type])
return Object.fromEntries(entries)
}

Expand All @@ -340,10 +342,10 @@ function consumeNumber(chars) {
*/
function consumeNumeric(chars) {
const number = consumeNumber(chars)
const { start, value } = number
const { start, value, type } = number
if (startsWithIdentifier(...chars.next(3))) {
const unit = consumeIdentifier(chars)
return { end: chars.index + 1, start, types: ['<dimension-token>'], unit: unit.value.toLowerCase(), value }
return { end: chars.index + 1, start, type, types: ['<dimension-token>'], unit: unit.value.toLowerCase(), value }
}
if (chars.consume('%')) {
return { end: chars.index + 1, start, types: ['<percentage-token>'], unit: '%', value }
Expand Down