SAME THING IN VueJS:
SAME THING IN React:
Things I wanted to achieve:
- completely native implementation
- stateless rendering of template
- content-distribution via
<slot>
API - shadowRoot encapsulation (scoped styles and hiding implementation)
- unidirectional dataflow, achieved via:
- using attributes for data communication to children
- using dispatched events for communication with parents
- provide an example of setters for passing rich data (arrays, objects)
Things that could be optimized:
- batching multiple attribute updates
attributeChangedCallback
to one render cycle - attributeMarshalling (syncing attributes to obj properties)
Here are some best practices I followed: https://developers.google.com/web/fundamentals/web-components/best-practices