diff --git a/lib/less/functions/types.js b/lib/less/functions/types.js index f6bfae929..7502acf84 100644 --- a/lib/less/functions/types.js +++ b/lib/less/functions/types.js @@ -57,6 +57,24 @@ functionRegistry.addMultiple({ isem: function (n) { return isunit(n, 'em'); }, + isrem: function (n) { + return isunit(n, 'rem'); + }, + isvw: function (n) { + return isunit(n, 'vw'); + }, + isvh: function (n) { + return isunit(n, 'vh'); + }, + isvmin: function (n) { + return isunit(n, 'vmin'); + }, + isvmax: function (n) { + return isunit(n, 'vmax'); + }, + isch: function (n) { + return isunit(n, 'ch'); + }, isunit: isunit, unit: function (val, unit) { if (!(val instanceof Dimension)) { diff --git a/lib/less/tree/unit.js b/lib/less/tree/unit.js index 0e27daaad..2aa0e8b81 100644 --- a/lib/less/tree/unit.js +++ b/lib/less/tree/unit.js @@ -42,7 +42,7 @@ Unit.prototype.is = function (unitString) { return this.toString().toUpperCase() === unitString.toUpperCase(); }; Unit.prototype.isLength = function () { - return Boolean(this.toCSS().match(/px|em|%|in|cm|mm|pc|pt|ex/)); + return RegExp('^(px|em|rem|in|cm|mm|pc|pt|ex|vw|vh|vmin|vmax)$', 'g').test(this.toCSS()); }; Unit.prototype.isEmpty = function () { return this.numerator.length === 0 && this.denominator.length === 0; diff --git a/test/css/functions.css b/test/css/functions.css index f4144ea2c..8ed26f842 100644 --- a/test/css/functions.css +++ b/test/css/functions.css @@ -150,6 +150,12 @@ pixel: true; percent: true; em: true; + rem: true; + vw: true; + vh: true; + vmin: true; + vmax: true; + ch: true; cat: true; no-unit-is-empty: true; case-insensitive-1: true; diff --git a/test/less/functions.less b/test/less/functions.less index ad8682931..431c26513 100644 --- a/test/less/functions.less +++ b/test/less/functions.less @@ -134,11 +134,11 @@ fade-out: fadeout(red, 5%); // support fadeOut and fadeout fade-in: fadein(fadeout(red, 10%), 5%); - fade-out-relative: fadeout(red, 5%,relative); + fade-out-relative: fadeout(red, 5%,relative); fade-in-relative: fadein(fadeout(red, 10%, relative), 5%, relative); - fade-out2: fadeout(fadeout(red, 50%), 50%); + fade-out2: fadeout(fadeout(red, 50%), 50%); fade-out2-relative: fadeout(fadeout(red, 50%, relative), 50%, relative); - + hsv: hsv(5, 50%, 30%); hsva: hsva(3, 50%, 30%, 0.2); @@ -163,6 +163,12 @@ pixel: ispixel(32px); percent: ispercentage(32%); em: isem(32em); + rem: isrem(32rem); + vw: isvw(32vw); + vh: isvh(32vh); + vmin: isvmin(32vmin); + vmax: isvmax(32vmax); + ch: isch(32ch); cat: isunit(32cat, cat); no-unit-is-empty: isunit(32, ''); case-insensitive-1: isunit(32CAT, cat);