@lwc/engine-core 8.5.0 → 8.7.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,8 +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, isFunction as isFunction$1, keys, ArrayFilter, isObject, isArray as isArray$1, 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, flattenStylesheets, 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';
4
+ import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, seal, create, isAPIFeatureEnabled, isFunction as isFunction$1, keys, ArrayFilter, isObject, isArray as isArray$1, 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, isTrue, KEY__SCOPED_CSS, KEY__NATIVE_ONLY_CSS, ArraySplice, flattenStylesheets, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, isNumber, StringReplace, sanitizeHtmlContent, StringTrim, ArraySort, ArrayFrom, htmlEscape, StringCharAt, LOWEST_API_VERSION, ArrayUnshift, 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 { setHooks, setTrustedSignalSet } from '@lwc/shared';
6
6
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
7
7
 
8
8
  /*
@@ -3197,29 +3197,29 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
3197
3197
  // the stylesheet, while internally, we have a replacement for it.
3198
3198
  stylesheet = getStyleOrSwappedStyle(stylesheet);
3199
3199
  }
3200
- const isScopedCss = stylesheet[KEY__SCOPED_CSS];
3200
+ const isScopedCss = isTrue(stylesheet[KEY__SCOPED_CSS]);
3201
+ const isNativeOnlyCss = isTrue(stylesheet[KEY__NATIVE_ONLY_CSS]);
3202
+ const { renderMode, shadowMode } = vm;
3201
3203
  if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS &&
3202
3204
  !isScopedCss &&
3203
- vm.renderMode === 0 /* RenderMode.Light */) {
3205
+ renderMode === 0 /* RenderMode.Light */) {
3204
3206
  logError('Unscoped CSS is not supported in Light DOM in this environment. Please use scoped CSS ' +
3205
3207
  '(*.scoped.css) instead of unscoped CSS (*.css). See also: https://sfdc.co/scoped-styles-light-dom');
3206
3208
  continue;
3207
3209
  }
3208
3210
  // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
3209
3211
  const scopeToken = isScopedCss ||
3210
- (vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */)
3212
+ (shadowMode === 1 /* ShadowMode.Synthetic */ && renderMode === 1 /* RenderMode.Shadow */)
3211
3213
  ? stylesheetToken
3212
3214
  : undefined;
3213
3215
  // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
3214
3216
  // native shadow DOM. Synthetic shadow DOM never uses `:host`.
3215
- const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */
3216
- ? !isScopedCss
3217
- : vm.shadowMode === 0 /* ShadowMode.Native */;
3217
+ const useActualHostSelector = renderMode === 0 /* RenderMode.Light */ ? !isScopedCss : shadowMode === 0 /* ShadowMode.Native */;
3218
3218
  // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
3219
3219
  // we use an attribute selector on the host to simulate :dir().
3220
3220
  let useNativeDirPseudoclass;
3221
- if (vm.renderMode === 1 /* RenderMode.Shadow */) {
3222
- useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
3221
+ if (renderMode === 1 /* RenderMode.Shadow */) {
3222
+ useNativeDirPseudoclass = shadowMode === 0 /* ShadowMode.Native */;
3223
3223
  }
3224
3224
  else {
3225
3225
  // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
@@ -3230,7 +3230,18 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
3230
3230
  }
3231
3231
  useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
3232
3232
  }
3233
- const cssContent = stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass);
3233
+ let cssContent;
3234
+ if (isNativeOnlyCss &&
3235
+ renderMode === 1 /* RenderMode.Shadow */ &&
3236
+ shadowMode === 1 /* ShadowMode.Synthetic */) {
3237
+ // Native-only (i.e. disableSyntheticShadowSupport) CSS should be ignored entirely
3238
+ // in synthetic shadow. It's fine to use in either native shadow or light DOM, but in
3239
+ // synthetic shadow it wouldn't be scoped properly and so should be ignored.
3240
+ cssContent = '/* ignored native-only CSS */';
3241
+ }
3242
+ else {
3243
+ cssContent = stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass);
3244
+ }
3234
3245
  if (process.env.NODE_ENV !== 'production') {
3235
3246
  linkStylesheetToCssContentInDevMode(stylesheet, cssContent);
3236
3247
  }
@@ -5781,26 +5792,9 @@ function sc(vnodes) {
5781
5792
  markAsDynamicChildren(vnodes);
5782
5793
  return vnodes;
5783
5794
  }
