Skip to content

Commit

Permalink
Merge pull request #2392 from Justineo/isruleset
Browse files Browse the repository at this point in the history
add support for `isruleset`
  • Loading branch information
lukeapage committed Jan 15, 2015
2 parents 2738aae + 297ac17 commit 8ed6a97
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/less/functions/types.js
Original file line number Diff line number Diff line change
@@ -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"),
Expand All @@ -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);
},
Expand Down
1 change: 1 addition & 0 deletions test/css/functions.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
mixt: rgba(255, 0, 0, 0.5);
}
#built-in .is-a {
ruleset: true;
color: true;
color1: true;
color2: true;
Expand Down
4 changes: 4 additions & 0 deletions test/less/functions.less
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 8ed6a97

Please sign in to comment.