tbranyen/diffhtml

diffhtml-components outside api

obedm503 opened this issue · 5 comments

when someone from the outside wants to update a prop on the WebComponent instance, should they set the property or set the property on the prop object? does such property being updated cause a rerender or is that just with changed attributes?

Actually working on updating this right now! For Web Components, simply setting them as attributes will set them on the instance (as a property), remove & set an attribute (to trigger attributeChangedCallback), and then the component can look at the property to get updated properly.

Note: this will only work with import { WebComponent } from 'diffhtml-components'.

Ah wait, are you asking if you build a component using WebComponent and want to use it outside how do you update it? I think you'd need to set the property and then wire up a getter to set the attribute to trigger an update.

Or maybe call this.forceUpdate() in the getter.

what if from the outside a WebComponent looked just like a custom element made from extending HTMLElement. It'd be nice if diffhtml-components automatically setup setters and getters from the proptypes and those setters update the inner props object and triggered a render. the getters would just get from the props object

so this turned into a feature request

This has been done for a while and I just forgot to close this out.