Mixed shadow mode is available as a developer preview with Sprint'23 release
Build Components in Mixed Shadow Mode (Developer Preview)
With mixed shadow mode, Lightning web components can use native shadow DOM even when the synthetic shadow polyfill is applied.
Where: This change applies to custom Lightning web components in Lightning Experience, Experience Builder sites, and all versions of the Salesforce mobile app. This change also applies to Lightning web components open source.
Why: All major browsers now support shadow DOM. Salesforce maintains the synthetic shadow polyfill for legacy browsers such as older versions of Microsoft Edge. To simplify development and testing, the polyfill is used even on browsers that support shadow DOM. With mixed shadow mode, you gain the speed and efficiency of using native shadow as much as possible in your app. And you can more readily migrate to use native shadow fully in the future.
How: Mixed shadow mode is disabled by default. Contact Salesforce Customer Support to enable mixed shadow mode.
To enable mixed shadow mode on a component, set the static shadowSupportMode
property to any
.
Valid values for shadowSupportMode
include:
any
—Renders the whole component subtree in native shadow DOM where possible. If the browser doesn't support shadow DOM, the subtree renders in synthetic shadow.reset
—Enables a subclass to opt out of receiving theshadowSupportMode
value from its superclass.reset
applies only if the component’s superclass is usingany
and no parent components are usingany
.
Lightning Experience and Experience Cloud include the synthetic shadow polyfill by default. When the polyfill is present, reset
defaults to synthetic shadow. If the polyfill isn't present, such as in Lightning Out or LWC Open Source, shadowSupportMode
has no impact and components render in native mode.
By default, slotted content is rendered in native shadow. Slotted content isn’t descended from the component it’s nested in, so you can slot synthetic shadow content into a native shadow component. This also means that slotted content isn’t affected by how your browser renders the #shadow-root
of the component containing the slot. For example, if your browser renders a native component in synthetic shadow, native content slotted into that component is still rendered in native shadow.
Comments
Post a Comment