Skip to content

Commit

Permalink
Make properties replacement robust against properties which start wit…
Browse files Browse the repository at this point in the history
…h a leading `;`
  • Loading branch information
Steven Orvell committed Jul 30, 2015
1 parent 756ef1b commit 3ea0333
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
30 changes: 16 additions & 14 deletions src/lib/style-properties.html
Expand Up @@ -147,22 +147,24 @@
// note: we do not yet support mixin within mixin
valueForProperties: function(property, props) {
var parts = property.split(';');
for (var i=0, p, m; (i<parts.length) && (p=parts[i]); i++) {
m = p.match(this.rx.MIXIN_MATCH);
if (m) {
p = this.valueForProperty(props[m[1]], props);
} else {
var pp = p.split(':');
if (pp[1]) {
pp[1] = pp[1].trim();
pp[1] = this.valueForProperty(pp[1], props) || pp[1];
for (var i=0, p, m; i<parts.length; i++) {
if (p = parts[i]) {
m = p.match(this.rx.MIXIN_MATCH);
if (m) {
p = this.valueForProperty(props[m[1]], props);
} else {
var pp = p.split(':');
if (pp[1]) {
pp[1] = pp[1].trim();
pp[1] = this.valueForProperty(pp[1], props) || pp[1];
}
p = pp.join(':');
}
p = pp.join(':');
parts[i] = (p && p.lastIndexOf(';') === p.length - 1) ?
// strip trailing ;
p.slice(0, -1) :
p || '';
}
parts[i] = (p && p.lastIndexOf(';') === p.length - 1) ?
// strip trailing ;
p.slice(0, -1) :
p || '';
}
return parts.join(';');
},
Expand Down
2 changes: 1 addition & 1 deletion test/unit/custom-style.html
Expand Up @@ -77,7 +77,7 @@
</style>
<style is="custom-style">
.bag {
@apply(--bag);
;@apply(--bag);
}

.italic {
Expand Down

0 comments on commit 3ea0333

Please sign in to comment.