[x3d-public] HTML Imports and ShadowDOM experiments

Andreas Plesch andreasplesch at gmail.com
Sat Jul 22 13:01:31 PDT 2017


On Fri, Jul 21, 2017 at 10:24 AM, Andreas Plesch <andreasplesch at gmail.com>
wrote:

>
> ...
> It could also be fruitful to investigate how custom elements with
> templates compare with protos in detail. There seems to be match in purpose
> and ability.
>

I investigated a bit more how to use web components' slotted templates with
x3dom. Slots are placeholders inside templates which can be assigned
content. The assignment works only when a template is used in a shadow
root. The shadow host can provide the content for the slots. It turns out
that there are too many obstacles to make this approach to macro's or
protos viable. First, the shadowing disrupts the parent-child relationship
between shadow host (a group or transform) and the template in the shadow
root. The shadow root is intentionally a root of a new document fragment.
Second, the shadow DOM does not actually change when the slots are
populated. The slot elements merely get an additional assignedNodes
property which the web browser automatically uses to render if it knows how
to. x3dom has this responsibility and would need to know how to deal with
slots explicitly. Here is a related discussion:

https://github.com/w3c/webcomponents/issues/611

A-Frame and other libraries are similarly affected. A-Frame does not
support shadow DOM use.

It may be possible to process the attached and populated template to
replace slot elements with their corresponding assigned nodes. This leaves
the first problem or parenting (a universal one !). One solution may be to
move the shadow root nodes out and into the light dom under the shadow
host. This defeats encapsulation. One still gets the templating but overall
this approach will only work if web browsers would understand how to render
x3d natively. At this point I think it is even difficult to do this with
svg.

-Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170722/e7fef9d7/attachment.html>


More information about the x3d-public mailing list