@lwc/engine-core 8.6.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.cjs.js CHANGED
@@ -3200,29 +3200,29 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
3200
3200
  // the stylesheet, while internally, we have a replacement for it.
3201
3201
  stylesheet = getStyleOrSwappedStyle(stylesheet);
3202
3202
  }
3203
- const isScopedCss = stylesheet[shared.KEY__SCOPED_CSS];
3203
+ const isScopedCss = shared.isTrue(stylesheet[shared.KEY__SCOPED_CSS]);
3204
+ const isNativeOnlyCss = shared.isTrue(stylesheet[shared.KEY__NATIVE_ONLY_CSS]);
3205
+ const { renderMode, shadowMode } = vm;
3204
3206
  if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS &&
3205
3207
  !isScopedCss &&
3206
- vm.renderMode === 0 /* RenderMode.Light */) {
3208
+ renderMode === 0 /* RenderMode.Light */) {
3207
3209
  logError('Unscoped CSS is not supported in Light DOM in this environment. Please use scoped CSS ' +
3208
3210
  '(*.scoped.css) instead of unscoped CSS (*.css). See also: https://sfdc.co/scoped-styles-light-dom');
3209
3211
  continue;
3210
3212
  }
3211
3213
  // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
3212
3214
  const scopeToken = isScopedCss ||
3213
- (vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */)
3215
+ (shadowMode === 1 /* ShadowMode.Synthetic */ && renderMode === 1 /* RenderMode.Shadow */)
3214
3216
  ? stylesheetToken
3215
3217
  : undefined;
3216
3218
  // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
3217
3219
  // native shadow DOM. Synthetic shadow DOM never uses `:host`.
3218
- const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */
3219
- ? !isScopedCss
3220
- : vm.shadowMode === 0 /* ShadowMode.Native */;
3220
+ const useActualHostSelector = renderMode === 0 /* RenderMode.Light */ ? !isScopedCss : shadowMode === 0 /* ShadowMode.Native */;
3221
3221
  // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
3222
3222
  // we use an attribute selector on the host to simulate :dir().
3223
3223
  let useNativeDirPseudoclass;
3224
- if (vm.renderMode === 1 /* RenderMode.Shadow */) {
3225
- useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
3224
+ if (renderMode === 1 /* RenderMode.Shadow */) {
3225
+ useNativeDirPseudoclass = shadowMode === 0 /* ShadowMode.Native */;
3226
3226
  }
3227
3227
  else {
3228
3228
  // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
@@ -3233,7 +3233,18 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
3233
3233
  }
3234
3234
  useNativeDirPseudoclass = shared.isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
3235
3235
  }
3236
- const cssContent = stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass);
3236
+ let cssContent;
3237
+ if (isNativeOnlyCss &&
3238
+ renderMode === 1 /* RenderMode.Shadow */ &&
3239
+ shadowMode === 1 /* ShadowMode.Synthetic */) {
3240
+ // Native-only (i.e. disableSyntheticShadowSupport) CSS should be ignored entirely
3241
+ // in synthetic shadow. It's fine to use in either native shadow or light DOM, but in
3242
+ // synthetic shadow it wouldn't be scoped properly and so should be ignored.
3243
+ cssContent = '/* ignored native-only CSS */';
3244
+ }
3245
+ else {
3246
+ cssContent = stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass);
3247
+ }
3237
3248
  if (process.env.NODE_ENV !== 'production') {
3238
3249
  linkStylesheetToCssContentInDevMode(stylesheet, cssContent);
3239
3250
  }
@@ -6444,7 +6455,13 @@ function evaluateTemplate(vm, html) {
6444
6455
  vnodes = html.call(undefined, api, component, cmpSlots, context.tplCache);
6445
6456
  const { styleVNodes } = context;
6446
6457
  if (!shared.isNull(styleVNodes)) {
6447
- shared.ArrayUnshift.apply(vnodes, styleVNodes);
6458
+ // It's important here not to mutate the underlying `vnodes` returned from `html.call()`.
6459
+ // The reason for this is because, due to the static content optimization, the vnodes array
6460
+ // may be a static array shared across multiple component instances. E.g. this occurs in the
6461
+ // case of an empty `<template></template>` in a `component.html` file, due to the underlying
6462
+ // children being `[]` (no children). If we append the `<style>` vnode to this array, then the same
6463
+ // array will be reused for every component instance, i.e. whenever `tmpl()` is called.
6464
+ vnodes = [...styleVNodes, ...vnodes];
6448
6465
  }
6449
6466
  });
6450
6467
  }, () => {
@@ -8170,10 +8187,7 @@ const TEMPLATE_PROPS = [
8170
8187
  'legacyStylesheetToken',
8171
8188
  ];
8172
8189
  // Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
8173
- const STYLESHEET_PROPS = [
8174
- // SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
8175
- '$scoped$',
8176
- ];
8190
+ const STYLESHEET_PROPS = [shared.KEY__SCOPED_CSS, shared.KEY__NATIVE_ONLY_CSS];
8177
8191
  // Via https://www.npmjs.com/package/object-observer
8178
8192
  const ARRAY_MUTATION_METHODS = [
8179
8193
  'pop',
@@ -8468,5 +8482,5 @@ exports.swapTemplate = swapTemplate;
8468
8482
  exports.track = track;
8469
8483
  exports.unwrap = unwrap;
8470
8484
  exports.wire = wire;
8471
- /** version: 8.6.0 */
8485
+ /** version: 8.7.0 */
8472
8486
  //# sourceMappingURL=index.cjs.js.map