Skip to content

Declarative shadow DOM: <template shadowrootmode> is parsed as an inert template, nothing inside renders #923

Description

@luis-serrano-l

Version: blitz-dom / blitz-html 0.3.0-beta.2 (crates.io), rendered headless through HtmlDocument::from_html + blitz_paint::paint_scene with anyrender_vello_cpu.

<template shadowrootmode="open"> is parsed as an inert template (html_sink.rs: get_template_contents has a // TODO: implement templates properly), so a page that relies on declarative shadow DOM renders nothing from the template and shows its light-DOM children unslotted.

Repro

<!doctype html>
<body>
  <template shadowrootmode="open">
    <h1>Shadow heading</h1>
    <slot name="a"><p>placeholder for a</p></slot>
  </template>
  <div slot="a">Slotted content</div>
</body>

Expected (Chrome 111+, Firefox 123+, Safari 16.4+): <body> gets an open shadow root; "Shadow heading" renders, and "Slotted content" renders in place of the placeholder.

Actual: nothing from the template is rendered. query_selector("h1") finds no node with a layout box; "Slotted content" renders as an ordinary block.

Context

I hit this using Blitz as the render engine for a zero-JS server-side component library's test suite, where out-of-order streaming ships the page inside a DSD root on <body> and appends <div slot=…> chunks later in the byte stream. Every other page in that suite renders fine through Blitz.

#889 / #892 add shadow trees and slots but explicitly leave the declarative parser path out ("Not in this PR"). This issue is to track that remaining piece: html5ever's TreeSink::get_template_contents + the shadowrootmode attribute attaching a shadow root to the template's parent, with the template's children moved into it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions