@lwc/engine-core 7.0.5 → 7.1.1

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.
@@ -55,7 +55,7 @@ declare function shc(content: unknown): string;
55
55
  * This implementation is borrowed from Vue:
56
56
  * https://github.com/vuejs/core/blob/e790e1bdd7df7be39e14780529db86e4da47a3db/packages/shared/src/normalizeProp.ts#L63-L82
57
57
  */
58
- declare function ncls(value: unknown): string;
58
+ declare function ncls(value: unknown): string | undefined;
59
59
  declare const api: Readonly<{
60
60
  s: typeof s;
61
61
  h: typeof h;
@@ -49,5 +49,7 @@ export interface RendererAPI {
49
49
  ownerDocument(elm: E): Document;
50
50
  registerContextConsumer: (element: E, adapterContextToken: string, subscriptionPayload: WireContextSubscriptionPayload) => void;
51
51
  attachInternals: (elm: E) => ElementInternals;
52
+ startTrackingMutations: (elm: E) => void;
53
+ stopTrackingMutations: (elm: E) => void;
52
54
  }
53
55
  export {};
package/dist/index.cjs.js CHANGED
@@ -3231,9 +3231,9 @@ function unrenderStylesheet(stylesheet) {
3231
3231
  }
3232
3232
  for (const cssContent of cssContents) {
3233
3233
  const abortController = cssContentToAbortControllers.get(cssContent);
3234
- /* istanbul ignore if */
3235
3234
  if (shared.isUndefined(abortController)) {
3236
- throw new Error('Cannot find AbortController for CSS content');
3235
+ // Two stylesheets with the same content will share an abort controller, in which case it only needs to be called once.
3236
+ continue;
3237
3237
  }
3238
3238
  abortController.abort();
3239
3239
  // remove association with AbortController in case stylesheet is rendered again
@@ -5631,6 +5631,11 @@ function shc(content) {
5631
5631
  * https://github.com/vuejs/core/blob/e790e1bdd7df7be39e14780529db86e4da47a3db/packages/shared/src/normalizeProp.ts#L63-L82
5632
5632
  */
5633
5633
  function ncls(value) {
5634
+ if (shared.isUndefined(value) || shared.isNull(value)) {
5635
+ // Returning undefined here improves initial render cost, because the old vnode's class will be considered
5636
+ // undefined in the `patchClassAttribute` routine, so `oldClass === newClass` will be true so we return early
5637
+ return undefined;
5638
+ }
5634
5639
  let res = '';
5635
5640
  if (shared.isString(value)) {
5636
5641
  res = value;
@@ -6695,7 +6700,14 @@ function runConnectedCallback(vm) {
6695
6700
  const { connectedCallback } = vm.def;
6696
6701
  if (!shared.isUndefined(connectedCallback)) {
6697
6702
  logOperationStart(3 /* OperationId.ConnectedCallback */, vm);
6703
+ if (!process.env.IS_BROWSER) {
6704
+ // Track host element mutations in SSR mode to add the `data-lwc-host-mutated` attribute if necessary
6705
+ vm.renderer.startTrackingMutations(vm.elm);
6706
+ }
6698
6707
  invokeComponentCallback(vm, connectedCallback);
6708
+ if (!process.env.IS_BROWSER) {
6709
+ vm.renderer.stopTrackingMutations(vm.elm);
6710
+ }
6699
6711
  logOperationEnd(3 /* OperationId.ConnectedCallback */, vm);
6700
6712
  }
6701
6713
  // This test only makes sense in the browser, with synthetic lifecycle, and when reporting is enabled or
@@ -7266,7 +7278,12 @@ function textNodeContentsAreEqual(node, vnode, renderer) {
7266
7278
  // The validationOptOut static property can be an array of attribute names.
7267
7279
  // Any attribute names specified in that array will not be validated, and the
7268
7280
  // LWC runtime will assume that VDOM attrs and DOM attrs are in sync.
7269
- function getValidationPredicate(optOutStaticProp) {
7281
+ function getValidationPredicate(elm, renderer, optOutStaticProp) {
7282
+ // `data-lwc-host-mutated` is a special attribute added by the SSR engine itself,
7283
+ // which does the same thing as an explicit `static validationOptOut = true`.
7284
+ if (renderer.getAttribute(elm, 'data-lwc-host-mutated') === '') {
7285
+ return (_attrName) => false;
7286
+ }
7270
7287
  if (shared.isUndefined(optOutStaticProp)) {
7271
7288
  return (_attrName) => true;
7272
7289
  }
@@ -7384,7 +7401,7 @@ function hydrateElement(elm, vnode, renderer) {
7384
7401
  }
7385
7402
  function hydrateCustomElement(elm, vnode, renderer) {
7386
7403
  const { validationOptOut } = vnode.ctor;
7387
- const shouldValidateAttr = getValidationPredicate(validationOptOut);
7404
+ const shouldValidateAttr = getValidationPredicate(elm, renderer, validationOptOut);
7388
7405
  // The validationOptOut static property can be an array of attribute names.
7389
7406
  // Any attribute names specified in that array will not be validated, and the
7390
7407
  // LWC runtime will assume that VDOM attrs and DOM attrs are in sync.
@@ -8072,5 +8089,5 @@ exports.swapTemplate = swapTemplate;
8072
8089
  exports.track = track;
8073
8090
  exports.unwrap = unwrap;
8074
8091
  exports.wire = wire;
8075
- /** version: 7.0.5 */
8092
+ /** version: 7.1.1 */
8076
8093
  //# sourceMappingURL=index.cjs.js.map