From 1d34cef032a0aedc4e169db20fce0bae0ffe26e5 Mon Sep 17 00:00:00 2001 From: Westbrook Johnson Date: Fri, 22 Apr 2022 09:57:19 -0400 Subject: [PATCH] quick drop --- README.md | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d5dccde..af78790 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,73 @@ -# declarative-custom-elements -Explainer draft for specifying an approach to Declarative Custom Elements +# Declarative Custom Elements +### A discussion... + +## Problem +Imperative JS code is required to unlock the power of [Custom Elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements), [Shadow DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM), and other "web components" APIs. This is particularly true when these APIs are used in concert with each other. A declarative API would open the door for things like: + +- non-JS developers being given the power of custom elements +- having custom element definitions available as parse time without requireing the jump over to the JS thread early in the document parse +- others? + +*Questions:* Have we come to a future where "web components" amount to _just_ Custom Elements and Shadow DOM? Could we benefit from including other specs in this conversation? Possibly: + +- [constructible stylesheets](https://web.dev/constructable-stylesheets/) +- [adoptedStyleSheets](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets) +- [aria delegation](https://leobalter.github.io/cross-root-aria-delegation/) (possibly implied but also not currently "spec", only proposal) +- [scoped registries](https://github.com/WICG/webcomponents/issues/716) +- others? see [current Web Components Community Group priorities](https://w3c.github.io/webcomponents-cg/) + +## Existing research +*NOTE:* It would be great to get someone with specific experience with these technologies to write up a demo outlining the declarative nature of components in their context. + +- Vue +- Svelte +- [Declarative Shadow DOM](https://web.dev/declarative-shadow-dom/) +- [Declarative CSS modules](https://github.com/WICG/webcomponents/issues/939) +- [x-element](https://www.npmjs.com/package/astro-xelement) from Astro +- [decorate element](https://matthewphillips.info/programming/posts/decorate-element/) + - cons: much like DSD does not allow for scripting. +- others? + +Previous conversation in this space have halted at "do we have enough coverage of exisiting paradigms in the room?", let's address that early and often! + +## Dreams +I would could this as a smashing success if we were able to do something _like_ the following, but understand this is more of a starting place than necessarily the API that we should drive towards. + +1. *External "module"* + ```html + + + + ``` +2. *Inline "module"* + ``` + + + + + ``` + +## Related research + +### Import assertions +Can we assert that a file we import ins a"custom element" rather than JSON or CSS or in the future plain HTML? The graph created here may be secondary to a declarative "element" that encapsulated the definition and registration of a custom element. + +### Declarative Shadow DOM +This technique upgrades an existing element, `