Skip to content

Commit 3ea0333

Browse files
author
Steven Orvell
committed
Make properties replacement robust against properties which start with a leading ;
1 parent 756ef1b commit 3ea0333

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

‎src/lib/style-properties.html‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,24 @@
147147
// note: we do not yet support mixin within mixin
148148
valueForProperties: function(property, props) {
149149
var parts = property.split(';');
150-
for (var i=0, p, m; (i<parts.length) && (p=parts[i]); i++) {
151-
m = p.match(this.rx.MIXIN_MATCH);
152-
if (m) {
153-
p = this.valueForProperty(props[m[1]], props);
154-
} else {
155-
var pp = p.split(':');
156-
if (pp[1]) {
157-
pp[1] = pp[1].trim();
158-
pp[1] = this.valueForProperty(pp[1], props) || pp[1];
150+
for (var i=0, p, m; i<parts.length; i++) {
151+
if (p = parts[i]) {
152+
m = p.match(this.rx.MIXIN_MATCH);
153+
if (m) {
154+
p = this.valueForProperty(props[m[1]], props);
155+
} else {
156+
var pp = p.split(':');
157+
if (pp[1]) {
158+
pp[1] = pp[1].trim();
159+
pp[1] = this.valueForProperty(pp[1], props) || pp[1];
160+
}
161+
p = pp.join(':');
159162
}
160-
p = pp.join(':');
163+
parts[i] = (p && p.lastIndexOf(';') === p.length - 1) ?
164+
// strip trailing ;
165+
p.slice(0, -1) :
166+
p || '';
161167
}
162-
parts[i] = (p && p.lastIndexOf(';') === p.length - 1) ?
163-
// strip trailing ;
164-
p.slice(0, -1) :
165-
p || '';
166168
}
167169
return parts.join(';');
168170
},

‎test/unit/custom-style.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
</style>
7878
<style is="custom-style">
7979
.bag {
80-
@apply(--bag);
80+
;@apply(--bag);
8181
}
8282

8383
.italic {

0 commit comments

Comments
 (0)