mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
remove duplicate rules automatically
This commit is contained in:
@@ -114,6 +114,7 @@ tree.Ruleset.prototype = {
|
||||
toCSS: function (context, env) {
|
||||
var css = [], // The CSS output
|
||||
rules = [], // node.Rule instances
|
||||
_rules = [], //
|
||||
rulesets = [], // node.Ruleset instances
|
||||
paths = [], // Current selectors
|
||||
selector, // The fully rendered selector
|
||||
@@ -163,7 +164,15 @@ tree.Ruleset.prototype = {
|
||||
return p.map(function (s) {
|
||||
return s.toCSS(env);
|
||||
}).join('').trim();
|
||||
}).join( env.compress ? ',' : ',\n');
|
||||
}).join(env.compress ? ',' : ',\n');
|
||||
|
||||
// Remove duplicates
|
||||
for (var i = rules.length - 1; i >= 0; i--) {
|
||||
if (_rules.indexOf(rules[i]) === -1) {
|
||||
_rules.unshift(rules[i]);
|
||||
}
|
||||
}
|
||||
rules = _rules;
|
||||
|
||||
css.push(selector,
|
||||
(env.compress ? '{' : ' {\n ') +
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
}
|
||||
#built-in .is-a {
|
||||
color: true;
|
||||
color: true;
|
||||
color: true;
|
||||
color1: true;
|
||||
color2: true;
|
||||
keyword: true;
|
||||
number: true;
|
||||
string: true;
|
||||
|
||||
@@ -18,5 +18,5 @@
|
||||
}
|
||||
.arrays {
|
||||
ary: "1, 2, 3";
|
||||
ary: "1, 2, 3";
|
||||
ary1: "1, 2, 3";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#hidden {
|
||||
color: transparent;
|
||||
}
|
||||
#hidden1 {
|
||||
color: transparent;
|
||||
}
|
||||
.two-args {
|
||||
@@ -49,10 +51,6 @@ body {
|
||||
#var-inside {
|
||||
width: 10px;
|
||||
}
|
||||
.id-class {
|
||||
color: red;
|
||||
color: red;
|
||||
}
|
||||
.arguments {
|
||||
border: 1px solid #000000;
|
||||
width: 1px;
|
||||
|
||||
@@ -35,6 +35,6 @@
|
||||
.mix-mul-class {
|
||||
color: #0000ff;
|
||||
color: #ff0000;
|
||||
color: #0000ff;
|
||||
color: #000000;
|
||||
color: #ffa500;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
|
||||
.is-a {
|
||||
color: iscolor(#ddd);
|
||||
color: iscolor(red);
|
||||
color: iscolor(rgb(0, 0, 0));
|
||||
color1: iscolor(red);
|
||||
color2: iscolor(rgb(0, 0, 0));
|
||||
keyword: iskeyword(hello);
|
||||
number: isnumber(32);
|
||||
string: isstring("hello");
|
||||
|
||||
@@ -23,5 +23,5 @@
|
||||
@ary: 1, 2, 3;
|
||||
@ary2: 1 2 3;
|
||||
ary: `@{ary}.join(', ')`;
|
||||
ary: `@{ary2}.join(', ')`;
|
||||
ary1: `@{ary2}.join(', ')`;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
|
||||
#hidden {
|
||||
.hidden;
|
||||
}
|
||||
|
||||
#hidden1 {
|
||||
.hidden();
|
||||
}
|
||||
|
||||
@@ -96,16 +99,6 @@ body {
|
||||
}
|
||||
#var-inside { .var-inside; }
|
||||
|
||||
// # mixins
|
||||
|
||||
#id-mixin () {
|
||||
color: red;
|
||||
}
|
||||
.id-class {
|
||||
#id-mixin();
|
||||
#id-mixin;
|
||||
}
|
||||
|
||||
.mixin-arguments (@width: 0px, ...) {
|
||||
border: @arguments;
|
||||
width: @width;
|
||||
|
||||
@@ -46,6 +46,6 @@
|
||||
.mix-mul-class {
|
||||
.mix-mul(blue);
|
||||
.mix-mul(red);
|
||||
.mix-mul(blue);
|
||||
.mix-mul(black);
|
||||
.mix-mul(orange);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user