@lwc/engine-core 2.45.5 → 2.47.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
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Copyright (C) 2023 salesforce.com, inc.
4
4
  */
5
- import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create, seal, isArray as isArray$1, isFunction as isFunction$1, keys, hasOwnProperty as hasOwnProperty$1, forEach, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, isObject, freeze, KEY__SYNTHETIC_MODE, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, isFalse, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyNames as getOwnPropertyNames$1, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, htmlAttributeToProperty, isString, StringSlice, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, ArrayPop, isNumber, StringReplace, ArrayUnshift, globalThis as globalThis$1, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, ArrayFilter, StringSplit, arrayEvery, ArrayIncludes, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift } from '@lwc/shared';
5
+ import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create, seal, isArray as isArray$1, isFunction as isFunction$1, keys, hasOwnProperty as hasOwnProperty$1, forEach, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, isObject, freeze, KEY__SYNTHETIC_MODE, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, isFalse, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyNames as getOwnPropertyNames$1, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, ArrayPop, isNumber, StringReplace, ArrayUnshift, globalThis as globalThis$1, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, ArrayFilter, StringSplit, arrayEvery, ArrayIncludes, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift } from '@lwc/shared';
6
6
  import { applyAriaReflection } from '@lwc/aria-reflection';
7
7
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
8
8
 
