I am using polymer v1.9.1 and testing on Chrome.
I have a custom element containing a <paper-input>
, and I want its text color to depend on some other property. This color is determined by the custom properties --paper-input-container-input-color
or --primary-text-color
, so I set a class-dependent value for those:
#input { --primary-text-color: red; }
#input.green { --primary-text-color: green; }
<paper-input id='input' class$='[[_getClasses(checked)]]'></paper-input>
_getClasses: function(checked) { return checked ? '':'green'; }
The text is always red, I guess because of this limitation in the shim (which I guess my browser must be using). So I add a call to updateStyles
:
_getClasses: function(checked) {
this.async(function() {
this.$.input.updateStyles();
});
return checked ? '':'green'; }
}
Now it works correctly after checked
first changes, but the initial state is incorrect (ie if checked
is initially false, it is initially red but should be green). I tried adding another async(updateStyles())
to ready
but no luck (yet if I call input.updateStyles() from the javascript console it corrects itself). How can I work around this?
Complete example: http://embed.plnkr.co/VC1ZMw9iyUO3K2SQq5Oy/