Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

WebKit 3 min read Announcement mediumAdept

Declarative Shadow DOM

Safari Technology Preview 162 enables declarative shadow DOM by default. A `template` element with a `shadowrootmode` attribute attaches its content as a shadow root on the parent element, so shadow trees work in server-side rendering and in no-JavaScript contexts such as email clients. Scripts can later reach the shadow root through `ElementInternals`. For backwards compatibility, `attachShadow()` on such an element returns the existing root emptied of its children instead of throwing. Parser APIs like `innerHTML` and `DOMParser` deliberately ignore the attribute to avoid new XSS vectors. A new `cloneable` option, set automatically for declarative roots, lets `cloneNode()` and `importNode()` copy shadow roots along with their hosts.

Assumes: Web ComponentsShadow DOM basicsCustom elements

Related posts

  • New WebKit Features in Safari 15.4

    WebKit mediumAdept

    Safari 15.4 ships over 70 WebKit additions, led by the <dialog> element with ::backdrop, lazy-loaded images, the :has() parent selector (shipped first in Safari), Cascade Layers, CSS containment, and new small/large/dynamic viewport units (svh, lvh, dvh and friends) that fix mobile viewport sizing. Other web platform additions include BroadcastChannel, Web Locks, structuredClone, Array at()/findLast(), Object.hasOwn(), and several Intl API upgrades. Web apps gain manifest-declared icons and ServiceWorker Navigation Preload. Security changes add CSP Level 3 features such as 'strict-dynamic' and remove the XSS Auditor, and many -webkit- prefixed properties now have unprefixed equivalents.

  • WebKit Features in Safari 16.4

    WebKit mediumAdept

    Safari 16.4 ships 135 new web features and over 280 polish updates. The headline additions are Web Push and the Badging API for Home Screen web apps on iOS and iPadOS, Declarative Shadow DOM and ElementInternals for Web Components, and a large batch of CSS features. The CSS work includes margin-trim, lh/rlh units, font-size-adjust, Relative Color Syntax, @property, Media Queries level 4 range syntax and CSS Typed OM. JavaScript gains RegExp lookbehind, and HTML gains lazy-loaded iframes. Most features come with short code examples showing typical usage.

  • WebKit Features in Safari 16.5

    WebKit easyNovice

    Safari 16.5 is mainly a polish and bug-fix release that adds CSS Nesting, the :user-valid and :user-invalid pseudo-classes, Apple Pay support for pre-orders and deferred payments, and disabling of the WebCodecs API in Lockdown Mode. Nesting still requires nested element selectors to start with a symbol such as &, a limitation the CSS Working Group hopes to remove. The new form pseudo-classes wait for user interaction before flagging input as invalid, which removes the need for JavaScript workarounds, and they pair well with :has(). Dozens of fixes cover CSS margin-trim, scroll snapping, media playback, WASM SIMD and Web Inspector.

  • ElementInternals and Form-Associated Custom Elements

    WebKit mediumAdept

    Safari Technology Preview 162 enables ElementInternals and form-associated custom elements by default, letting custom elements set default ARIA roles and labels and take part in form submission and validation. Calling attachInternals() and setting ariaRole avoids the old pattern of adding a role attribute in the constructor, which blocked page authors from overriding it. Declaring static formAssociated = true enables setFormValue, setValidity and reportValidity with native validation UI and :invalid styling. The lifecycle callbacks formAssociatedCallback, formResetCallback, formDisabledCallback and formStateRestoreCallback are also available, though WebKit currently supports only string state and not autocomplete restoration.

  • New WebKit Features in Safari 15.5

    WebKit easyNovice

    Safari 15.5 is mostly a polish and bug-fix release, adding three developer-facing technologies: the HTML `inert` attribute, which makes an element non-interactive and hides it from assistive technologies; the CSP Level 3 `worker-src` directive for restricting worker script sources; and WKWebView `minimumViewportInset`/`maximumViewportInset` APIs so apps can support the new CSS small, large and dynamic viewport units. A long list of fixes covers CSS (`position: sticky`, `aspect-ratio`, `background-clip: text`), Web APIs, CSP, media/HLS playback, WebRTC, WebGL multisampling, WebAuthn spec alignment and Safari extensions.

The quest for software engineering knowledge.

Look:
Layout: