mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
add more is-* functions
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
keyword: true;
|
||||
number: true;
|
||||
string: true;
|
||||
pixel: true;
|
||||
percent: true;
|
||||
em: true;
|
||||
}
|
||||
#alpha {
|
||||
alpha: rgba(153, 94, 51, 0.6);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user