@lwc/engine-core 2.45.1 → 2.45.3

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.
Files changed (66) hide show
  1. package/dist/framework/attributes.d.ts +1 -0
  2. package/{types → dist}/framework/wiring/types.d.ts +3 -1
  3. package/dist/{engine-core.cjs.js → index.cjs.js} +77 -46
  4. package/dist/index.cjs.js.map +1 -0
  5. package/dist/{engine-core.js → index.js} +76 -47
  6. package/dist/index.js.map +1 -0
  7. package/package.json +27 -22
  8. package/dist/engine-core.cjs.js.map +0 -1
  9. package/dist/engine-core.js.map +0 -1
  10. package/types/framework/attributes.d.ts +0 -4
  11. /package/{types → dist}/framework/api.d.ts +0 -0
  12. /package/{types → dist}/framework/base-bridge-element.d.ts +0 -0
  13. /package/{types → dist}/framework/base-lightning-element.d.ts +0 -0
  14. /package/{types → dist}/framework/check-version-mismatch.d.ts +0 -0
  15. /package/{types → dist}/framework/component.d.ts +0 -0
  16. /package/{types → dist}/framework/decorators/api.d.ts +0 -0
  17. /package/{types → dist}/framework/decorators/register.d.ts +0 -0
  18. /package/{types → dist}/framework/decorators/track.d.ts +0 -0
  19. /package/{types → dist}/framework/decorators/wire.d.ts +0 -0
  20. /package/{types → dist}/framework/def.d.ts +0 -0
  21. /package/{types → dist}/framework/freeze-template.d.ts +0 -0
  22. /package/{types → dist}/framework/get-component-constructor.d.ts +0 -0
  23. /package/{types → dist}/framework/hot-swaps.d.ts +0 -0
  24. /package/{types → dist}/framework/html-element.d.ts +0 -0
  25. /package/{types → dist}/framework/html-properties.d.ts +0 -0
  26. /package/{types → dist}/framework/hydration.d.ts +0 -0
  27. /package/{types → dist}/framework/invoker.d.ts +0 -0
  28. /package/{types → dist}/framework/main.d.ts +0 -0
  29. /package/{types → dist}/framework/membrane.d.ts +0 -0
  30. /package/{types → dist}/framework/modules/attr-unless-prop.d.ts +0 -0
  31. /package/{types → dist}/framework/modules/attrs.d.ts +0 -0
  32. /package/{types → dist}/framework/modules/computed-class-attr.d.ts +0 -0
  33. /package/{types → dist}/framework/modules/computed-style-attr.d.ts +0 -0
  34. /package/{types → dist}/framework/modules/events.d.ts +0 -0
  35. /package/{types → dist}/framework/modules/props.d.ts +0 -0
  36. /package/{types → dist}/framework/modules/static-class-attr.d.ts +0 -0
  37. /package/{types → dist}/framework/modules/static-style-attr.d.ts +0 -0
  38. /package/{types → dist}/framework/mutation-tracker.d.ts +0 -0
  39. /package/{types → dist}/framework/observed-fields.d.ts +0 -0
  40. /package/{types → dist}/framework/overridable-hooks.d.ts +0 -0
  41. /package/{types → dist}/framework/profiler.d.ts +0 -0
  42. /package/{types → dist}/framework/readonly.d.ts +0 -0
  43. /package/{types → dist}/framework/renderer.d.ts +0 -0
  44. /package/{types → dist}/framework/rendering.d.ts +0 -0
  45. /package/{types → dist}/framework/reporting.d.ts +0 -0
  46. /package/{types → dist}/framework/restrictions.d.ts +0 -0
  47. /package/{types → dist}/framework/secure-template.d.ts +0 -0
  48. /package/{types → dist}/framework/services.d.ts +0 -0
  49. /package/{types → dist}/framework/stylesheet.d.ts +0 -0
  50. /package/{types → dist}/framework/template.d.ts +0 -0
  51. /package/{types → dist}/framework/update-component-value.d.ts +0 -0
  52. /package/{types → dist}/framework/utils.d.ts +0 -0
  53. /package/{types → dist}/framework/vm.d.ts +0 -0
  54. /package/{types → dist}/framework/vnodes.d.ts +0 -0
  55. /package/{types → dist}/framework/weak-multimap.d.ts +0 -0
  56. /package/{types → dist}/framework/wiring/context.d.ts +0 -0
  57. /package/{types → dist}/framework/wiring/index.d.ts +0 -0
  58. /package/{types → dist}/framework/wiring/wiring.d.ts +0 -0
  59. /package/{types → dist}/index.d.ts +0 -0
  60. /package/{types → dist}/libs/mutation-tracker/index.d.ts +0 -0
  61. /package/{types → dist}/patches/detect-non-standard-aria.d.ts +0 -0
  62. /package/{types → dist}/patches/detect-synthetic-cross-root-aria.d.ts +0 -0
  63. /package/{types → dist}/shared/circular-module-dependencies.d.ts +0 -0
  64. /package/{types → dist}/shared/error.d.ts +0 -0
  65. /package/{types → dist}/shared/format.d.ts +0 -0
  66. /package/{types → dist}/shared/logger.d.ts +0 -0
