@lwc/engine-core 2.45.4 → 2.46.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.
@@ -1,8 +1,8 @@
1
1
  import { SlotSet } from './vm';
2
2
  import { LightningElementConstructor } from './base-lightning-element';
3
- import { VNode, VNodes, VElement, VText, VCustomElement, VComment, VElementData, VStatic, Key, VFragment, VScopedSlotFragment } from './vnodes';
3
+ import { VNode, VNodes, VElement, VText, VCustomElement, VComment, VElementData, VStatic, Key, VFragment, VScopedSlotFragment, VStaticElementData } from './vnodes';
4
4
  declare function ssf(slotName: unknown, factory: (value: any, key: any) => VFragment): VScopedSlotFragment;
5
- declare function st(fragment: Element, key: Key): VStatic;
5
+ declare function st(fragment: Element, key: Key, data?: VStaticElementData): VStatic;
6
6
  declare function fr(key: Key, children: VNodes, stable: 0 | 1): VFragment;
7
7
  declare function h(sel: string, data: VElementData, children?: VNodes): VElement;
8
8
  declare function ti(value: any): number;
@@ -1,3 +1,3 @@
1
1
  import { RendererAPI } from '../renderer';
2
- import { VBaseElement } from '../vnodes';
3
- export declare function applyEventListeners(vnode: VBaseElement, renderer: RendererAPI): void;
2
+ import { VBaseElement, VStatic } from '../vnodes';
3
+ export declare function applyEventListeners(vnode: VBaseElement | VStatic, renderer: RendererAPI): void;
@@ -27,11 +27,13 @@ export interface VScopedSlotFragment extends BaseVNode {
27
27
  type: VNodeType.ScopedSlotFragment;
28
28
  slotName: unknown;
29
29
  }
30
+ export type VStaticElementData = Pick<VNodeData, 'on'>;
30
31
  export interface VStatic extends BaseVNode {
31
- type: VNodeType.Static;
32
- sel: undefined;
33
- key: Key;
34
- fragment: Element;
32
+ readonly type: VNodeType.Static;
33
+ readonly sel: undefined;
34
+ readonly key: Key;
35
+ readonly fragment: Element;
36
+ readonly data: VStaticElementData | undefined;
35
37
  }
