Fix one issue with media queries and detached rulesets, one to go

This commit is contained in:
Luke Page
2014-02-16 17:50:51 +00:00
parent b46ca11286
commit c730829d1d
4 changed files with 59 additions and 4 deletions

View File

@@ -147,6 +147,8 @@ tree.Media.prototype = {
}
},
bubbleSelectors: function (selectors) {
if (!selectors)
return;
this.rules = [new(tree.Ruleset)(selectors.slice(0), [this.rules[0]])];
}
};

View File

@@ -2,7 +2,7 @@
tree.Rule = function (name, value, important, merge, index, currentFileInfo, inline) {
this.name = name;
this.value = (value instanceof tree.Value) ? value : new(tree.Value)([value]);
this.value = (value instanceof tree.Value || value instanceof tree.Ruleset) ? value : new(tree.Value)([value]);
this.important = important ? ' ' + important.trim() : '';
this.merge = merge;
this.index = index;
@@ -46,7 +46,6 @@ tree.Rule.prototype = {
evaldValue = this.value.eval(env);
if (!this.variable && evaldValue.type === "Ruleset") {
console.log(this.index);
throw { message: "Rulesets cannot be evaluated on a property.",
index: this.index, filename: this.currentFileInfo.filename };
}

View File

@@ -45,3 +45,20 @@ html.lt-ie9 header {
.without-mixins {
b: 1;
}
@media (orientation: portrait) {
/* .wrap-media-mixin({
@media tv {
.triple-wrapped-mq {
triple: true;
}
}
});*/
}
@media (orientation: portrait) and tv {
.my-selector {
background-color: black;
}
}
.a {
test: test;
}

View File

@@ -10,8 +10,8 @@
.wrap-selector {
@c: visible;
@ruleset();
visible-one: @b;
visible-two: @c;
visible-one: @b;
visible-two: @c;
}
};
@@ -63,3 +63,40 @@ header {
.without-mixins {
@ruleset-2();
}
@my-ruleset: {
.my-selector {
@media tv {
background-color: black;
}
}
};
@media (orientation:portrait) {
@my-ruleset();
// doesn't work yet
/* .wrap-media-mixin({
@media tv {
.triple-wrapped-mq {
triple: true;
}
}
});*/
}
.wrap-media-mixin(@ruleset) {
@media widescreen {
@media print {
@ruleset();
}
@ruleset();
}
@ruleset();
}
// unlocking mixins
@my-mixins: {
.mixin() {
test: test;
}
};
@my-mixins();
.a {
.mixin();
}