> Javascript
> you complain about objects
> don't magically solve
> raw WCs vs helpers
etc. etc. etc.
And then you wonder why I'm so set against WebComponents. Because you (and Rob Dodson and other WebComponent proponents) are entirely blind to how bad WebComponent APIs are. I dunno, maybe your goal isn't to "sell" WebComponents, but to sell Polymer.
WebComponent API is bad not because "we complain about how Javascript objects are". We complain because WebComponents API is horrendously bad, and that was a deliberate design choice.
Current line of defence is "oh, it's just low level API" or "oh, it's just how Javascript is", both of which are at best patently false.
Here's code to create one single property with one single synced attribute. One. single. property/attribute pair. One.
set transitionDuration(value) {
this.setAttribute('transition-duration', value);
}
get transitionDuration() {
return this.getAttribute('transition-duration');
}
static get observedAttributes() {
return ['transition-duration'];
}
attributeChangedCallback(name, oldVal, newVal) {
if (name === 'transition-duration') {
// do something
}
}
There is no reality where this is good API design. There is no reality where "this is how objects work in Javascript" is an excuse.
This is objectivly bad API design. Bad developer experience. However, you and all other webcomponent proponents completely ignore this fact, and dismiss any and all complaints out of hand.
Of course you do. You've got Polymer to promote [1]. If WebComponents had better APIs, there would be no need for Polymer, would there. Because here's how Polymer solves the problem, despite this being "oh, that's how Javascript works".
static get properties() {
return {
transitionDuration: {
type: Number,
readOnly: false,
reflectToAttribute: true,
observer: 'methodName'
}
}
}
Oh. My. God. This is doable without any excuses about how Javascript works? Really? Who would've thunk it?
[1] Hell, even in your "rebuttal" of criticism towards WebComponents here's what you write:
> To show how absolutely easy this is, and how off-base the DX complain is, here's how easy a Polymer 2 + TypeScript element is
Were we talking about the bad DX of Polymer? No. You are totally entirely absolutely blind to the fact though. Because in your mind WebComponents === Polymer. And, sadly, for all intents and purposes it's true.
edit: removed some erroneously pasted code