add more is-* functions

This commit is contained in:
Alexis Sellier
2012-01-03 19:01:47 +01:00
parent 2844e03c5b
commit b43d442d55
3 changed files with 18 additions and 0 deletions

View File

@@ -187,6 +187,18 @@ tree.functions = {
'is-keyword': function (n) {
return this._isa(n, tree.Keyword);
},
'is-url': function (n) {
return this._isa(n, tree.URL);
},
'is-pixel': function (n) {
return (n instanceof tree.Dimension) && n.unit === 'px' ? tree.True : tree.False;
},
'is-percentage': function (n) {
return (n instanceof tree.Dimension) && n.unit === '%' ? tree.True : tree.False;
},
'is-em': function (n) {
return (n instanceof tree.Dimension) && n.unit === 'em' ? tree.True : tree.False;
},
_isa: function (n, Type) {
return (n instanceof Type) ? tree.True : tree.False;
}

View File

@@ -34,6 +34,9 @@
keyword: true;
number: true;
string: true;
pixel: true;
percent: true;
em: true;
}
#alpha {
alpha: rgba(153, 94, 51, 0.6);

View File

@@ -38,6 +38,9 @@
keyword: is-keyword(hello);
number: is-number(32);
string: is-string("hello");
pixel: is-pixel(32px);
percent: is-percentage(32%);
em: is-em(32em);
}
}