@@ -1,5 +1,7 @@
1
- /* proxy-compat-disable */
2
- 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, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift } from '@lwc/shared';
1
+ /**
2
+ * Copyright (C) 2023 salesforce.com, inc.
3
+ */
4
+ 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';
3
5
  import { applyAriaReflection } from '@lwc/aria-reflection';
4
6
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
5
7
 
@@ -444,19 +446,6 @@ const defaultDefHTMLPropertyNames = [
444
446
  'tabIndex',
445
447
  'title',
446
448
  ];
447
- let controlledElement = null;
448
- let controlledAttributeName;
449
- function isAttributeLocked(elm, attrName) {
450
- return elm !== controlledElement || attrName !== controlledAttributeName;
451
- }
452
- function lockAttribute(_elm, _key) {
453
- controlledElement = null;
454
- controlledAttributeName = undefined;
455
- }
456
- function unlockAttribute(elm, key) {
457
- controlledElement = elm;
458
- controlledAttributeName = key;
459
- }
460
449
 
461
450
  /*
462
451
  * Copyright (c) 2018, salesforce.com, inc.
@@ -495,6 +484,7 @@ forEach.call(defaultDefHTMLPropertyNames, (propName) => {
495
484
  * SPDX-License-Identifier: MIT
496
485
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
497
486
  */
