I created this component to demonstrate my question. This component works in chrome and firefox, as expected. But if I write this.$.wrapper.setAttribute('class','blue');
instead of this.$.wrapper.setAttribute('class','blue style-scope poly-test');
it stops working in firefox.
Is this the preferred way to change classes on shadow dom elements inside an event handler, or am I doing something accidentally right, that might break in a future version?
Also, why do I have to specify style-scope
and my element name as a class manually for firefox?
<link rel="import" href="../js/bower_components/polymer/polymer.html">
<dom-module id="poly-test">
<style>
.blue { border: 10px solid blue; }
.red { border: 10px solid red; }
#wrapper { font-weight: bold; font-size: 42px; }
</style>
<template>
<div id="wrapper" class="red"><content></content></div>
</template>
</dom-module>
<script>
Polymer({
is: 'poly-test',
properties: {'blue': { type: 'Boolean', value: false }},
listeners: { 'click': 'clickHandler' },
clickHandler: function () {
this.blue = !this.blue;
if (this.blue) {
this.$.wrapper.setAttribute('class','blue style-scope poly-test');
} else {
this.$.wrapper.setAttribute('class','red style-scope poly-test');
}
this.updateStyles();
}
});
</script>