Skip to content

Commit 4d66a9b

Browse files
committed
Parse / operator (used with background position/size)
1 parent 9b9904f commit 4d66a9b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ Parser.prototype.comma = function(){
2121
return { type: 'comma', string: ',' };
2222
};
2323

24+
Parser.prototype.operator = function(){
25+
var m = /^\/ */.exec(this.str);
26+
if (!m) return;
27+
this.skip(m[0]);
28+
return { type: 'operator', value: '/' };
29+
};
30+
2431
Parser.prototype.ident = function(){
2532
var m = /^([\w-]+) */.exec(this.str);
2633
if (!m) return;
@@ -32,7 +39,7 @@ Parser.prototype.ident = function(){
3239
};
3340

3441
Parser.prototype.int = function(){
35-
var m = /^((\d+)(\S+)?) */.exec(this.str);
42+
var m = /^((\d+)([^\s\/]+)?) */.exec(this.str);
3643
if (!m) return;
3744
this.skip(m[0]);
3845
var n = ~~m[2];
@@ -47,7 +54,7 @@ Parser.prototype.int = function(){
4754
};
4855

4956
Parser.prototype.float = function(){
50-
var m = /^(((?:\d+)?\.\d+)(\S+)?) */.exec(this.str);
57+
var m = /^(((?:\d+)?\.\d+)([^\s\/]+)?) */.exec(this.str);
5158
if (!m) return;
5259
this.skip(m[0]);
5360
var n = parseFloat(m[2]);
@@ -154,7 +161,8 @@ Parser.prototype.gradient = function(){
154161

155162
Parser.prototype.value = function(){
156163
this.str = this.str.replace(/^\s+/, '');
157-
return this.number()
164+
return this.operator()
165+
|| this.number()
158166
|| this.color()
159167
|| this.gradient()
160168
|| this.url()

0 commit comments

Comments
 (0)