Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/nodes/Numeric.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


class Numeric extends Node {
constructor(options = {}) {
Expand Down
7 changes: 6 additions & 1 deletion test/fixtures/numeric.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
};
Expand Down
289 changes: 289 additions & 0 deletions test/snapshots/numeric.test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<input css 26>',
},
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: '<input css 27>',
},
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: '<input css 27>',
},
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: '<input css 27>',
},
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: '<input css 23>',
},
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: '<input css 25>',
},
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: '<input css 25>',
},
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: '<input css 25>',
},
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: '<input css 24>',
},
start: {
column: 1,
line: 1,
},
},
type: 'numeric',
unit: 'ms',
value: '500',
},
]
Binary file modified test/snapshots/numeric.test.js.snap
Binary file not shown.