@lwc/engine-core 7.1.3 → 7.1.5

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
@@ -5252,14 +5252,33 @@ function s(slotName, data, children, slotset) {
5252
5252
  if (renderMode === 0 /* RenderMode.Light */ &&
5253
5253
  shared.isAPIFeatureEnabled(6 /* APIFeature.USE_LIGHT_DOM_SLOT_FORWARDING */, apiVersion) &&
5254
5254
  (isVBaseElement(vnode) || isVStatic(vnode)) &&
5255
- // We only need to copy the vnodes when the slot assignment changes, copying every time causes issues with
5256
- // disconnected/connected callback firing.
5257
5255
  vnode.slotAssignment !== data.slotAssignment) {
5258
- // When the light DOM slot assignment (slot attribute) changes we can't use the same reference
5259
- // to the vnode because the current way the diffing algo works, it will replace the original reference
5260
- // to the host element with a new one. This means the new element will be mounted and immediately unmounted.
5261
- // Creating a copy of the vnode to preserve a reference to the previous host element.
5256
+ // When the light DOM slot assignment (slot attribute) changes, we can't use the same reference
5257
+ // to the vnode because the current way the diffing algo works, it will replace the original
5258
+ // reference to the host element with a new one. This means the new element will be mounted and
5259
+ // immediately unmounted. Creating a copy of the vnode preserves a reference to the previous
5260
+ // host element.
5262
5261
  clonedVNode = { ...vnode, slotAssignment: data.slotAssignment };
5262
+ // For disconnectedCallback to work correctly in synthetic lifecycle mode, we need to link the
5263
+ // current VM's velements to the clone, so that when the VM unmounts, the clone also unmounts.
5264
+ // Note this only applies to VCustomElements, since those are the elements that we manually need
5265
+ // to call disconnectedCallback for, when running in synthetic lifecycle mode.
5266
+ //
5267
+ // You might think it would make more sense to add the clonedVNode to the same velements array
5268
+ // as the original vnode's VM (i.e. `vnode.owner.velements`) rather than the current VM (i.e.
5269
+ // `vmBeingRendered.velements`), but this actually might not trigger disconnectedCallback
5270
+ // in synthetic lifecycle mode. The reason for this is that a reactivity change may cause
5271
+ // the slottable component to unmount, but _not_ the slotter component (see issue #4446).
5272
+ //
5273
+ // If this occurs, then the slottable component (i.e .this component we are rendering right
5274
+ // now) is the one that needs to own the clone. Whereas if a reactivity change higher in the
5275
+ // tree causes the slotter to unmount, then the slottable will also unmount. So using the
5276
+ // current VM works either way.
5277
+ if (lwcRuntimeFlags.ENABLE_SLOT_FORWARDING_FIX) {
5278
+ if (isVCustomElement(vnode)) {
5279
+ addVNodeToChildLWC(clonedVNode);
5280
+ }
5281
+ }
5263
5282
  }
5264
5283
  // If the slot content is standard type, the content is static, no additional
5265
5284
  // processing needed on the vnode
@@ -5802,6 +5821,12 @@ function getVMBeingRendered() {
5802
5821
  function setVMBeingRendered(vm) {
5803
5822
  vmBeingRendered = vm;
5804
5823
  }
5824
+ const VALID_SCOPE_TOKEN_REGEX = /^[a-zA-Z0-9\-_.]+$/;
5825
+ // See W-16614556
5826
+ // TODO [#2826]: freeze the template object
5827
+ function isValidScopeToken(token) {
5828
+ return shared.isString(token) && VALID_SCOPE_TOKEN_REGEX.test(token);
5829
+ }
5805
5830
  function validateSlots(vm) {
5806
5831
  assertNotProd(); // this method should never leak to prod
5807
5832
  const { cmpSlots } = vm;
@@ -5972,6 +5997,11 @@ function buildParseFragmentFn(createFragmentFn) {
5972
5997
  return cached;
5973
5998
  }
5974
5999
  }
6000
+ // See W-16614556
6001
+ if ((hasStyleToken && !isValidScopeToken(stylesheetToken)) ||
6002
+ (hasLegacyToken && !isValidScopeToken(legacyStylesheetToken))) {
6003
+ throw new Error('stylesheet token must be a valid string');
6004
+ }
5975
6005
  // If legacy stylesheet tokens are required, then add them to the rendered string
5976
6006
  const stylesheetTokenToRender = stylesheetToken + (hasLegacyToken ? ` ${legacyStylesheetToken}` : '');
5977
6007
  const classToken = hasScopedStyles && hasStyleToken ? ' ' + stylesheetTokenToRender : '';
@@ -7789,7 +7819,13 @@ function setHooks(hooks) {
7789
7819
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7790
7820
  */
7791
7821
  // See @lwc/engine-core/src/framework/template.ts
7792
- const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
7822
+ const TEMPLATE_PROPS = [
7823
+ 'slots',
7824
+ 'stylesheetToken',
7825
+ 'stylesheets',
7826
+ 'renderMode',
7827
+ 'legacyStylesheetToken',
7828
+ ];
7793
7829
  // Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
7794
7830
  const STYLESHEET_PROPS = [
7795
7831
  // SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
@@ -8082,5 +8118,5 @@ exports.swapTemplate = swapTemplate;
8082
8118
  exports.track = track;
8083
8119
  exports.unwrap = unwrap;
8084
8120
  exports.wire = wire;
8085
- /** version: 7.1.3 */
8121
+ /** version: 7.1.5 */
8086
8122
  //# sourceMappingURL=index.cjs.js.map