Skip to content
Browse files

Make properties replacement robust against properties which start wit…

…h a leading `;`
  • Loading branch information...
1 parent 756ef1b commit 3ea03332563f77d3b5b134b8bd4d900e1dfa05ce @sorvell sorvell committed
Showing with 17 additions and 15 deletions.
  1. +16 −14 src/lib/style-properties.html
  2. +1 −1 test/unit/custom-style.html
View
30 src/lib/style-properties.html
@@ -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(';');
},
View
2 test/unit/custom-style.html
@@ -77,7 +77,7 @@
</style>
<style is="custom-style">
.bag {
- @apply(--bag);
+ ;@apply(--bag);
}
.italic {

0 comments on commit 3ea0333

Please sign in to comment.
Something went wrong with that request. Please try again.