added failing test for #49 #431

Closed
wants to merge 5 commits into
from
View
@@ -8,7 +8,7 @@ tree.mixin.Call = function (elements, args, index) {
};
tree.mixin.Call.prototype = {
eval: function (env) {
- var mixins, args, rules = [], match = false;
+ var mixins, args, rules = [], match = false, cssRules = {}, l, ruleCss;
for (var i = 0; i < env.frames.length; i++) {
if ((mixins = env.frames[i].find(this.selector)).length > 0) {
@@ -25,6 +25,17 @@ tree.mixin.Call.prototype = {
}
}
if (match) {
+ // filter out rules with the same name and value.
+ l = rules.length;
+ while(l--) {
+ ruleCss = rules[l].toCSS(env);
+ if (!cssRules[ruleCss]) {
+ cssRules[ruleCss] = 1;
+ }
+ else {
+ rules.splice(l, 1);
+ }
+ }
return rules;
} else {
throw { message: 'No matching definition was found for `' +
View
@@ -0,0 +1,18 @@
+.a {
+ mixed: 20;
+ foo: 'bar';
+ mixed: 25;
+ main: 'yes';
+}
+.b {
+ mixed: 20;
+ foo: 'bar';
+ mixed: 25;
+ main: 'yes';
+}
+#main {
+ mixed: 20;
+ foo: 'bar';
+ mixed: 25;
+ main: 'yes';
+}
View
@@ -2,9 +2,7 @@ var path = require('path'),
fs = require('fs'),
sys = require('sys');
-require.paths.unshift(__dirname, path.join(__dirname, '..'));
-
-var less = require('lib/less');
+var less = require('../lib/less');
less.tree.functions.add = function (a, b) {
return new(less.tree.Dimension)(a.value + b.value);
@@ -18,13 +16,13 @@ less.tree.functions.color = function (str) {
sys.puts("\n" + stylize("LESS", 'underline') + "\n");
-fs.readdirSync('test/less').forEach(function (file) {
+fs.readdirSync(__dirname + '/less').forEach(function (file) {
if (! /\.less/.test(file)) { return }
- toCSS('test/less/' + file, function (err, less) {
+ toCSS(__dirname + '/less/' + file, function (err, less) {
var name = path.basename(file, '.less');
- fs.readFile(path.join('test/css', name) + '.css', 'utf-8', function (e, css) {
+ fs.readFile(path.join(__dirname + '/css', name) + '.css', 'utf-8', function (e, css) {
sys.print("- " + name + ": ")
if (less === css) { sys.print(stylize('OK', 'green')) }
else if (err) {
@@ -0,0 +1,4 @@
+@import "mixins-import-vars";
+.a {
+ .mixin;
+}
@@ -0,0 +1,4 @@
+@import "mixins-import-vars";
+.b {
+ .mixin;
+}
@@ -0,0 +1,4 @@
+.mixin() {
+ mixed: 20;
+ foo: 'bar';
+}
@@ -0,0 +1,11 @@
+@import "import/mixins-import-a";
+@import "import/mixins-import-b";
+
+.mixin() {
+ mixed: 25;
+ main: 'yes';
+}
+
+#main {
+ .mixin
+}