Skip to content

Commit 35c89f1

Browse files
committed
Fix for BEM-like CSS selectors under media queries, fixes #2639.
Small optimization for produced CSS (empty rules produced semicolon before, now empty string).
1 parent 30da1b3 commit 35c89f1

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/lib/css-parse.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
},
124124

125125
_hasMixinRules: function(rules) {
126-
return (rules[0].selector.indexOf(this.VAR_START) >= 0);
126+
return rules[0].selector.indexOf(this.VAR_START) === 0;
127127
},
128128

129129
removeCustomProps: function(cssText) {

src/lib/style-properties.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
p || '';
167167
}
168168
}
169-
return parts.join(';');
169+
return parts.filter(function(v) {return v;}).join(';');
170170
},
171171

172172
applyProperties: function(rule, props) {

test/unit/custom-style.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@
119119
border: 20px solid blue;
120120
}
121121
</style>
122+
<style>
123+
.foo--bar {
124+
border-top : 3px solid red;
125+
}
126+
</style>
127+
<style is="custom-style">
128+
@media (min-width: 1px) {
129+
.foo--bar {
130+
border-top : 20px solid blue;
131+
}
132+
}
133+
</style>
122134
</head>
123135
<body>
124136
<div class="italic">italic</div>
@@ -143,6 +155,7 @@
143155

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

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

147160
<dom-module id="x-baz">
148161
<style>
@@ -385,6 +398,10 @@
385398
document.body.removeChild(d);
386399
});
387400

401+
test('BEM-like CSS selectors under media queries', function() {
402+
assertComputed(document.querySelector('.foo--bar'), '3px');
403+
});
404+
388405
});
389406

390407

0 commit comments

Comments
 (0)