Hacker News new | ask | show | jobs
by tomkinson 2950 days ago
Imagine you had a chat, and 30 videos in the chat.

30 play buttons 30 vulume sliders 30 pause buttons Etc

That's a lot in the DOM.

So intead you put the html5 video player components in shadowDOM and reference as needed. Only have them once then.

2 comments

ShadowDOM and the other parts of the web components specs don't do any of that kind of de-duplication which you describe, sorry.
But they don't have the same state. Some of them are half run. Some of them have sound off. Some are paused or playing. One is selected.

Is the state separated from structure ?

State can be orchestrated from the parent document. Custom elements can implement their own APIs.
So what's the difference with a webcomponent ?