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.

Note
NOTE Mixed shadow mode is available as a developer preview. This feature isn't generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. All commands, parameters, and other features are subject to change or deprecation at any time, with or without notice. Don't implement functionality developed with these commands or tools.

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.

// native.js
import { LightningElement } from 'lwc';

export default class NativeComponent extends LightningElement {
    static shadowSupportMode = '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 the shadowSupportMode value from its superclass. reset applies only if the component’s superclass is using any and no parent components are using any.

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

Popular posts from this blog

IsVisibleInSelfService on Task salesforce

Too many batch retries in the presence of Apex triggers and partial failures.

Governor limit SOQL 101 being suppressed