11ty / 11ty/webc

Declarative shadow DOM template is rendering inside of itself

Open
#185 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.4k
Forks
46
Avg merge
10m
Merged PRs (30d)
2

Description

I'm trying to use the web standard declarative shadow dom to render my component. I'd like the slotted content not to be compiled away, but would live with compiler magic if the page would at least print. but instead, slotted content isn't rendering to the page, instead, It's printing to a triple-nested template (see below)

_components/inline-notification.webc

<template shadowroot="open" shadowrootmode="open">
  <style>/*...*/</style>
  <h3 @text="title ?? type"></h3>
  <slot id="content"></slot>
</template>

some-page.webc.md

<inline-notification type="tip">

This page is a HOW-TO guide. For detailed docs on the `ApolloQuery` interface 
see the [API docs](/api/core/interfaces/query/)

</inline-notification>

EXPECTED:

<inline-notification type="tip">
  <template shadowroot="open" shadowrootmode="open">
    <style>
    </style>
    <slot></slot>
  </template>
  <p>This page is a HOW-TO guide. For detailed docs on the <code>ApolloQuery</code> interface see the <a href="/api/core/interfaces/query/">API docs</a></p>
</inline-notification>

ACTUAL html:

<inline-notification type="tip">
<template shadowroot="open" shadowrootmode="open">
  <style>
  </style>
  
<template shadowroot="open" shadowrootmode="open">
  <style>
  </style>
  
<template shadowroot="open" shadowrootmode="open">
  <style>
  </style>
<p>This page is a HOW-TO guide. For detailed docs on the <code>ApolloQuery</code> interface
see the <a href="/api/core/interfaces/query/">API docs</a></p>
</template>

</template>

</template>
</inline-notification>

I've tried many combinations of slot, nokeep, keep, raw, template, etc, nothing seems to work.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use components/inline-notification.webc and some-page.webc.md as the reproduction inputs, then inspect the rendering path for declarative shadow DOM and slotted content. Done means the generated HTML has one shadow-root template and preserves the page content as the expected slotted paragraph rather than nesting templates.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.