WebReflection / hyperHTML-Element

An extensible class to define hyperHTML based Custom Elements.
ISC License
202 stars 25 forks source link

double render call on initial element creation #71

Closed 2alin closed 3 years ago

2alin commented 3 years ago

this.render() is been called two times when the element is initially created. Please check this demo.

There's no issue in subsequent changes of observed attribute values.

WebReflection commented 3 years ago

Calling render is super cheap, while avoiding this is super cumbersome. As this should never be a real world issue, in terms of performance, I’m not sure there’s anything to do

WebReflection commented 3 years ago

To be fair, if you have an attributes listener the callback is going to be called for each attribute change, that’s how custom elements work in platform. If you do anything in attributes callback, such anything would be invoked multiple times. Accordingly, unless you have a better idea on how this should work, I’d close this as won’t fix, as that’s what you get if you call render both in create, and on attributes, which are triggered on custom elements update, one after the other, by specs.

2alin commented 3 years ago

Sounds fair, thanks for clarifying the expected behavior. Feel free to close this issue as you suggested.

WebReflection commented 3 years ago

You can reproduce this behavior without any library, which is how specs work, and imho, for a good reason. Hope you don’t mind me closing this, but again, if you have a better idea on how to avoid how specs work, I’m listening 👍