[WICG/webcomponents] Clarify that declarative custom element definitions don't contain declarative shadow roots. (PR #1101)

The current Declarative Custom Elements Strawman was authored before Declarative Custom Elements was specified, and the pattern of putting shadow root instance options on the `<template>` element. Now that that pattern does exist, it has created something of an semantic ambiguity with the strawman syntax. (with the assumption that `shadowmode` should be updated to `shadowrootmode`).

In this example, is `<template shadowmode="open">` intended to do?

```html
<definition name="my-element" constructor="MyElement">
    <template shadowmode="open">~</template>
</definition>
```

Does it:
1. Create a shadow root on the `<definition>` element
2. Define a template with options to be used to initialize instance shadow roots.

If the answer is (2), then we have the same syntax with two different behaviors: one creates a shadow root instance, one defines future shadow roots.

Since the strawman was created before DSD, it doesn't seem like this collision was intended. I think to separate DSD from declarative custom elements, even just in this strawman syntax, we should make a small edit to put the options on a new element. This has the benefit of shortening the option names by not requiring the `shadowroot` prefix on every one.

```html
<definition name="my-element" constructor="MyElement">
    <shadowoptions mode="open"></shadowoptions>
    <template>~</template>
</definition>
```

cc @rniwa 
You can view, comment on, or merge this pull request online at:

  https://github.com/WICG/webcomponents/pull/1101

-- Commit Summary --

  * Clarify that declarative custom element definitions don't contain declarative shadow roots.

-- File Changes --

    M proposals/Declarative-Custom-Elements-Strawman.md (12)

-- Patch Links --

https://github.com/WICG/webcomponents/pull/1101.patch
https://github.com/WICG/webcomponents/pull/1101.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/pull/1101
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/pull/1101@github.com>

Received on Saturday, 12 April 2025 18:16:26 UTC