Closed dakom closed 2 years ago
fwiw - potential showstopper for this particular use-case (but not the general idea)
lit-element does its own batching of updates and rendering, so even if an element theoretically has some child - there's no guarantee that it's actually rendered until after lit-element's promises settle. Specifically a promise from updateComplete
.
For example (using JS and assuming my-container renders some element with id="child-id"
):
const element = document.createElement("my-container");
document.body.appendChild(element);
console.log(element.shadowRoot.getElementById("child-id")); //null
element.updateComplete.then(() => {
console.log(element.shadowRoot.getElementById("child-id")); //okay
});
Closing this for now, it's a bit too generic and I can't remember what I had in mind at the time.
Realistically, Dominator renders custom elements just fine, and all that's needed is to carefully plan out slots for placing children.
There's other utilities specific to web components which are useful, of course, but imho those should be opened as specific issues if/when they come up.
Consider the following... there's these CustomElements that are pre-registered and created via something like lit-element:
sticker-book
sticker-menu
sticker-image
sticker-frame
Some of them are setup to have meaningful properties that should be set from the outside (for example,
sticker-frame
might play an animation and let itsstep
be driven from an external clock)dominator wants to mount
sticker-book
to the top-level body. So far so good. But the problem is that the other elements are actually inside ofsticker-book
's shadow dom. It may look like this:And lets say
sticker-image
is setup to react on itsactive
property change such that it will render either:or
So dominator should be able to:
sticker-image
items in the list (at id="list")In other words, through dominator, with the above setup it should be possible to easily drive the final
step
property onsticker-frame
. However, if the top levelactive
sticker is changed, then it must switch to set thestep
property on the newsticker-frame
@Pauan noted that it is currently possible, but may require some ugly workarounds, and that macros will make this much more elegant. Also that since it fundamentally boils down to working with pre-existing nodes, it will help with server-side rendering as well.