Open yoshuawuyts opened 1 year ago
We should do this using Declarative Shadow DOM.
<template>
tag on MDNGiven this HTML:
<host-element>
<template shadowrootmode="open">
<style>shadow styles</style>
<h2>Shadow Content</h2>
<slot></slot>
</template>
<h2>Light content</h2>
</host-element>
We should be able to write this Rust code:
CustomElement::new("host-element")
.template(|t| t
.shadow_root_mode("open")
.style("shadow styles)
.h2(|h2| h2.text("Shadow Context"))
.slot(|_|))
.h2(|h2| h2.text("Light Content");
CustomElement
type to the root of html
data-
propertiesCustomElement
can have every single node type as a childCustomElement
can be a child of every single node typetemplate
with the non-standard shadow_root_mode
property. We should do this declaratively by adding new custom .json
mixin files.
Added the "help wanted" label to this. This should be fairly self-contained, and probably a fun one to pick up if anyone wants to. Doing this should enable us to build modular component-based server-rendered pages, which seems like a pretty big deal.
It should be possible to define
<custom-element></custom-element>
elements, and append them to other elements. We probably need to:CustomElement
typeCustomElement
as a child