36
38
  export interface VFragment extends BaseVNode, BaseVParent {
37
39
  sel: undefined;
package/dist/index.cjs.js CHANGED
@@ -3310,27 +3310,35 @@ function isVScopedSlotFragment(vnode) {
3310
3310
  * SPDX-License-Identifier: MIT
3311
3311
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3312
3312
  */
3313
- const ColonCharCode$1 = 58;
3313
+ const ColonCharCode = 58;
3314
3314
  function patchAttributes(oldVnode, vnode, renderer) {
3315
- const { attrs } = vnode.data;
3315
+ const { attrs, external } = vnode.data;
3316
3316
  if (shared.isUndefined(attrs)) {
3317
3317
  return;
3318
3318
  }
3319
3319
  const oldAttrs = shared.isNull(oldVnode) ? EmptyObject : oldVnode.data.attrs;
3320
+ // Attrs may be the same due to the static content optimization, so we can skip diffing
3320
3321
  if (oldAttrs === attrs) {
3321
3322
  return;
3322
3323
  }
3323
3324
  const { elm } = vnode;
3324
- const { setAttribute, removeAttribute } = renderer;
3325
+ const { setAttribute, removeAttribute, setProperty } = renderer;
3325
3326
  for (const key in attrs) {
3326
3327
  const cur = attrs[key];
3327
3328
  const old = oldAttrs[key];
3328
3329
  if (old !== cur) {
3329
- if (shared.StringCharCodeAt.call(key, 3) === ColonCharCode$1) {
3330
+ let propName;
3331
+ // For external custom elements, sniff to see if the attr should be considered a prop.
3332
+ // Use kebabCaseToCamelCase directly because we don't want to set props like `ariaLabel` or `tabIndex`
3333
+ // on a custom element versus just using the more reliable attribute format.
3334
+ if (external && (propName = shared.kebabCaseToCamelCase(key)) in elm) {
3335
+ setProperty(elm, propName, cur);
3336
+ }
3337
+ else if (shared.StringCharCodeAt.call(key, 3) === ColonCharCode) {
3330
3338
  // Assume xml namespace
3331
3339
  setAttribute(elm, key, cur, shared.XML_NAMESPACE);
3332
3340
  }
3333
- else if (shared.StringCharCodeAt.call(key, 5) === ColonCharCode$1) {
3341
+ else if (shared.StringCharCodeAt.call(key, 5) === ColonCharCode) {
3334
3342
  // Assume xlink namespace
3335
3343
  setAttribute(elm, key, cur, shared.XLINK_NAMESPACE);
3336
3344
  }
@@ -3344,46 +3352,6 @@ function patchAttributes(oldVnode, vnode, renderer) {
3344
3352
  }
3345
3353
  }
3346
3354
 
3347
- /*
3348
- * Copyright (c) 2018, salesforce.com, inc.
3349
- * All rights reserved.
3350
- * SPDX-License-Identifier: MIT
3351
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3352
- */
3353
- const ColonCharCode = 58;
3354
- function patchAttrUnlessProp(oldVnode, vnode, renderer) {
3355
- const { data: { attrs }, elm, } = vnode;
3356
- if (shared.isUndefined(attrs)) {
3357
- return;
3358
- }
3359
- const { removeAttribute, setAttribute, setProperty } = renderer;
3360
- const oldAttrs = shared.isNull(oldVnode) ? EmptyObject : oldVnode.data.attrs;
3361
- for (const name in attrs) {
3362
- const cur = attrs[name];
3363
- const old = oldAttrs[name];
3364
- if (old !== cur) {
3365
- const propName = shared.htmlAttributeToProperty(name);
3366
- if (propName in elm) {
3367
- setProperty(elm, name, cur);
3368
- }
3369
- else if (shared.StringCharCodeAt.call(name, 3) === ColonCharCode) {
3370
- // Assume xml namespace
3371
- setAttribute(elm, name, cur, shared.XML_NAMESPACE);
3372
- }
3373
- else if (shared.StringCharCodeAt.call(name, 5) === ColonCharCode) {
3374
- // Assume xlink namespace
3375
- setAttribute(elm, name, cur, shared.XLINK_NAMESPACE);
3376
- }
3377
- else if (shared.isNull(cur) || shared.isUndefined(cur)) {
3378
- removeAttribute(elm, name);
3379
- }
3380
- else {
3381
- setAttribute(elm, name, cur);
3382
- }
3383
- }
3384
- }
3385
- }
3386
-
3387
3355
  /*
3388
3356
  * Copyright (c) 2018, salesforce.com, inc.
3389
3357
  * All rights reserved.
@@ -3405,6 +3373,7 @@ function patchProps(oldVnode, vnode, renderer) {
3405
3373
  if (!shared.isNull(oldVnode)) {
3406
3374
  oldProps = oldVnode.data.props;
3407
3375
  const oldSpread = oldVnode.data.spread;
3376
+ // Props may be the same due to the static content optimization, so we can skip diffing
3408
3377
  if (oldProps === props && oldSpread === spread) {
3409
3378
  return;
3410
3379
  }
@@ -3535,7 +3504,9 @@ function patchStyleAttribute(oldVnode, vnode, renderer) {
3535
3504
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3536
3505
  */
3537
3506
  function applyEventListeners(vnode, renderer) {
3538
- const { elm, data: { on }, } = vnode;
3507
+ var _a;
3508
+ const { elm } = vnode;
3509
+ const on = (_a = vnode.data) === null || _a === void 0 ? void 0 : _a.on;
3539
3510
  if (shared.isUndefined(on)) {
3540
3511
  return;
3541
3512
  }
@@ -3747,6 +3718,8 @@ function mountStatic(vnode, parent, anchor, renderer) {
3747
3718
  }
3748
3719
  }
3749
3720
  insertNode(elm, parent, anchor, renderer);
3721
+ // Event listeners are only applied once when mounting, so they are allowed for static vnodes
3722
+ applyEventListeners(vnode, renderer);
3750
3723
  }
3751
3724
  function mountCustomElement(vnode, parent, anchor, renderer) {
3752
3725
  const { sel, owner } = vnode;
@@ -3979,12 +3952,7 @@ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
3979
3952
  // value is set before type=radio.
3980
3953
  patchClassAttribute(oldVnode, vnode, renderer);
3981
3954
  patchStyleAttribute(oldVnode, vnode, renderer);
3982
- if (vnode.data.external) {
3983
- patchAttrUnlessProp(oldVnode, vnode, renderer);
3984
- }
3985
- else {
3986
- patchAttributes(oldVnode, vnode, renderer);
3987
- }
3955
+ patchAttributes(oldVnode, vnode, renderer);
3988
3956
  patchProps(oldVnode, vnode, renderer);
3989
3957
  }
3990
3958
  function applyStyleScoping(elm, owner, renderer) {
@@ -4384,7 +4352,7 @@ function ssf(slotName, factory) {
4384
4352
  };
4385
4353
  }
4386
4354
  // [st]atic node
4387
- function st(fragment, key) {
4355
+ function st(fragment, key, data) {
4388
4356
  return {
4389
4357
  type: 4 /* VNodeType.Static */,
4390
4358
  sel: undefined,
@@ -4392,6 +4360,7 @@ function st(fragment, key) {
4392
4360
  elm: undefined,
4393
4361
  fragment,
4394
4362
  owner: getVMBeingRendered(),
4363
+ data,
4395
4364
  };
4396
4365
  }
4397
4366
  // [fr]agment node
@@ -4497,7 +4466,12 @@ function s(slotName, data, children, slotset) {
4497
4466
  // undefined is for root components, but root components cannot accept slotted content
4498
4467
  setVMBeingRendered(slotset.owner);
4499
4468
  try {
4500
- shared.ArrayPush.call(newChildren, vnode.factory(data.slotData, data.key));
4469
+ // The factory function is a template snippet from the slot set owner's template,
4470
+ // hence switch over to the slot set owner's template reactive observer
4471
+ const { tro } = slotset.owner;
4472
+ tro.observe(() => {
4473
+ shared.ArrayPush.call(newChildren, vnode.factory(data.slotData, data.key));
4474
+ });
4501
4475
  }
4502
4476
  finally {
4503
4477
  setVMBeingRendered(vmBeingRenderedInception);
@@ -6293,6 +6267,7 @@ function hydrateStaticElement(elm, vnode, renderer) {
6293
6267
  return handleMismatch(elm, vnode, renderer);
6294
6268
  }
6295
6269
  vnode.elm = elm;
6270
+ applyEventListeners(vnode, renderer);
6296
6271
  return elm;
6297
6272
  }
6298
6273
  function hydrateFragment(elm, vnode, renderer) {
@@ -6939,5 +6914,5 @@ exports.swapTemplate = swapTemplate;
6939
6914
  exports.track = track;
6940
6915
  exports.unwrap = unwrap;
6941
6916
  exports.wire = wire;
6942
- /** version: 2.45.4 */
6917
+ /** version: 2.46.0 */
6943
6918
  //# sourceMappingURL=index.cjs.js.map