5784
- /**
5785
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
5786
- * libraries to sanitize HTML content. This hook process the content passed via the template to
5787
- * lwc:inner-html directive.
5788
- * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
5789
- */
5790
- let sanitizeHtmlContentHook = () => {
5791
- // locker-service patches this function during runtime to sanitize HTML content.
5792
- throw new Error('sanitizeHtmlContent hook must be implemented.');
5793
- };
5794
- /**
5795
- * Sets the sanitizeHtmlContentHook.
5796
- * @param newHookImpl
5797
- */
5798
- function setSanitizeHtmlContentHook(newHookImpl) {
5799
- sanitizeHtmlContentHook = newHookImpl;
5800
- }
5801
5795
  // [s]anitize [h]tml [c]ontent
5802
5796
  function shc(content) {
5803
- const sanitizedString = sanitizeHtmlContentHook(content);
5797
+ const sanitizedString = sanitizeHtmlContent(content);
5804
5798
  return createSanitizedHtmlContent(sanitizedString);
5805
5799
  }
5806
5800
  /**
@@ -6458,7 +6452,13 @@ function evaluateTemplate(vm, html) {
6458
6452
  vnodes = html.call(undefined, api, component, cmpSlots, context.tplCache);
6459
6453
  const { styleVNodes } = context;
6460
6454
  if (!isNull(styleVNodes)) {
6461
- ArrayUnshift.apply(vnodes, styleVNodes);
6455
+ // It's important here not to mutate the underlying `vnodes` returned from `html.call()`.
6456
+ // The reason for this is because, due to the static content optimization, the vnodes array
6457
+ // may be a static array shared across multiple component instances. E.g. this occurs in the
6458
+ // case of an empty `<template></template>` in a `component.html` file, due to the underlying
6459
+ // children being `[]` (no children). If we append the `<style>` vnode to this array, then the same
6460
+ // array will be reused for every component instance, i.e. whenever `tmpl()` is called.
6461
+ vnodes = [...styleVNodes, ...vnodes];
6462
6462
  }
6463
6463
  });
6464
6464
  }, () => {
@@ -7854,7 +7854,7 @@ expectAddlSiblings) {
7854
7854
  }
7855
7855
  }
7856
7856
  mount(childVnode, parentNode, renderer, nextNode);
7857
- nextNode = renderer.nextSibling(childVnode.elm);
7857
+ nextNode = renderer.nextSibling(childVnode.type === 5 /* VNodeType.Fragment */ ? childVnode.trailing : childVnode.elm);
7858
7858
  }
7859
7859
  }
7860
7860
  }
@@ -8169,19 +8169,6 @@ function haveCompatibleStaticParts(vnode, renderer) {
8169
8169
  return true;
8170
8170
  }
8171
8171
 
8172
- /*
8173
- * Copyright (c) 2018, salesforce.com, inc.
8174
- * All rights reserved.
8175
- * SPDX-License-Identifier: MIT
8176
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8177
- */
8178
- let hooksAreSet = false;
8179
- function setHooks(hooks) {
8180
- assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
8181
- hooksAreSet = true;
8182
- setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
8183
- }
8184
-
8185
8172
  /*
8186
8173
  * Copyright (c) 2024, Salesforce, Inc.
8187
8174
  * All rights reserved.
@@ -8197,10 +8184,7 @@ const TEMPLATE_PROPS = [
8197
8184
  'legacyStylesheetToken',
8198
8185
  ];
8199
8186
  // Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
8200
- const STYLESHEET_PROPS = [
8201
- // SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
8202
- '$scoped$',
8203
- ];
8187
+ const STYLESHEET_PROPS = [KEY__SCOPED_CSS, KEY__NATIVE_ONLY_CSS];
8204
8188
  // Via https://www.npmjs.com/package/object-observer
8205
8189
  const ARRAY_MUTATION_METHODS = [
8206
8190
  'pop',
@@ -8444,6 +8428,6 @@ function readonly(obj) {
8444
8428
  return getReadOnlyProxy(obj);
8445
8429
  }
8446
8430
 
8447
- 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 };
8448
- /** version: 8.5.0 */
8431
+ 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, shouldBeFormAssociated, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
8432
+ /** version: 8.7.0 */
8449
8433
  //# sourceMappingURL=index.js.map