Skip to content

Commit 8bdafa5

Browse files
committed
remove the need for trim
1 parent 59dae34 commit 8bdafa5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ Parser.prototype.skip = function(m){
1414
};
1515

1616
Parser.prototype.number = function(){
17-
var m = /^(\d+)(\w+)? */.exec(this.str);
17+
var m = /^((\d+)(\w+)?) */.exec(this.str);
1818
if (!m) return;
1919
this.skip(m);
20-
var n = ~~m[1];
21-
var u = m[2];
20+
var n = ~~m[2];
21+
var u = m[3];
2222

2323
return {
2424
type: 'number',
25-
string: n + u,
26-
unit: u,
25+
string: m[1],
26+
unit: u || '',
2727
value: n
2828
}
2929
};

test/cases/numbers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ exports.object = [
55
{ type: 'number', string: '1px', unit: 'px', value: 1 },
66
{ type: 'number', string: '0', unit: '', value: 0 },
77
{ type: 'number', string: '0', unit: '', value: 0 },
8-
{ type: 'number', string: '1px', unit: 'px', value: 5 },
8+
{ type: 'number', string: '5px', unit: 'px', value: 5 },
99
];

0 commit comments

Comments
 (0)