@lwc/engine-core 8.1.3 → 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.
@@ -3916,6 +3918,12 @@ function isVStaticPartText(vnode) {
3916
3918
  return vnode.type === 0 /* VStaticPartType.Text */;
3917
3919
  }
3918
3920
 
3921
+ /*
3922
+ * Copyright (c) 2024, Salesforce, Inc.
3923
+ * All rights reserved.
3924
+ * SPDX-License-Identifier: MIT
3925
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3926
+ */
3919
3927
  const sanitizedHtmlContentSymbol = Symbol('lwc-get-sanitized-html-content');
3920
3928
  function isSanitizedHtmlContent(object) {
3921
3929
  return isObject(object) && !isNull(object) && sanitizedHtmlContentSymbol in object;
@@ -6172,19 +6180,30 @@ function validateSlots(vm) {
6172
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}.`);
6173
6181
  }
6174
6182
  }
6175
- function validateLightDomTemplate(template, vm) {
6176
- assertNotProd(); // should never leak to prod mode
6177
- 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()) {
6178
6186
  return;
6179
6187
  }
6180
- if (vm.renderMode === 0 /* RenderMode.Light */) {
6181
- if (template.renderMode !== 'light') {
6182
- 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)}.`);
6183
- }
6188
+ // don't validate the default empty template - it is not inherently light or shadow
6189
+ if (template === defaultEmptyTemplate) {
6190
+ return;
6184
6191
  }
6185
- else {
6186
- if (!isUndefined$1(template.renderMode)) {
6187
- 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);
6188
6207
  }
6189
6208
  }
6190
6209
  }
@@ -6399,9 +6418,7 @@ function evaluateTemplate(vm, html) {
6399
6418
  if (!isTemplateRegistered(html)) {
6400
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)}.`);
6401
6420
  }
6402
- if (process.env.NODE_ENV !== 'production') {
6403
- validateLightDomTemplate(html, vm);
6404
- }
6421
+ checkHasMatchingRenderMode(html, vm);
6405
6422
  // Perf opt: do not reset the shadow root during the first rendering (there is
6406
6423
  // nothing to reset).
6407
6424
  if (!isNull(cmpTemplate)) {
@@ -8127,13 +8144,15 @@ function haveCompatibleStaticParts(vnode, renderer) {
8127
8144
  // Explicitly skip hydration validation when static parts don't contain `style` or `className`.
8128
8145
  // This means the style/class attributes are either static or don't exist on the element and
8129
8146
  // cannot be affected by hydration.
8130
- const hasMatchingStyleAttr = shouldValidateAttr(data, 'style')
8131
- ? validateStyleAttr(vnode, elm, data, renderer)
8132
- : 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.
8133
8149
  const hasMatchingClass = shouldValidateAttr(data, 'className')
8134
8150
  ? validateClassAttr(vnode, elm, data, renderer)
8135
8151
  : true;
8136
- 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)) {
8137
8156
  return false;
8138
8157
  }
8139
8158
  }
@@ -8424,5 +8443,5 @@ function readonly(obj) {
8424
8443
  }
8425
8444
 
8426
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 };
8427
- /** version: 8.1.3 */
8446
+ /** version: 8.3.0 */
8428
8447
  //# sourceMappingURL=index.js.map