Skip to content

Commit

Permalink
Fix for BEM-like CSS selectors under media queries, fixes #2639.
Browse files Browse the repository at this point in the history
Small optimization for produced CSS (empty rules produced semicolon before, now empty string).
  • Loading branch information
nazar-pc committed Nov 1, 2015
1 parent 30da1b3 commit 35c89f1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/css-parse.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
},

_hasMixinRules: function(rules) {
return (rules[0].selector.indexOf(this.VAR_START) >= 0);
return rules[0].selector.indexOf(this.VAR_START) === 0;
},

removeCustomProps: function(cssText) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/style-properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
p || '';
}
}
return parts.join(';');
return parts.filter(function(v) {return v;}).join(';');
},

applyProperties: function(rule, props) {
Expand Down
17 changes: 17 additions & 0 deletions test/unit/custom-style.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@
border: 20px solid blue;
}
</style>
<style>
.foo--bar {
border-top : 3px solid red;
}
</style>
<style is="custom-style">
@media (min-width: 1px) {
.foo--bar {
border-top : 20px solid blue;
}
}
</style>
</head>
<body>
<div class="italic">italic</div>
Expand All @@ -143,6 +155,7 @@

<div class="foo"></div>

<div class="foo--bar style-scope"></div>

<dom-module id="x-baz">
<style>
Expand Down Expand Up @@ -385,6 +398,10 @@
document.body.removeChild(d);
});

test('BEM-like CSS selectors under media queries', function() {
assertComputed(document.querySelector('.foo--bar'), '3px');
});

});


Expand Down

0 comments on commit 35c89f1

Please sign in to comment.