mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
fixed a bug when using @media with mixins
This commit is contained in:
@@ -22,22 +22,23 @@ tree.Media.prototype = {
|
||||
env.mediaBlocks = [];
|
||||
env.mediaPath = [];
|
||||
}
|
||||
|
||||
env.mediaBlocks.push(this);
|
||||
|
||||
var blockIndex = env.mediaBlocks.length;
|
||||
env.mediaPath.push(this);
|
||||
env.mediaBlocks.push(this);
|
||||
|
||||
this.features = this.features.eval(env);
|
||||
env.frames.unshift(this);
|
||||
this.ruleset = this.ruleset.eval(env);
|
||||
var media = new(tree.Media)([], []);
|
||||
media.features = this.features.eval(env);
|
||||
|
||||
env.frames.unshift(this.ruleset);
|
||||
media.ruleset = this.ruleset.eval(env);
|
||||
env.frames.shift();
|
||||
|
||||
|
||||
env.mediaBlocks[blockIndex] = media;
|
||||
env.mediaPath.pop();
|
||||
|
||||
if (env.mediaPath.length === 0) {
|
||||
return this.evalTop(env);
|
||||
} else {
|
||||
return this.evalNested(env);
|
||||
}
|
||||
return env.mediaPath.length === 0 ? media.evalTop(env) :
|
||||
media.evalNested(env)
|
||||
},
|
||||
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) },
|
||||
find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) },
|
||||
@@ -93,9 +94,9 @@ tree.Media.prototype = {
|
||||
return new(tree.Ruleset)([], []);
|
||||
},
|
||||
permute: function (arr) {
|
||||
if (arr.length == 0) {
|
||||
if (arr.length === 0) {
|
||||
return [];
|
||||
} else if (arr.length == 1) {
|
||||
} else if (arr.length === 1) {
|
||||
return arr[0];
|
||||
} else {
|
||||
var result = [];
|
||||
|
||||
@@ -48,3 +48,29 @@
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.a {
|
||||
background: black;
|
||||
}
|
||||
@media handheld {
|
||||
.a {
|
||||
background: white;
|
||||
}
|
||||
}
|
||||
@media handheld and (max-width: 100px) {
|
||||
.a {
|
||||
background: red;
|
||||
}
|
||||
}
|
||||
.b {
|
||||
background: black;
|
||||
}
|
||||
@media handheld {
|
||||
.b {
|
||||
background: white;
|
||||
}
|
||||
}
|
||||
@media handheld and (max-width: 200px) {
|
||||
.b {
|
||||
background: red;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,4 +52,24 @@ body {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.mediaMixin(@fallback: 200px) {
|
||||
background: black;
|
||||
|
||||
@media handheld {
|
||||
background: white;
|
||||
|
||||
@media (max-width: @fallback) {
|
||||
background: red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.a {
|
||||
.mediaMixin(100px);
|
||||
}
|
||||
|
||||
.b {
|
||||
.mediaMixin();
|
||||
}
|
||||
Reference in New Issue
Block a user