diff --git a/lib/nodes/Numeric.js b/lib/nodes/Numeric.js index 5cf25a4..d64dbf2 100644 --- a/lib/nodes/Numeric.js +++ b/lib/nodes/Numeric.js @@ -14,7 +14,7 @@ const { registerWalker } = require('../walker'); const Node = require('./Node'); -const unitRegex = /%|ch|cm|em|ex|in|mm|pc|pt|px|q|rem|vh|vmax|vmin|vw$/i; +const unitRegex = /%|ch|cm|em|ex|in|mm|ms|pc|pt|px|s|q|rem|vh|vmax|vmin|vw$/i; class Numeric extends Node { constructor(options = {}) { diff --git a/test/fixtures/numeric.js b/test/fixtures/numeric.js index cbedc06..7bf99ae 100644 --- a/test/fixtures/numeric.js +++ b/test/fixtures/numeric.js @@ -31,7 +31,12 @@ module.exports = { '1E+10', '-.567800E-0012780em', '.1E-10', - '.1E+10' + '.1E+10', + '0.5s', + '500ms', + '0.5s + 0.5s', + '-.3s', + '-.3s + 0.5s' ], throws: ['+-2.', '.', '.rem', '.2.3rem'] }; diff --git a/test/snapshots/numeric.test.js.md b/test/snapshots/numeric.test.js.md index 75986bf..c898dbe 100644 --- a/test/snapshots/numeric.test.js.md +++ b/test/snapshots/numeric.test.js.md @@ -1051,3 +1051,292 @@ Generated by [AVA](https://ava.li). value: '5', }, ] + +## -.3s + +> Snapshot 1 + + '-.3s' + +> Snapshot 2 + + '-.3s' + +> Snapshot 3 + + [ + Numeric { + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + }, + input: Input { + css: '-.3s', + hasBOM: false, + id: '', + }, + start: { + column: 1, + line: 1, + }, + }, + type: 'numeric', + unit: 's', + value: '-.3', + }, + ] + +## -.3s + 0.5s + +> Snapshot 1 + + '-.3s' + +> Snapshot 2 + + '-.3s + 0.5s' + +> Snapshot 3 + + [ + Numeric { + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + }, + input: Input { + css: '-.3s + 0.5s', + hasBOM: false, + id: '', + }, + start: { + column: 1, + line: 1, + }, + }, + type: 'numeric', + unit: 's', + value: '-.3', + }, + Operator { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 6, + line: 1, + }, + input: Input { + css: '-.3s + 0.5s', + hasBOM: false, + id: '', + }, + start: { + column: 6, + line: 1, + }, + }, + type: 'operator', + value: '+', + }, + Numeric { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 8, + line: 1, + }, + input: Input { + css: '-.3s + 0.5s', + hasBOM: false, + id: '', + }, + start: { + column: 8, + line: 1, + }, + }, + type: 'numeric', + unit: 's', + value: '0.5', + }, + ] + +## 0.5s + +> Snapshot 1 + + '0.5s' + +> Snapshot 2 + + '0.5s' + +> Snapshot 3 + + [ + Numeric { + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + }, + input: Input { + css: '0.5s', + hasBOM: false, + id: '', + }, + start: { + column: 1, + line: 1, + }, + }, + type: 'numeric', + unit: 's', + value: '0.5', + }, + ] + +## 0.5s + 0.5s + +> Snapshot 1 + + '0.5s' + +> Snapshot 2 + + '0.5s + 0.5s' + +> Snapshot 3 + + [ + Numeric { + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + }, + input: Input { + css: '0.5s + 0.5s', + hasBOM: false, + id: '', + }, + start: { + column: 1, + line: 1, + }, + }, + type: 'numeric', + unit: 's', + value: '0.5', + }, + Operator { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 6, + line: 1, + }, + input: Input { + css: '0.5s + 0.5s', + hasBOM: false, + id: '', + }, + start: { + column: 6, + line: 1, + }, + }, + type: 'operator', + value: '+', + }, + Numeric { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 8, + line: 1, + }, + input: Input { + css: '0.5s + 0.5s', + hasBOM: false, + id: '', + }, + start: { + column: 8, + line: 1, + }, + }, + type: 'numeric', + unit: 's', + value: '0.5', + }, + ] + +## 500ms + +> Snapshot 1 + + '500ms' + +> Snapshot 2 + + '500ms' + +> Snapshot 3 + + [ + Numeric { + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + }, + input: Input { + css: '500ms', + hasBOM: false, + id: '', + }, + start: { + column: 1, + line: 1, + }, + }, + type: 'numeric', + unit: 'ms', + value: '500', + }, + ] diff --git a/test/snapshots/numeric.test.js.snap b/test/snapshots/numeric.test.js.snap index 26556f4..1b85ca3 100644 Binary files a/test/snapshots/numeric.test.js.snap and b/test/snapshots/numeric.test.js.snap differ