@lwc/engine-core 7.0.0-alpha.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ import { AccessibleElementProperties } from '@lwc/shared';
10
10
  import { ShadowSupportMode } from './vm';
11
11
  import { Template } from './template';
12
12
  import { HTMLElementConstructor } from './base-bridge-element';
13
- import { TemplateStylesheetFactories } from './stylesheet';
13
+ import { Stylesheets } from './stylesheet';
14
14
  export interface LightningElementConstructor {
15
15
  new (): LightningElement;
16
16
  readonly prototype: LightningElement;
@@ -19,7 +19,7 @@ export interface LightningElementConstructor {
19
19
  renderMode?: 'light' | 'shadow';
20
20
  formAssociated?: boolean;
21
21
  shadowSupportMode?: ShadowSupportMode;
22
- stylesheets: TemplateStylesheetFactories;
22
+ stylesheets: Stylesheets;
23
23
  }
24
24
  type HTMLElementTheGoodParts = {
25
25
  toString: () => string;
@@ -27,10 +27,18 @@ type HTMLElementTheGoodParts = {
27
27
  type RefNodes = {
28
28
  [name: string]: Element;
29
29
  };
30
+ /**
31
+ * A `LightningElement` will always be attached to an [`HTMLElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement),
32
+ * rather than the more broad `Element` used by the generic shadow root interface.
33
+ */
34
+ export interface LightningElementShadowRoot extends ShadowRoot {
35
+ readonly host: HTMLElement;
36
+ }
30
37
  export interface LightningElement extends HTMLElementTheGoodParts, AccessibleElementProperties {
31
38
  constructor: LightningElementConstructor;
32
- template: ShadowRoot | null;
39
+ template: LightningElementShadowRoot | null;
33
40
  refs: RefNodes | undefined;
41
+ hostElement: Element;
34
42
  render(): Template;
35
43
  connectedCallback?(): void;
36
44
  disconnectedCallback?(): void;
@@ -1,5 +1,5 @@
1
1
  import { Template } from './template';
2
- import { StylesheetFactory } from './stylesheet';
2
+ import { Stylesheet } from './stylesheet';
3
3
  import { LightningElementConstructor } from './base-lightning-element';
4
4
  /**
5
5
  * Validate a template, stylesheet, or component to make sure that its compiled version matches
@@ -9,5 +9,5 @@ import { LightningElementConstructor } from './base-lightning-element';
9
9
  * @param type
10
10
  */
11
11
  export declare function checkVersionMismatch(func: Template, type: 'template'): void;
12
- export declare function checkVersionMismatch(func: StylesheetFactory, type: 'stylesheet'): void;
12
+ export declare function checkVersionMismatch(func: Stylesheet, type: 'stylesheet'): void;
13
13
  export declare function checkVersionMismatch(func: LightningElementConstructor, type: 'component'): void;
@@ -41,12 +41,9 @@ export interface ComponentDef {
41
41
  export declare function isComponentConstructor(ctor: unknown): ctor is LightningElementConstructor;
42
42
  export declare function getComponentInternalDef(Ctor: unknown): ComponentDef;
43
43
  export declare function getComponentHtmlPrototype(Ctor: unknown): HTMLElementConstructor;
44
- declare const enum PropDefType {
45
- any = "any"
46
- }
47
44
  interface PropDef {
48
45
  config: number;
49
- type: PropDefType;
46
+ type: 'any';
50
47
  attr: string;
51
48
  }
52
49
  type PublicMethod = (...args: any[]) => any;
@@ -1,11 +1,11 @@
1
1
  import { VM } from './vm';
2
2
  import { LightningElementConstructor } from './base-lightning-element';
3
3
  import { Template } from './template';
4
- import { StylesheetFactory } from './stylesheet';
4
+ import { Stylesheet } from './stylesheet';
5
5
  export declare function getTemplateOrSwappedTemplate(tpl: Template): Template;
6
6
  export declare function getComponentOrSwappedComponent(Ctor: LightningElementConstructor): LightningElementConstructor;
7
- export declare function getStyleOrSwappedStyle(style: StylesheetFactory): StylesheetFactory;
7
+ export declare function getStyleOrSwappedStyle(style: Stylesheet): Stylesheet;
8
8
  export declare function setActiveVM(vm: VM): void;
9
9
  export declare function swapTemplate(oldTpl: Template, newTpl: Template): boolean;
10
10
  export declare function swapComponent(oldComponent: LightningElementConstructor, newComponent: LightningElementConstructor): boolean;
11
- export declare function swapStyle(oldStyle: StylesheetFactory, newStyle: StylesheetFactory): boolean;
11
+ export declare function swapStyle(oldStyle: Stylesheet, newStyle: Stylesheet): boolean;
@@ -18,7 +18,9 @@ export { getComponentAPIVersion } from './component';
18
18
  export { shouldBeFormAssociated } from './utils';
19
19
  export { getComponentConstructor } from './get-component-constructor';
20
20
  export type { RendererAPI, LifecycleCallback } from './renderer';
21
- export type { ConfigValue as WireConfigValue, ContextValue as WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, } from './wiring';
21
+ export type { Stylesheets } from './stylesheet';
22
+ export type { Template } from './template';
23
+ export type { ConfigValue as WireConfigValue, ContextConsumer as WireContextConsumer, ContextProvider as WireContextProvider, ContextValue as WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, } from './wiring';
22
24
  export type { FormRestoreState, FormRestoreReason } from './vm';
23
25
  export { LightningElement } from './base-lightning-element';
24
26
  export { default as api } from './decorators/api';
@@ -5,13 +5,12 @@ import { VCustomElement, VNode } from './vnodes';
5
5
  * Function producing style based on a host and a shadow selector. This function is invoked by
6
6
  * the engine with different values depending on the mode that the component is running on.
7
7
  */
8
- export type StylesheetFactory = (stylesheetToken: string | undefined, useActualHostSelector: boolean, useNativeDirPseudoclass: boolean) => string;
8
+ export type Stylesheet = (stylesheetToken: string | undefined, useActualHostSelector: boolean, useNativeDirPseudoclass: boolean) => string;
9
9
  /**
10
- * The list of stylesheets associated with a template. Each entry is either a StylesheetFactory or a
11
- * TemplateStylesheetFactory a given stylesheet depends on other external stylesheets (via
12
- * the @import CSS declaration).
10
+ * The list of stylesheets associated with a template. Each entry is either a `Stylesheet` or
11
+ * an array of stylesheets that a given stylesheet depends on via CSS `@import` declarations.
13
12
  */
14
- export type TemplateStylesheetFactories = Array<StylesheetFactory | TemplateStylesheetFactories>;
13
+ export type Stylesheets = Array<Stylesheet | Stylesheets>;
15
14
  export declare function updateStylesheetToken(vm: VM, template: Template, legacy: boolean): void;
16
15
  export declare function getStylesheetsContent(vm: VM, template: Template): string[];
17
16
  /**
@@ -31,4 +30,4 @@ export declare function getScopeTokenClass(owner: VM, legacy: boolean): string |
31
30
  */
32
31
  export declare function getStylesheetTokenHost(vnode: VCustomElement): string | null;
33
32
  export declare function createStylesheet(vm: VM, stylesheets: string[]): VNode[] | null;
34
- export declare function unrenderStylesheet(stylesheet: StylesheetFactory): void;
33
+ export declare function unrenderStylesheet(stylesheet: Stylesheet): void;
@@ -1,13 +1,13 @@
1
1
  import { RenderAPI } from './api';
2
2
  import { SlotSet, TemplateCache, VM } from './vm';
3
- import { TemplateStylesheetFactories } from './stylesheet';
3
+ import { Stylesheets } from './stylesheet';
4
4
  import { VNodes } from './vnodes';
5
5
  export interface Template {
6
6
  (api: RenderAPI, cmp: object, slotSet: SlotSet, cache: TemplateCache): VNodes;
7
7
  /** The list of slot names used in the template. */
8
8
  slots?: string[];
9
9
  /** The stylesheet associated with the template. */
10
- stylesheets?: TemplateStylesheetFactories;
10
+ stylesheets?: Stylesheets;
11
11
  /** The string used for synthetic shadow style scoping and light DOM style scoping. */
12
12
  stylesheetToken?: string;
13
13
  /** Same as the above, but for legacy use cases (pre-LWC v3.0.0) */
@@ -24,4 +24,4 @@ export declare const parseFragment: (strings: string[], ...keys: (string | numbe
24
24
  export declare const parseSVGFragment: (strings: string[], ...keys: (string | number)[]) => () => Element;
25
25
  export declare function evaluateTemplate(vm: VM, html: Template): VNodes;
26
26
  export declare function computeHasScopedStyles(template: Template, vm: VM | undefined): boolean;
27
- export declare function hasStyles(stylesheets: TemplateStylesheetFactories | undefined | null): stylesheets is TemplateStylesheetFactories;
27
+ export declare function hasStyles(stylesheets: Stylesheets | undefined | null): stylesheets is Stylesheets;
@@ -1,4 +1,4 @@
1
- import { StylesheetFactory, TemplateStylesheetFactories } from './stylesheet';
1
+ import { Stylesheet, Stylesheets } from './stylesheet';
2
2
  import { LightningElementConstructor } from './base-lightning-element';
3
3
  type Callback = () => void;
4
4
  export declare const SPACE_CHAR = 32;
@@ -15,7 +15,7 @@ export declare function cloneAndOmitKey(object: {
15
15
  }, keyToOmit: string): {
16
16
  [key: string]: any;
17
17
  };
18
- export declare function flattenStylesheets(stylesheets: TemplateStylesheetFactories): StylesheetFactory[];
18
+ export declare function flattenStylesheets(stylesheets: Stylesheets): Stylesheet[];
19
19
  export declare function assertNotProd(): void;
20
20
  export declare function shouldBeFormAssociated(Ctor: LightningElementConstructor): boolean;
21
21
  export {};
@@ -2,10 +2,10 @@ import { APIVersion } from '@lwc/shared';
2
2
  import { HostNode, HostElement, RendererAPI } from './renderer';
3
3
  import { Template } from './template';
4
4
  import { ComponentDef } from './def';
5
- import { LightningElement, LightningElementConstructor } from './base-lightning-element';
5
+ import { LightningElement, LightningElementConstructor, LightningElementShadowRoot } from './base-lightning-element';
6
6
  import { ReactiveObserver } from './mutation-tracker';
7
7
  import { VNodes, VCustomElement, VNode, VBaseElement, VStaticPartElement } from './vnodes';
8
- import { TemplateStylesheetFactories } from './stylesheet';
8
+ import { Stylesheets } from './stylesheet';
9
9
  type ShadowRootMode = 'open' | 'closed';
10
10
  export interface TemplateCache {
11
11
  [key: string]: any;
@@ -29,14 +29,7 @@ export declare const enum ShadowMode {
29
29
  Native = 0,
30
30
  Synthetic = 1
31
31
  }
32
- export declare const enum ShadowSupportMode {
33
- Any = "any",
34
- Default = "reset",
35
- Native = "native"
36
- }
37
- export declare const enum LwcDomMode {
38
- Manual = "manual"
39
- }
32
+ export type ShadowSupportMode = 'any' | 'reset' | 'native';
40
33
  export interface Context {
41
34
  /** The string used for synthetic shadow DOM and light DOM style scoping. */
42
35
  stylesheetToken: string | undefined;
@@ -126,12 +119,12 @@ export interface VM<N = HostNode, E = HostElement> {
126
119
  /** The component instance. */
127
120
  component: LightningElement;
128
121
  /** The custom element shadow root. */
129
- shadowRoot: ShadowRoot | null;
122
+ shadowRoot: LightningElementShadowRoot | null;
130
123
  /**
131
124
  * The component render root. If the component is a shadow DOM component, it is its shadow
132
125
  * root. If the component is a light DOM component it the element itself.
133
126
  */
134
- renderRoot: ShadowRoot | HostElement;
127
+ renderRoot: LightningElementShadowRoot | HostElement;
135
128
  /** The template reactive observer. */
136
129
  tro: ReactiveObserver;
137
130
  /**
@@ -160,7 +153,7 @@ export interface VM<N = HostNode, E = HostElement> {
160
153
  /**
161
154
  * Any stylesheets associated with the component
162
155
  */
163
- stylesheets: TemplateStylesheetFactories | null;
156
+ stylesheets: Stylesheets | null;
164
157
  /**
165
158
  * API version associated with this VM
166
159
  */
@@ -27,7 +27,7 @@ export interface BaseVParent {
27
27
  export interface BaseVNode {
28
28
  type: VNodeType;
29
29
  elm: Node | undefined;
30
- sel: string | undefined;
30
+ sel: string;
31
31
  key: Key | undefined;
32
32
  owner: VM;
33
33
  }
@@ -35,6 +35,7 @@ export interface VScopedSlotFragment extends BaseVNode {
35
35
  factory: (value: any, key: any) => VFragment;
36
36
  type: VNodeType.ScopedSlotFragment;
37
37
  slotName: unknown;
38
+ sel: '__scoped_slot_fragment__';
38
39
  }
39
40
  export interface VStaticPart {
40
41
  readonly type: VStaticPartType;
@@ -56,7 +57,7 @@ export interface VStaticPartText extends VStaticPart {
56
57
  export type VStaticPartData = Pick<VElementData, 'on' | 'ref' | 'attrs' | 'style' | 'className'>;
57
58
  export interface VStatic extends BaseVNode {
58
59
  readonly type: VNodeType.Static;
59
- readonly sel: undefined;
60
+ readonly sel: '__static__';
60
61
  readonly key: Key;
61
62
  readonly fragment: Element;
62
63
  readonly parts: VStaticPart[] | undefined;
@@ -64,7 +65,7 @@ export interface VStatic extends BaseVNode {
64
65
  slotAssignment: string | undefined;
65
66
  }
66
67
  export interface VFragment extends BaseVNode, BaseVParent {
67
- sel: undefined;
68
+ sel: '__fragment__';
68
69
  type: VNodeType.Fragment;
69
70
  stable: 0 | 1;
70
71
  leading: VText | VComment;
@@ -72,15 +73,15 @@ export interface VFragment extends BaseVNode, BaseVParent {
72
73
  }
73
74
  export interface VText extends BaseVNode {
74
75
  type: VNodeType.Text;
75
- sel: undefined;
76
+ sel: '__text__';
76
77
  text: string;
77
78
  key: undefined;
78
79
  }
79
80
  export interface VComment extends BaseVNode {
80
81
  type: VNodeType.Comment;
81
- sel: undefined;
82
+ sel: '__comment__';
82
83
  text: string;
83
- key: 'c';
84
+ key: undefined;
84
85
  }
85
86
  export interface VBaseElement extends BaseVNode, BaseVParent {
86
87
  sel: string;
@@ -117,6 +118,11 @@ export interface VElementData extends VNodeData {
117
118
  readonly ref?: string;
118
119
  readonly slotData?: any;
119
120
  readonly slotAssignment?: string;
121
+ readonly context?: {
122
+ lwc?: {
123
+ dom?: 'manual';
124
+ };
125
+ };
120
126
  }
121
127
  export declare function isVBaseElement(vnode: VNode): vnode is VElement | VCustomElement;
122
128
  export declare function isSameVnode(vnode1: VNode, vnode2: VNode): boolean;
@@ -1,3 +1,3 @@
1
1
  export { createContextProviderWithRegister, createContextWatcher } from './context';
2
- export { ConfigCallback, ConfigValue, ContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, } from './types';
2
+ export { ConfigCallback, ConfigValue, ContextConsumer, ContextProvider, ContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, } from './types';
3
3
  export { connectWireAdapters, disconnectWireAdapters, installWireAdapters, storeWiredFieldMeta, storeWiredMethodMeta, } from './wiring';
@@ -1,20 +1,20 @@
1
1
  import type { LightningElement } from '../base-lightning-element';
2
2
  import type { HostElement } from '../renderer';
3
- export type DataCallback = (value: any) => void;
3
+ export type DataCallback<T = any> = (value: T) => void;
4
4
  export type ConfigValue = Record<string, any>;
5
5
  export type WireAdapterSchemaValue = 'optional' | 'required';
6
6
  export type ContextValue = Record<string, any>;
7
- export interface WireAdapter {
8
- update(config: ConfigValue, context?: ContextValue): void;
7
+ export interface WireAdapter<Config extends ConfigValue = ConfigValue, Context extends ContextValue = ContextValue> {
8
+ update(config: Config, context?: Context): void;
9
9
  connect(): void;
10
10
  disconnect(): void;
11
11
  }
12
- export interface WireAdapterConstructor {
13
- new (callback: DataCallback, sourceContext?: {
12
+ export interface WireAdapterConstructor<Config extends ConfigValue = ConfigValue, Value = any, Context extends ContextValue = ContextValue> {
13
+ new (callback: DataCallback<Value>, sourceContext?: {
14
14
  tagName: string;
15
- }): WireAdapter;
16
- configSchema?: Record<string, WireAdapterSchemaValue>;
17
- contextSchema?: Record<string, WireAdapterSchemaValue>;
15
+ }): WireAdapter<Config, Context>;
16
+ configSchema?: Record<keyof Config, WireAdapterSchemaValue>;
17
+ contextSchema?: Record<keyof Context, WireAdapterSchemaValue>;
18
18
  }
19
19
  export interface WireDef {
20
20
  method?: (data: any) => void;
package/dist/index.cjs.js CHANGED
@@ -1517,7 +1517,7 @@ function applyShadowMigrateMode(shadowRoot) {
1517
1517
  }
1518
1518
 
1519
1519
  /*
1520
- * Copyright (c) 2018, salesforce.com, inc.
1520
+ * Copyright (c) 2024, Salesforce, Inc.
1521
1521
  * All rights reserved.
1522
1522
  * SPDX-License-Identifier: MIT
1523
1523
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
@@ -1784,6 +1784,25 @@ LightningElement.prototype = {
1784
1784
  }
1785
1785
  return vm.shadowRoot;
1786
1786
  },
1787
+ get hostElement() {
1788
+ const vm = getAssociatedVM(this);
1789
+ if (!process.env.IS_BROWSER) {
1790
+ shared.assert.fail('this.hostElement is not supported in this environment');
1791
+ }
1792
+ const apiVersion = getComponentAPIVersion(vm.def.ctor);
1793
+ if (!shared.isAPIFeatureEnabled(9 /* APIFeature.ENABLE_THIS_DOT_HOST_ELEMENT */, apiVersion)) {
1794
+ if (process.env.NODE_ENV !== 'production') {
1795
+ logWarnOnce('The `this.hostElement` API within LightningElement is ' +
1796
+ 'only supported in API version 62 and above. Increase the API version to use it.');
1797
+ }
1798
+ // Simulate the old behavior for `this.hostElement` to avoid a breaking change
1799
+ return undefined;
1800
+ }
1801
+ if (process.env.NODE_ENV !== 'production') {
1802
+ shared.assert.isTrue(vm.elm instanceof Element, `this.hostElement should be an Element, found: ${vm.elm}`);
1803
+ }
1804
+ return vm.elm;
1805
+ },
1787
1806
  get refs() {
1788
1807
  const vm = getAssociatedVM(this);
1789
1808
  if (isUpdatingTemplate) {
@@ -2460,13 +2479,13 @@ function internalWireFieldDecorator(key) {
2460
2479
  */
2461
2480
  function getClassDescriptorType(descriptor) {
2462
2481
  if (shared.isFunction(descriptor.value)) {
2463
- return "method" /* DescriptorType.Method */;
2482
+ return 'method';
2464
2483
  }
2465
2484
  else if (shared.isFunction(descriptor.set) || shared.isFunction(descriptor.get)) {
2466
- return "accessor" /* DescriptorType.Accessor */;
2485
+ return 'accessor';
2467
2486
  }
2468
2487
  else {
2469
- return "field" /* DescriptorType.Field */;
2488
+ return 'field';
2470
2489
  }
2471
2490
  }
2472
2491
  function validateObservedField(Ctor, fieldName, descriptor) {
@@ -2696,9 +2715,7 @@ function checkVersionMismatch(func, type) {
2696
2715
  const versionMatcher = func.toString().match(shared.LWC_VERSION_COMMENT_REGEX);
2697
2716
  if (!shared.isNull(versionMatcher) && !warned) {
2698
2717
  const version = versionMatcher[1];
2699
- const [major, minor] = version.split('.');
2700
- const [expectedMajor, expectedMinor] = shared.LWC_VERSION.split('.');
2701
- if (major !== expectedMajor || minor !== expectedMinor) {
2718
+ if (version !== shared.LWC_VERSION) {
2702
2719
  warned = true; // only warn once to avoid flooding the console
2703
2720
  // stylesheets and templates do not have user-meaningful names, but components do
2704
2721
  const friendlyName = type === 'component' ? `${type} ${func.name}` : type;
@@ -3331,7 +3348,7 @@ let swappedComponentMap =
3331
3348
  let swappedStyleMap = /*@__PURE__@*/ new WeakMap();
3332
3349
  // The important thing here is the weak values – VMs are transient (one per component instance) and should be GC'ed,
3333
3350
  // so we don't want to create strong references to them.
3334
- // The weak keys are kind of useless, because Templates, LightningElementConstructors, and StylesheetFactories are
3351
+ // The weak keys are kind of useless, because Templates, LightningElementConstructors, and Stylesheets are
3335
3352
  // never GC'ed. But maybe they will be someday, so we may as well use weak keys too.
3336
3353
  // The "pure" annotations are so that Rollup knows for sure it can remove these from prod mode
3337
3354
  let activeTemplates = /*@__PURE__@*/ new WeakMultiMap();
@@ -3366,6 +3383,9 @@ function rehydrateHotTemplate(tpl) {
3366
3383
  }
3367
3384
  function rehydrateHotStyle(style) {
3368
3385
  const activeVMs = activeStyles.get(style);
3386
+ if (!activeVMs.size) {
3387
+ return true;
3388
+ }
3369
3389
  unrenderStylesheet(style);
3370
3390
  for (const vm of activeVMs) {
3371
3391
  // if a style definition is swapped, we must reset
@@ -3480,12 +3500,25 @@ function swapTemplate(oldTpl, newTpl) {
3480
3500
  }
3481
3501
  function swapComponent(oldComponent, newComponent) {
3482
3502
  if (process.env.NODE_ENV !== 'production') {
3483
- if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
3503
+ const isOldCtorAComponent = isComponentConstructor(oldComponent);
3504
+ const isNewCtorAComponent = isComponentConstructor(newComponent);
3505
+ if (isOldCtorAComponent && isNewCtorAComponent) {
3484
3506
  swappedComponentMap.set(oldComponent, newComponent);
3485
3507
  return rehydrateHotComponent(oldComponent);
3486
3508
  }
3509
+ else if (isOldCtorAComponent === false && isNewCtorAComponent === true) {
3510
+ throw new TypeError(`Invalid Component: Attempting to swap a non-component with a component`);
3511
+ }
3512
+ else if (isOldCtorAComponent === true && isNewCtorAComponent === false) {
3513
+ throw new TypeError(`Invalid Component: Attempting to swap a component with a non-component`);
3514
+ }
3487
3515
  else {
3488
- throw new TypeError(`Invalid Component`);
3516
+ // The dev-server relies on the presence of registerComponent() as a way to determine a
3517
+ // component module. However, the compiler cannot definitively add registerComponent()
3518
+ // transformation only to a component constructor. Hence the dev-server may attempt to
3519
+ // hot swap javascript modules that look like a component and should not cause the app
3520
+ // to fail. To allow that, this api ignores such hot swap attempts.
3521
+ return false;
3489
3522
  }
3490
3523
  }
3491
3524
  return false;
@@ -3548,13 +3581,13 @@ function createComponentDef(Ctor) {
3548
3581
  logError(`Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
3549
3582
  }
3550
3583
  if (!shared.isUndefined(ctorShadowSupportMode) &&
3551
- ctorShadowSupportMode !== "any" /* ShadowSupportMode.Any */ &&
3552
- ctorShadowSupportMode !== "reset" /* ShadowSupportMode.Default */ &&
3553
- ctorShadowSupportMode !== "native" /* ShadowSupportMode.Native */) {
3584
+ ctorShadowSupportMode !== 'any' &&
3585
+ ctorShadowSupportMode !== 'reset' &&
3586
+ ctorShadowSupportMode !== 'native') {
3554
3587
  logError(`Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
3555
3588
  }
3556
3589
  // TODO [#3971]: Completely remove shadowSupportMode "any"
3557
- if (ctorShadowSupportMode === "any" /* ShadowSupportMode.Any */) {
3590
+ if (ctorShadowSupportMode === 'any') {
3558
3591
  logWarn(`Invalid value 'any' for static property shadowSupportMode. 'any' is deprecated and will be removed in a future release--use 'native' instead.`);
3559
3592
  }
3560
3593
  if (!shared.isUndefined(ctorRenderMode) &&
@@ -3588,8 +3621,7 @@ function createComponentDef(Ctor) {
3588
3621
  if (!shared.isUndefined(ctorShadowSupportMode)) {
3589
3622
  shadowSupportMode = ctorShadowSupportMode;
3590
3623
  if (isReportingEnabled() &&
3591
- (shadowSupportMode === "any" /* ShadowSupportMode.Any */ ||
3592
- shadowSupportMode === "native" /* ShadowSupportMode.Native */)) {
3624
+ (shadowSupportMode === 'any' || shadowSupportMode === 'native')) {
3593
3625
  report("ShadowSupportModeUsage" /* ReportingEventId.ShadowSupportModeUsage */, {
3594
3626
  tagName: Ctor.name,
3595
3627
  mode: shadowSupportMode,
@@ -3704,7 +3736,7 @@ const lightingElementDef = {
3704
3736
  propsConfig: EmptyObject,
3705
3737
  methods: EmptyObject,
3706
3738
  renderMode: 1 /* RenderMode.Shadow */,
3707
- shadowSupportMode: "reset" /* ShadowSupportMode.Default */,
3739
+ shadowSupportMode: 'reset',
3708
3740
  formAssociated: undefined,
3709
3741
  wire: EmptyObject,
3710
3742
  bridge: BaseBridgeElement,
@@ -3728,7 +3760,7 @@ function getComponentDef(Ctor) {
3728
3760
  // avoid leaking the reference to the public props descriptors
3729
3761
  publicProps[key] = {
3730
3762
  config: propsConfig[key] || 0, // a property by default
3731
- type: "any" /* PropDefType.any */, // no type inference for public services
3763
+ type: 'any', // no type inference for public services
3732
3764
  attr: shared.htmlPropertyToAttribute(key),
3733
3765
  };
3734
3766
  }
@@ -4705,14 +4737,14 @@ function applyStyleScoping(elm, owner, renderer) {
4705
4737
  }
4706
4738
  function applyDomManual(elm, vnode) {
4707
4739
  const { owner, data: { context }, } = vnode;
4708
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && context?.lwc?.dom === "manual" /* LwcDomMode.Manual */) {
4740
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && context?.lwc?.dom === 'manual') {
4709
4741
  elm.$domManual$ = true;
4710
4742
  }
4711
4743
  }
4712
4744
  function applyElementRestrictions(elm, vnode) {
4713
4745
  if (process.env.NODE_ENV !== 'production') {
4714
4746
  const isSynthetic = vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
4715
- const isPortal = vnode.type === 2 /* VNodeType.Element */ && vnode.data.context?.lwc?.dom === "manual" /* LwcDomMode.Manual */;
4747
+ const isPortal = vnode.type === 2 /* VNodeType.Element */ && vnode.data.context?.lwc?.dom === 'manual';
4716
4748
  const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
4717
4749
  patchElementWithRestrictions(elm, {
4718
4750
  isPortal,
@@ -5089,7 +5121,7 @@ function ssf(slotName, factory) {
5089
5121
  factory,
5090
5122
  owner: getVMBeingRendered(),
5091
5123
  elm: undefined,
5092
- sel: undefined,
5124
+ sel: '__scoped_slot_fragment__',
5093
5125
  key: undefined,
5094
5126
  slotName,
5095
5127
  };
@@ -5100,7 +5132,7 @@ function st(fragmentFactory, key, parts) {
5100
5132
  const fragment = fragmentFactory(parts);
5101
5133
  const vnode = {
5102
5134
  type: 4 /* VNodeType.Static */,
5103
- sel: undefined,
5135
+ sel: '__static__',
5104
5136
  key,
5105
5137
  elm: undefined,
5106
5138
  fragment,
@@ -5118,7 +5150,7 @@ function fr(key, children, stable) {
5118
5150
  const trailing = useCommentNodes ? co('') : t('');
5119
5151
  return {
5120
5152
  type: 5 /* VNodeType.Fragment */,
5121
- sel: undefined,
5153
+ sel: '__fragment__',
5122
5154
  key,
5123
5155
  elm: undefined,
5124
5156
  children: [leading, ...children, trailing],
@@ -5235,7 +5267,16 @@ function s(slotName, data, children, slotset) {
5235
5267
  // to the vnode because the current way the diffing algo works, it will replace the original reference
5236
5268
  // to the host element with a new one. This means the new element will be mounted and immediately unmounted.
5237
5269
  // Creating a copy of the vnode to preserve a reference to the previous host element.
5238
- clonedVNode = { ...vnode, slotAssignment: data.slotAssignment };
5270
+ if (shared.isUndefined(vnode.elm)) {
5271
+ // vnode.elm is undefined during initial render.
5272
+ // We don't need to clone at this point because it doesn't need to be unmounted.
5273
+ vnode.slotAssignment = data.slotAssignment;
5274
+ }
5275
+ else {
5276
+ // Clone when the vnode.elm is defined to ensure we don't lose reference to the previous element.
5277
+ // This is specifically for slot forwarding.
5278
+ clonedVNode = { ...vnode, slotAssignment: data.slotAssignment };
5279
+ }
5239
5280
  }
5240
5281
  // If the slot content is standard type, the content is static, no additional
5241
5282
  // processing needed on the vnode
@@ -5403,10 +5444,10 @@ function f(items) {
5403
5444
  }
5404
5445
  // [t]ext node
5405
5446
  function t(text) {
5406
- let sel, key, elm;
5447
+ let key, elm;
5407
5448
  return {
5408
5449
  type: 0 /* VNodeType.Text */,
5409
- sel,
5450
+ sel: '__text__',
5410
5451
  text,
5411
5452
  elm,
5412
5453
  key,
@@ -5415,13 +5456,13 @@ function t(text) {
5415
5456
  }
5416
5457
  // [co]mment node
5417
5458
  function co(text) {
5418
- let sel, elm;
5459
+ let elm, key;
5419
5460
  return {
5420
5461
  type: 1 /* VNodeType.Comment */,
5421
- sel,
5462
+ sel: '__comment__',
5422
5463
  text,
5423
5464
  elm,
5424
- key: 'c',
5465
+ key,
5425
5466
  owner: getVMBeingRendered(),
5426
5467
  };
5427
5468
  }
@@ -6522,7 +6563,7 @@ function computeShadowMode(def, owner, renderer, hydrated) {
6522
6563
  // everything defaults to native when the synthetic shadow polyfill is unavailable.
6523
6564
  shadowMode = 0 /* ShadowMode.Native */;
6524
6565
  }
6525
- else if (def.shadowSupportMode === "native" /* ShadowSupportMode.Native */) {
6566
+ else if (def.shadowSupportMode === 'native') {
6526
6567
  shadowMode = 0 /* ShadowMode.Native */;
6527
6568
  }
6528
6569
  else {
@@ -7317,7 +7358,7 @@ function hydrateElement(elm, vnode, renderer) {
7317
7358
  vnode.elm = elm;
7318
7359
  const { owner } = vnode;
7319
7360
  const { context } = vnode.data;
7320
- const isDomManual = Boolean(!shared.isUndefined(context) && !shared.isUndefined(context.lwc) && context.lwc.dom === "manual" /* LwcDomMode.Manual */);
7361
+ const isDomManual = Boolean(!shared.isUndefined(context) && !shared.isUndefined(context.lwc) && context.lwc.dom === 'manual');
7321
7362
  if (isDomManual) {
7322
7363
  // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
7323
7364
  // remove the innerHTML from props so it reuses the existing dom elements.
@@ -7686,6 +7727,7 @@ function haveCompatibleStaticParts(vnode, renderer) {
7686
7727
  if (shared.isUndefined(parts)) {
7687
7728
  return true;
7688
7729
  }
7730
+ const shouldValidateAttr = (data, attrName) => attrName in data;
7689
7731
  // The validation here relies on 2 key invariants:
7690
7732
  // 1. It's never the case that `parts` is undefined on the server but defined on the client (or vice-versa)
7691
7733
  // 2. It's never the case that `parts` has one length on the server but another on the client
@@ -7697,8 +7739,15 @@ function haveCompatibleStaticParts(vnode, renderer) {
7697
7739
  }
7698
7740
  const { data } = part;
7699
7741
  const hasMatchingAttrs = validateAttrs(vnode, elm, data, renderer, () => true);
7700
- const hasMatchingStyleAttr = validateStyleAttr(vnode, elm, data, renderer);
7701
- const hasMatchingClass = validateClassAttr(vnode, elm, data, renderer);
7742
+ // Explicitly skip hydration validation when static parts don't contain `style` or `className`.
7743
+ // This means the style/class attributes are either static or don't exist on the element and
7744
+ // cannot be affected by hydration.
7745
+ const hasMatchingStyleAttr = shouldValidateAttr(data, 'style')
7746
+ ? validateStyleAttr(vnode, elm, data, renderer)
7747
+ : true;
7748
+ const hasMatchingClass = shouldValidateAttr(data, 'className')
7749
+ ? validateClassAttr(vnode, elm, data, renderer)
7750
+ : true;
7702
7751
  if (shared.isFalse(hasMatchingAttrs && hasMatchingStyleAttr && hasMatchingClass)) {
7703
7752
  return false;
7704
7753
  }
@@ -8027,5 +8076,5 @@ exports.swapTemplate = swapTemplate;
8027
8076
  exports.track = track;
8028
8077
  exports.unwrap = unwrap;
8029
8078
  exports.wire = wire;
8030
- /** version: 7.0.0-alpha.0 */
8079
+ /** version: 7.0.0 */
8031
8080
  //# sourceMappingURL=index.cjs.js.map