mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Add isunit function. fixes #1298
This commit is contained in:
@@ -291,13 +291,16 @@ tree.functions = {
|
||||
return this._isa(n, tree.URL);
|
||||
},
|
||||
ispixel: function (n) {
|
||||
return (n instanceof tree.Dimension) && n.unit.is('px') ? tree.True : tree.False;
|
||||
return this.isunit(n, 'px');
|
||||
},
|
||||
ispercentage: function (n) {
|
||||
return (n instanceof tree.Dimension) && n.unit.is('%') ? tree.True : tree.False;
|
||||
return this.isunit(n, '%');
|
||||
},
|
||||
isem: function (n) {
|
||||
return (n instanceof tree.Dimension) && n.unit.is('em') ? tree.True : tree.False;
|
||||
return this.isunit(n, 'em');
|
||||
},
|
||||
isunit: function (n, unit) {
|
||||
return (n instanceof tree.Dimension) && n.unit.is(unit.value || unit) ? tree.True : tree.False;
|
||||
},
|
||||
_isa: function (n, Type) {
|
||||
return (n instanceof Type) ? tree.True : tree.False;
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
pixel: true;
|
||||
percent: true;
|
||||
em: true;
|
||||
cat: true;
|
||||
}
|
||||
#alpha {
|
||||
alpha: rgba(153, 94, 51, 0.6);
|
||||
|
||||
@@ -116,6 +116,7 @@
|
||||
pixel: ispixel(32px);
|
||||
percent: ispercentage(32%);
|
||||
em: isem(32em);
|
||||
cat: isunit(32cat, cat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user