@@ -3306,27 +3306,35 @@ function isVScopedSlotFragment(vnode) {
3306
3306
  * SPDX-License-Identifier: MIT
3307
3307
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3308
3308
  */
3309
- const ColonCharCode$1 = 58;
3309
+ const ColonCharCode = 58;
3310
3310
  function patchAttributes(oldVnode, vnode, renderer) {
3311
- const { attrs } = vnode.data;
3311
+ const { attrs, external } = vnode.data;
3312
3312
  if (isUndefined$1(attrs)) {
3313
3313
  return;
3314
3314
  }
3315
3315
  const oldAttrs = isNull(oldVnode) ? EmptyObject : oldVnode.data.attrs;
3316
+ // Attrs may be the same due to the static content optimization, so we can skip diffing
3316
3317
  if (oldAttrs === attrs) {
3317
3318
  return;
3318
3319
  }
3319
3320
  const { elm } = vnode;
3320
- const { setAttribute, removeAttribute } = renderer;
3321
+ const { setAttribute, removeAttribute, setProperty } = renderer;
3321
3322
  for (const key in attrs) {
3322
3323
  const cur = attrs[key];
3323
3324
  const old = oldAttrs[key];
3324
3325
  if (old !== cur) {
3325
- if (StringCharCodeAt.call(key, 3) === ColonCharCode$1) {
3326
+ let propName;
3327
+ // For external custom elements, sniff to see if the attr should be considered a prop.
3328
+ // Use kebabCaseToCamelCase directly because we don't want to set props like `ariaLabel` or `tabIndex`
3329
+ // on a custom element versus just using the more reliable attribute format.
3330
+ if (external && (propName = kebabCaseToCamelCase(key)) in elm) {
3331
+ setProperty(elm, propName, cur);
3332
+ }
3333
+ else if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
3326
3334
  // Assume xml namespace
3327
3335
  setAttribute(elm, key, cur, XML_NAMESPACE);
3328
3336
  }
3329
- else if (StringCharCodeAt.call(key, 5) === ColonCharCode$1) {
3337
+ else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
3330
3338
  // Assume xlink namespace
3331
3339
  setAttribute(elm, key, cur, XLINK_NAMESPACE);
3332
3340
  }
@@ -3340,46 +3348,6 @@ function patchAttributes(oldVnode, vnode, renderer) {
3340
3348
  }
3341
3349
  }
3342
3350
 
3343
- /*
3344
- * Copyright (c) 2018, salesforce.com, inc.
3345
- * All rights reserved.
3346
- * SPDX-License-Identifier: MIT
3347
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3348
- */
3349
- const ColonCharCode = 58;
3350
- function patchAttrUnlessProp(oldVnode, vnode, renderer) {
3351
- const { data: { attrs }, elm, } = vnode;
3352
- if (isUndefined$1(attrs)) {
3353
- return;
3354
- }
3355
- const { removeAttribute, setAttribute, setProperty } = renderer;
3356
- const oldAttrs = isNull(oldVnode) ? EmptyObject : oldVnode.data.attrs;
3357
- for (const name in attrs) {
3358
- const cur = attrs[name];
3359
- const old = oldAttrs[name];
3360
- if (old !== cur) {
3361
- const propName = htmlAttributeToProperty(name);
3362
- if (propName in elm) {
3363
- setProperty(elm, name, cur);
3364
- }
3365
- else if (StringCharCodeAt.call(name, 3) === ColonCharCode) {
3366
- // Assume xml namespace
3367
- setAttribute(elm, name, cur, XML_NAMESPACE);
3368
- }
3369
- else if (StringCharCodeAt.call(name, 5) === ColonCharCode) {
3370
- // Assume xlink namespace
3371
- setAttribute(elm, name, cur, XLINK_NAMESPACE);
3372
- }
3373
- else if (isNull(cur) || isUndefined$1(cur)) {
3374
- removeAttribute(elm, name);
3375
- }
3376
- else {
3377
- setAttribute(elm, name, cur);
3378
- }
3379
- }
3380
- }
3381
- }
3382
-
3383
3351
  /*
3384
3352
  * Copyright (c) 2018, salesforce.com, inc.
3385
3353
  * All rights reserved.
@@ -3401,6 +3369,7 @@ function patchProps(oldVnode, vnode, renderer) {
3401
3369
  if (!isNull(oldVnode)) {
3402
3370
  oldProps = oldVnode.data.props;
3403
3371
  const oldSpread = oldVnode.data.spread;
3372
+ // Props may be the same due to the static content optimization, so we can skip diffing
3404
3373
  if (oldProps === props && oldSpread === spread) {
3405
3374
  return;
3406
3375
  }
@@ -3531,7 +3500,9 @@ function patchStyleAttribute(oldVnode, vnode, renderer) {
3531
3500
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3532
3501
  */
3533
3502
  function applyEventListeners(vnode, renderer) {
3534
- const { elm, data: { on }, } = vnode;
3503
+ var _a;
3504
+ const { elm } = vnode;
3505
+ const on = (_a = vnode.data) === null || _a === void 0 ? void 0 : _a.on;
3535
3506
  if (isUndefined$1(on)) {
3536
3507
  return;
3537
3508
  }
@@ -3743,6 +3714,8 @@ function mountStatic(vnode, parent, anchor, renderer) {
3743
3714
  }
3744
3715
  }
3745
3716
  insertNode(elm, parent, anchor, renderer);
3717
+ // Event listeners are only applied once when mounting, so they are allowed for static vnodes
3718
+ applyEventListeners(vnode, renderer);
3746
3719
  }
3747
3720
  function mountCustomElement(vnode, parent, anchor, renderer) {
3748
3721
  const { sel, owner } = vnode;
@@ -3975,12 +3948,7 @@ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
3975
3948
  // value is set before type=radio.
3976
3949
  patchClassAttribute(oldVnode, vnode, renderer);
3977
3950
  patchStyleAttribute(oldVnode, vnode, renderer);
3978
- if (vnode.data.external) {
3979
- patchAttrUnlessProp(oldVnode, vnode, renderer);
3980
- }
3981
- else {
3982
- patchAttributes(oldVnode, vnode, renderer);
3983
- }
3951
+ patchAttributes(oldVnode, vnode, renderer);
3984
3952
  patchProps(oldVnode, vnode, renderer);
3985
3953
  }
3986
3954
  function applyStyleScoping(elm, owner, renderer) {
@@ -4380,7 +4348,7 @@ function ssf(slotName, factory) {
4380
4348
  };
4381
4349
  }
4382
4350
  // [st]atic node
4383
- function st(fragment, key) {
4351
+ function st(fragment, key, data) {
4384
4352
  return {
4385
4353
  type: 4 /* VNodeType.Static */,
4386
4354
  sel: undefined,
@@ -4388,6 +4356,7 @@ function st(fragment, key) {
4388
4356
  elm: undefined,
4389
4357
  fragment,
4390
4358
  owner: getVMBeingRendered(),
4359
+ data,
4391
4360
  };
4392
4361
  }
4393
4362
  // [fr]agment node
@@ -6294,6 +6263,7 @@ function hydrateStaticElement(elm, vnode, renderer) {
6294
6263
  return handleMismatch(elm, vnode, renderer);
6295
6264
  }
6296
6265
  vnode.elm = elm;
6266
+ applyEventListeners(vnode, renderer);
6297
6267
  return elm;
6298
6268
  }
6299
6269
  function hydrateFragment(elm, vnode, renderer) {
@@ -6903,5 +6873,5 @@ function readonly(obj) {
6903
6873
  }
6904
6874
 
6905
6875
  export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6906
- /** version: 2.45.5 */
6876
+ /** version: 2.47.0 */
6907
6877
  //# sourceMappingURL=index.js.map