From 297ac17ddad19c8b284f5318ae5c579ae72cabc5 Mon Sep 17 00:00:00 2001 From: Justineo Date: Thu, 15 Jan 2015 12:12:39 +0800 Subject: [PATCH] add support for `isruleset` --- lib/less/functions/types.js | 4 ++++ test/css/functions.css | 1 + test/less/functions.less | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/lib/less/functions/types.js b/lib/less/functions/types.js index 42a5190d0..adc134725 100644 --- a/lib/less/functions/types.js +++ b/lib/less/functions/types.js @@ -1,4 +1,5 @@ var Keyword = require("../tree/keyword"), + DetachedRuleset = require("../tree/detached-ruleset"), Dimension = require("../tree/dimension"), Color = require("../tree/color"), Quoted = require("../tree/quoted"), @@ -21,6 +22,9 @@ var isa = function (n, Type) { return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False; }; functionRegistry.addMultiple({ + isruleset: function (n) { + return isa(n, DetachedRuleset); + }, iscolor: function (n) { return isa(n, Color); }, diff --git a/test/css/functions.css b/test/css/functions.css index 37bbfdf7f..62eac50e9 100644 --- a/test/css/functions.css +++ b/test/css/functions.css @@ -127,6 +127,7 @@ mixt: rgba(255, 0, 0, 0.5); } #built-in .is-a { + ruleset: true; color: true; color1: true; color2: true; diff --git a/test/less/functions.less b/test/less/functions.less index 6a02e7094..947b9f2d3 100644 --- a/test/less/functions.less +++ b/test/less/functions.less @@ -137,6 +137,10 @@ mixt: mix(#ff0000, transparent); .is-a { + @rules: { + color: red; + }; + ruleset: isruleset(@rules); color: iscolor(#ddd); color1: iscolor(red); color2: iscolor(rgb(0, 0, 0));