@lwc/engine-core 8.2.0 → 8.3.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.
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2024 Salesforce, Inc.
3
3
  */
4
- import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, seal, create, isAPIFeatureEnabled, isArray as isArray$1, isFunction as isFunction$1, keys, ArrayFilter, isObject, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertySymbols as getOwnPropertySymbols$1, toString as toString$1, isString, ArrayIndexOf, ArrayPop, isFalse, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, assert, freeze, KEY__SYNTHETIC_MODE, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyDescriptors, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, ArraySplice, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, StringSlice, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, isNumber, StringReplace, StringTrim, ArraySort, ArrayFrom, htmlEscape, StringCharAt, ArrayUnshift, LOWEST_API_VERSION, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, StringSplit, parseStyleText, arrayEvery, ArrayCopyWithin, ArrayFill, ArrayReverse, ArrayShift } from '@lwc/shared';
4
+ import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, seal, create, isAPIFeatureEnabled, isArray as isArray$1, isFunction as isFunction$1, keys, ArrayFilter, isObject, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertySymbols as getOwnPropertySymbols$1, toString as toString$1, isString, ArrayIndexOf, ArrayPop, isFalse, isTrustedSignal, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, assert, freeze, KEY__SYNTHETIC_MODE, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyDescriptors, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, ArraySplice, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, StringSlice, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, isNumber, StringReplace, StringTrim, ArraySort, ArrayFrom, htmlEscape, StringCharAt, ArrayUnshift, LOWEST_API_VERSION, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, StringSplit, parseStyleText, arrayEvery, ArrayCopyWithin, ArrayFill, ArrayReverse, ArrayShift } from '@lwc/shared';
5
+ export { setTrustedSignalSet } from '@lwc/shared';
5
6
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
6
7
 
7
8
  /*
@@ -598,6 +599,7 @@ function componentValueObserved(vm, key, target = {}) {
598
599
  'value' in target &&
599
600
  'subscribe' in target &&
600
601
  isFunction$1(target.subscribe) &&
602
+ isTrustedSignal(target) &&
601
603
  // Only subscribe if a template is being rendered by the engine
602
604
  tro.isObserving()) {
603
605
  // Subscribe the template reactive observer's notify method, which will mark the vm as dirty and schedule hydration.
@@ -6178,19 +6180,30 @@ function validateSlots(vm) {
6178
6180
  assert.isTrue(isArray$1(cmpSlots.slotAssignments[slotName]), `Slots can only be set to an array, instead received ${toString$1(cmpSlots.slotAssignments[slotName])} for slot "${slotName}" in ${vm}.`);
6179
6181
  }
6180
6182
  }
6181
- function validateLightDomTemplate(template, vm) {
6182
- assertNotProd(); // should never leak to prod mode
6183
- if (template === defaultEmptyTemplate) {
6183
+ function checkHasMatchingRenderMode(template, vm) {
6184
+ // don't validate in prod environments where reporting is disabled
6185
+ if (process.env.NODE_ENV === 'production' && !isReportingEnabled()) {
6184
6186
  return;
6185
6187
  }
6186
- if (vm.renderMode === 0 /* RenderMode.Light */) {
6187
- if (template.renderMode !== 'light') {
6188
- logError(`Light DOM components can't render shadow DOM templates. Add an 'lwc:render-mode="light"' directive to the root template tag of ${getComponentTag(vm)}.`);
6189
- }
6188
+ // don't validate the default empty template - it is not inherently light or shadow
6189
+ if (template === defaultEmptyTemplate) {
6190
+ return;
6190
6191
  }
6191
- else {
6192
- if (!isUndefined$1(template.renderMode)) {
6193
- logError(`Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${getComponentTag(vm)} or set it to 'lwc:render-mode="shadow"`);
6192
+ // TODO [#4663]: `renderMode` mismatch between template and component causes `console.error` but no error
6193
+ // Note that `undefined` means shadow in this case, because shadow is the default.
6194
+ const vmIsLight = vm.renderMode === 0 /* RenderMode.Light */;
6195
+ const templateIsLight = template.renderMode === 'light';
6196
+ if (vmIsLight !== templateIsLight) {
6197
+ report("RenderModeMismatch" /* ReportingEventId.RenderModeMismatch */, {
6198
+ tagName: vm.tagName,
6199
+ mode: vm.renderMode,
6200
+ });
6201
+ if (process.env.NODE_ENV !== 'production') {
6202
+ const tagName = getComponentTag(vm);
6203
+ const message = vmIsLight
6204
+ ? `Light DOM components can't render shadow DOM templates. Add an 'lwc:render-mode="light"' directive to the root template tag of ${tagName}.`
6205
+ : `Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${tagName} or set it to 'lwc:render-mode="shadow"`;
6206
+ logError(message);
6194
6207
  }
6195
6208
  }
6196
6209
  }
@@ -6405,9 +6418,7 @@ function evaluateTemplate(vm, html) {
6405
6418
  if (!isTemplateRegistered(html)) {
6406
6419
  throw new TypeError(`Invalid template returned by the render() method on ${vm.tagName}. It must return an imported template (e.g.: \`import html from "./${vm.def.name}.html"\`), instead, it has returned: ${toString$1(html)}.`);
6407
6420
  }
6408
- if (process.env.NODE_ENV !== 'production') {
6409
- validateLightDomTemplate(html, vm);
6410
- }
6421
+ checkHasMatchingRenderMode(html, vm);
6411
6422
  // Perf opt: do not reset the shadow root during the first rendering (there is
6412
6423
  // nothing to reset).
6413
6424
  if (!isNull(cmpTemplate)) {
@@ -8133,13 +8144,15 @@ function haveCompatibleStaticParts(vnode, renderer) {
8133
8144
  // Explicitly skip hydration validation when static parts don't contain `style` or `className`.
8134
8145
  // This means the style/class attributes are either static or don't exist on the element and
8135
8146
  // cannot be affected by hydration.
8136
- const hasMatchingStyleAttr = shouldValidateAttr(data, 'style')
8137
- ? validateStyleAttr(vnode, elm, data, renderer)
8138
- : true;
8147
+ // We need to do class first, style second to match the ordering of non-static-optimized nodes,
8148
+ // otherwise the ordering of console errors is different between the two.
8139
8149
  const hasMatchingClass = shouldValidateAttr(data, 'className')
8140
8150
  ? validateClassAttr(vnode, elm, data, renderer)
8141
8151
  : true;
8142
- if (isFalse(hasMatchingAttrs && hasMatchingStyleAttr && hasMatchingClass)) {
8152
+ const hasMatchingStyleAttr = shouldValidateAttr(data, 'style')
8153
+ ? validateStyleAttr(vnode, elm, data, renderer)
8154
+ : true;
8155
+ if (isFalse(hasMatchingAttrs && hasMatchingClass && hasMatchingStyleAttr)) {
8143
8156
  return false;
8144
8157
  }
8145
8158
  }
@@ -8430,5 +8443,5 @@ function readonly(obj) {
8430
8443
  }
8431
8444
 
8432
8445
  export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, computeShadowAndRenderMode, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, runFormAssociatedCallback, runFormDisabledCallback, runFormResetCallback, runFormStateRestoreCallback, sanitizeAttribute, setHooks, shouldBeFormAssociated, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
8433
- /** version: 8.2.0 */
8446
+ /** version: 8.3.0 */
8434
8447
  //# sourceMappingURL=index.js.map