Is it an intended behavior of Polymer, that beforeRegister() method is executed on a plain HTMLElement? This leads to an error when using an arrow function in the properties-declaration within a computed property value. It fails to resolve this.$ because this is a native HTMLElement, meanwhile the object that function is invoked upon is the extended Polymer Element at runtime (which works if a normal function is used)?
This does not work:
class TestComponent {
beforeRegister() {
/* during beforeRegister() execution `this` is a `HTMLElement`*/
this.is = 'test-component';
this.properties = {
_testElement: {
type: Object,
value: () => this.$.testElement
}
};
}
}
This does work:
class TestComponent {
beforeRegister() {
this.is = 'test-component';
this.properties = {
_testElement: {
type: Object,
value: function() {
/* `this` is an instance of TestComponent */
return this.$.testElement
}
}
};
}
}
It is not a big issue, but I am wondering, whether it is an issue towards ES6 support in Polymer and will be fixed or whether it is an intended behavior.