487
+ /* eslint @lwc/lwc-internal/no-production-assert: "off" */
498
488
  function generateDataDescriptor(options) {
499
489
  return assign({
500
490
  configurable: true,
@@ -1324,6 +1314,14 @@ function markLockerLiveObject(obj) {
1324
1314
  * SPDX-License-Identifier: MIT
1325
1315
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1326
1316
  */
1317
+ /**
1318
+ * This module is responsible for producing the ComponentDef object that is always
1319
+ * accessible via `vm.def`. This is lazily created during the creation of the first
1320
+ * instance of a component class, and shared across all instances.
1321
+ *
1322
+ * This structure can be used to synthetically create proxies, and understand the
1323
+ * shape of a component. It is also used internally to apply extra optimizations.
1324
+ */
1327
1325
  /**
1328
1326
  * This operation is called with a descriptor of an standard html property
1329
1327
  * that a Custom Element can support (including AOM properties), which
@@ -1487,15 +1485,11 @@ LightningElement.prototype = {
1487
1485
  removeAttribute(name) {
1488
1486
  const vm = getAssociatedVM(this);
1489
1487
  const { elm, renderer: { removeAttribute }, } = vm;
1490
- unlockAttribute(elm, name);
1491
1488
  removeAttribute(elm, name);
1492
- lockAttribute();
1493
1489
  },
1494
1490
  removeAttributeNS(namespace, name) {
1495
1491
  const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
1496
- unlockAttribute(elm, name);
1497
1492
  removeAttribute(elm, name, namespace);
1498
- lockAttribute();
1499
1493
  },
1500
1494
  getAttribute(name) {
1501
1495
  const vm = getAssociatedVM(this);
@@ -1517,9 +1511,7 @@ LightningElement.prototype = {
1517
1511
  logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1518
1512
  }
1519
1513
  }
1520
- unlockAttribute(elm, name);
1521
1514
  setAttribute(elm, name, value);
1522
- lockAttribute();
1523
1515
  },
1524
1516
  setAttributeNS(namespace, name, value) {
1525
1517
  const vm = getAssociatedVM(this);
@@ -1529,9 +1521,7 @@ LightningElement.prototype = {
1529
1521
  logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1530
1522
  }
1531
1523
  }
1532
- unlockAttribute(elm, name);
1533
1524
  setAttribute(elm, name, value, namespace);
1534
- lockAttribute();
1535
1525
  },
1536
1526
  getBoundingClientRect() {
1537
1527
  const vm = getAssociatedVM(this);
@@ -1913,7 +1903,7 @@ function createConnector(vm, name, wireDef) {
1913
1903
  });
1914
1904
  runWithBoundaryProtection(vm, vm, noop, () => {
1915
1905
  // job
1916
- connector = new adapter(dataCallback);
1906
+ connector = new adapter(dataCallback, { tagName: vm.tagName });
1917
1907
  }, noop);
1918
1908
  const updateConnectorConfig = (config) => {
1919
1909
  // every time the config is recomputed due to tracking,
@@ -2481,6 +2471,10 @@ function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
2481
2471
  * SPDX-License-Identifier: MIT
2482
2472
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2483
2473
  */
2474
+ /**
2475
+ * This module is responsible for creating the base bridge class BaseBridgeElement
2476
+ * that represents the HTMLElement extension used for any LWC inserted in the DOM.
2477
+ */
2484
2478
  // A bridge descriptor is a descriptor whose job is just to get the component instance
2485
2479
  // from the element instance, and get the value or set a new value on the component.
2486
2480
  // This means that across different elements, similar names can get the exact same
@@ -2534,14 +2528,6 @@ function createAttributeChangedCallback(attributeToPropMap, superAttributeChange
2534
2528
  }
2535
2529
  return;
2536
2530
  }
2537
- if (!isAttributeLocked(this, attrName)) {
2538
- // Ignore changes triggered by the engine itself during:
2539
- // * diffing when public props are attempting to reflect to the DOM
2540
- // * component via `this.setAttribute()`, should never update the prop
2541
- // Both cases, the setAttribute call is always wrapped by the unlocking of the
2542
- // attribute to be changed
2543
- return;
2544
- }
2545
2531
  // Reflect attribute change to the corresponding property when changed from outside.
2546
2532
  this[propName] = newValue;
2547
2533
  };
@@ -2886,6 +2872,14 @@ function swapStyle(oldStyle, newStyle) {
2886
2872
  * SPDX-License-Identifier: MIT
2887
2873
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2888
2874
  */
2875
+ /**
2876
+ * This module is responsible for producing the ComponentDef object that is always
2877
+ * accessible via `vm.def`. This is lazily created during the creation of the first
2878
+ * instance of a component class, and shared across all instances.
2879
+ *
2880
+ * This structure can be used to synthetically create proxies, and understand the
2881
+ * shape of a component. It is also used internally to apply extra optimizations.
2882
+ */
2889
2883
  const CtorToDefMap = new WeakMap();
2890
2884
  function getCtorProto(Ctor) {
2891
2885
  let proto = getPrototypeOf$1(Ctor);
@@ -3327,7 +3321,6 @@ function patchAttributes(oldVnode, vnode, renderer) {
3327
3321
  const cur = attrs[key];
3328
3322
  const old = oldAttrs[key];
3329
3323
  if (old !== cur) {
3330
- unlockAttribute(elm, key);
3331
3324
  if (StringCharCodeAt.call(key, 3) === ColonCharCode$1) {
3332
3325
  // Assume xml namespace
3333
3326
  setAttribute(elm, key, cur, XML_NAMESPACE);
@@ -3342,7 +3335,6 @@ function patchAttributes(oldVnode, vnode, renderer) {
3342
3335
  else {
3343
3336
  setAttribute(elm, key, cur);
3344
3337
  }
3345
- lockAttribute();
3346
3338
  }
3347
3339
  }
3348
3340
  }
@@ -6238,6 +6230,27 @@ function textNodeContentsAreEqual(node, vnode, renderer) {
6238
6230
  }
6239
6231
  return false;
6240
6232
  }
6233
+ // The validationOptOut static property can be an array of attribute names.
6234
+ // Any attribute names specified in that array will not be validated, and the
6235
+ // LWC runtime will assume that VDOM attrs and DOM attrs are in sync.
6236
+ function getValidationPredicate(optOutStaticProp) {
6237
+ if (isUndefined$1(optOutStaticProp)) {
6238
+ return (_attrName) => true;
6239
+ }
6240
+ // If validationOptOut is true, no attributes will be checked for correctness
6241
+ // and the runtime will assume VDOM attrs and DOM attrs are in sync.
6242
+ if (isTrue(optOutStaticProp)) {
6243
+ return (_attrName) => false;
6244
+ }
6245
+ // If validationOptOut is an array of strings, attributes specified in the
6246
+ // array will be "opted out". Attributes not specified in the array will still
6247
+ // be validated.
6248
+ if (isArray$1(optOutStaticProp) && arrayEvery(optOutStaticProp, isString)) {
6249
+ return (attrName) => !ArrayIncludes.call(optOutStaticProp, attrName);
6250
+ }
6251
+ logWarn('Validation opt out must be `true` or an array of attributes that should not be validated.');
6252
+ return (_attrName) => true;
6253
+ }
6241
6254
  function hydrateText(node, vnode, renderer) {
6242
6255
  var _a;
6243
6256
  if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
@@ -6316,8 +6329,19 @@ function hydrateElement(elm, vnode, renderer) {
6316
6329
  return elm;
6317
6330
  }
6318
6331
  function hydrateCustomElement(elm, vnode, renderer) {
6332
+ const { validationOptOut } = vnode.ctor;
6333
+ const shouldValidateAttr = getValidationPredicate(validationOptOut);
6334
+ // The validationOptOut static property can be an array of attribute names.
6335
+ // Any attribute names specified in that array will not be validated, and the
6336
+ // LWC runtime will assume that VDOM attrs and DOM attrs are in sync.
6337
+ //
6338
+ // If validationOptOut is true, no attributes will be checked for correctness
6339
+ // and the runtime will assume VDOM attrs and DOM attrs are in sync.
6340
+ //
6341
+ // Therefore, if validationOptOut is falsey or an array of strings, we need to
6342
+ // examine some or all of the custom element's attributes.
6319
6343
  if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) ||
6320
- !isMatchingElement(vnode, elm, renderer)) {
6344
+ !isMatchingElement(vnode, elm, renderer, shouldValidateAttr)) {
6321
6345
  return handleMismatch(elm, vnode, renderer);
6322
6346
  }
6323
6347
  const { sel, mode, ctor, owner } = vnode;
@@ -6348,14 +6372,12 @@ function hydrateCustomElement(elm, vnode, renderer) {
6348
6372
  function hydrateChildren(node, children, parentNode, owner) {
6349
6373
  let hasWarned = false;
6350
6374
  let nextNode = node;
6351
- let anchor = null;
6352
6375
  const { renderer } = owner;
6353
6376
  for (let i = 0; i < children.length; i++) {
6354
6377
  const childVnode = children[i];
6355
6378
  if (!isNull(childVnode)) {
6356
6379
  if (nextNode) {
6357
6380
  nextNode = hydrateNode(nextNode, childVnode, renderer);
6358
- anchor = childVnode.elm;
6359
6381
  }
6360
6382
  else {
6361
6383
  hasMismatch = true;
@@ -6365,8 +6387,8 @@ function hydrateChildren(node, children, parentNode, owner) {
6365
6387
  logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
6366
6388
  }
6367
6389
  }
6368
- mount(childVnode, parentNode, renderer, anchor);
6369
- anchor = childVnode.elm;
6390
+ mount(childVnode, parentNode, renderer, nextNode);
6391
+ nextNode = renderer.nextSibling(childVnode.elm);
6370
6392
  }
6371
6393
  }
6372
6394
  }
@@ -6411,7 +6433,7 @@ function hasCorrectNodeType(vnode, node, nodeType, renderer) {
6411
6433
  }
6412
6434
  return true;
6413
6435
  }
6414
- function isMatchingElement(vnode, elm, renderer) {
6436
+ function isMatchingElement(vnode, elm, renderer, shouldValidateAttr = () => true) {
6415
6437
  const { getProperty } = renderer;
6416
6438
  if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
6417
6439
  if (process.env.NODE_ENV !== 'production') {
@@ -6419,10 +6441,14 @@ function isMatchingElement(vnode, elm, renderer) {
6419
6441
  }
6420
6442
  return false;
6421
6443
  }
6422
- const hasIncompatibleAttrs = validateAttrs(vnode, elm, renderer);
6423
- const hasIncompatibleClass = validateClassAttr(vnode, elm, renderer);
6424
- const hasIncompatibleStyle = validateStyleAttr(vnode, elm, renderer);
6425
- return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
6444
+ const hasCompatibleAttrs = validateAttrs(vnode, elm, renderer, shouldValidateAttr);
6445
+ const hasCompatibleClass = shouldValidateAttr('class')
6446
+ ? validateClassAttr(vnode, elm, renderer)
6447
+ : true;
6448
+ const hasCompatibleStyle = shouldValidateAttr('style')
6449
+ ? validateStyleAttr(vnode, elm, renderer)
6450
+ : true;
6451
+ return hasCompatibleAttrs && hasCompatibleClass && hasCompatibleStyle;
6426
6452
  }
6427
6453
  function attributeValuesAreEqual(vnodeValue, value) {
6428
6454
  const vnodeValueAsString = String(vnodeValue);
@@ -6437,12 +6463,15 @@ function attributeValuesAreEqual(vnodeValue, value) {
6437
6463
  // In all other cases, the two values are not considered equal
6438
6464
  return false;
6439
6465
  }
6440
- function validateAttrs(vnode, elm, renderer) {
6466
+ function validateAttrs(vnode, elm, renderer, shouldValidateAttr) {
6441
6467
  const { data: { attrs = {} }, } = vnode;
6442
6468
  let nodesAreCompatible = true;
6443
6469
  // Validate attributes, though we could always recovery from those by running the update mods.
6444
6470
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6445
6471
  for (const [attrName, attrValue] of Object.entries(attrs)) {
6472
+ if (!shouldValidateAttr(attrName)) {
6473
+ continue;
6474
+ }
6446
6475
  const { owner } = vnode;
6447
6476
  const { getAttribute } = renderer;
6448
6477
  const elmAttrValue = getAttribute(elm, attrName);
@@ -6868,5 +6897,5 @@ function readonly(obj) {
6868
6897
  }
6869
6898
 
6870
6899
  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 };
6871
- /* version: 2.45.1 */
6872
- //# sourceMappingURL=engine-core.js.map
6900
+ /** version: 2.45.3 */
6901
+ //# sourceMappingURL=index.js.map