← Back to release summary

shadowrootslotassignment attribute for declarative shadow DOM

Category
Web Components
Type
No developer-visible change
Status
Proposed (Chrome Proposed)
Intent stage
None

Summary

Adds the shadowrootslotassignment attribute to the <template> element, allowing declarative shadow roots to use manual slot assignment. Until now this option was only available imperatively, via attachShadow({slotAssignment: "manual"}), so components that rely on manual assignment could not create their shadow roots declaratively. The attribute accepts "named" (the default, preserving current behavior) and "manual", and is reflected by the shadowRootSlotAssignment property on HTMLTemplateElement.

Motivation

slotAssignment is fixed at shadow root creation, so components using manual slot assignment could not adopt declarative shadow DOM. The gap was raised in https://github.com/WICG/webcomponents/issues/967 and specified in the HTML Standard via https://github.com/whatwg/html/pull/12267 (merged). Both Gecko and WebKit have implemented the attribute; shipping in Chromium completes cross-engine support. This feature is opt-in; the default ("named") is unchanged.

Standards & signals

View on chromestatus.com