@lwc/engine-core 2.45.0 → 2.45.2

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,5 +1,5 @@
1
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, assert, freeze, KEY__SYNTHETIC_MODE, 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';
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, arrayEvery, ArrayIncludes, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift } from '@lwc/shared';
3
3
  import { applyAriaReflection } from '@lwc/aria-reflection';
4
4
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
5
5
 
@@ -528,8 +528,9 @@ function patchElementWithRestrictions(elm, options) {
528
528
  get() {
529
529
  return originalOuterHTMLDescriptor.get.call(this);
530
530
  },
531
- set(_value) {
532
- throw new TypeError(`Invalid attempt to set outerHTML on Element.`);
531
+ set(value) {
532
+ logError(`Invalid attempt to set outerHTML on Element.`);
533
+ return originalOuterHTMLDescriptor.set.call(this, value);
533
534
  },
534
535
  }),
535
536
  };
@@ -614,16 +615,18 @@ function getShadowRootRestrictionsDescriptors(sr) {
614
615
  get() {
615
616
  return originalInnerHTMLDescriptor.get.call(this);
616
617
  },
617
- set(_value) {
618
- throw new TypeError(`Invalid attempt to set innerHTML on ShadowRoot.`);
618
+ set(value) {
619
+ logError(`Invalid attempt to set innerHTML on ShadowRoot.`);
620
+ return originalInnerHTMLDescriptor.set.call(this, value);
619
621
  },
620
622
  }),
621
623
  textContent: generateAccessorDescriptor({
622
624
  get() {
623
625
  return originalTextContentDescriptor.get.call(this);
624
626
  },
625
- set(_value) {
626
- throw new TypeError(`Invalid attempt to set textContent on ShadowRoot.`);
627
+ set(value) {
628
+ logError(`Invalid attempt to set textContent on ShadowRoot.`);
629
+ return originalTextContentDescriptor.set.call(this, value);
627
630
  },
628
631
  }),
629
632
  addEventListener: generateDataDescriptor({
@@ -652,24 +655,27 @@ function getCustomElementRestrictionsDescriptors(elm) {
652
655
  get() {
653
656
  return originalInnerHTMLDescriptor.get.call(this);
654
657
  },
655
- set(_value) {
656
- throw new TypeError(`Invalid attempt to set innerHTML on HTMLElement.`);
658
+ set(value) {
659
+ logError(`Invalid attempt to set innerHTML on HTMLElement.`);
660
+ return originalInnerHTMLDescriptor.set.call(this, value);
657
661
  },
658
662
  }),
659
663
  outerHTML: generateAccessorDescriptor({
660
664
  get() {
661
665
  return originalOuterHTMLDescriptor.get.call(this);
662
666
  },
663
- set(_value) {
664
- throw new TypeError(`Invalid attempt to set outerHTML on HTMLElement.`);
667
+ set(value) {
668
+ logError(`Invalid attempt to set outerHTML on HTMLElement.`);
669
+ return originalOuterHTMLDescriptor.set.call(this, value);
665
670
  },
666
671
  }),
667
672
  textContent: generateAccessorDescriptor({
668
673
  get() {
669
674
  return originalTextContentDescriptor.get.call(this);
670
675
  },
671
- set(_value) {
672
- throw new TypeError(`Invalid attempt to set textContent on HTMLElement.`);
676
+ set(value) {
677
+ logError(`Invalid attempt to set textContent on HTMLElement.`);
678
+ return originalTextContentDescriptor.set.call(this, value);
673
679
  },
674
680
  }),
675
681
  addEventListener: generateDataDescriptor({
@@ -685,20 +691,6 @@ function getCustomElementRestrictionsDescriptors(elm) {
685
691
  }),
686
692
  };
687
693
  }
688
- function getComponentRestrictionsDescriptors() {
689
- assertNotProd(); // this method should never leak to prod
690
- return {
691
- tagName: generateAccessorDescriptor({
692
- get() {
693
- throw new Error(`Usage of property \`tagName\` is disallowed because the component itself does` +
694
- ` not know which tagName will be used to create the element, therefore writing` +
695
- ` code that check for that value is error prone.`);
696
- },
697
- configurable: true,
698
- enumerable: false, // no enumerable properties on component
699
- }),
700
- };
701
- }
702
694
  function getLightningElementPrototypeRestrictionsDescriptors(proto) {
703
695
  assertNotProd(); // this method should never leak to prod
704
696
  const originalDispatchEvent = proto.dispatchEvent;
@@ -731,9 +723,6 @@ function patchCustomElementWithRestrictions(elm) {
731
723
  const elmProto = getPrototypeOf$1(elm);
732
724
  setPrototypeOf(elm, create(elmProto, restrictionsDescriptors));
733
725
  }
734
- function patchComponentWithRestrictions(cmp) {
735
- defineProperties(cmp, getComponentRestrictionsDescriptors());
736
- }
737
726
  function patchLightningElementPrototypeWithRestrictions(proto) {
738
727
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
739
728
  }
@@ -1344,16 +1333,10 @@ function markLockerLiveObject(obj) {
1344
1333
  function createBridgeToElementDescriptor(propName, descriptor) {
1345
1334
  const { get, set, enumerable, configurable } = descriptor;
1346
1335
  if (!isFunction$1(get)) {
1347
- if (process.env.NODE_ENV !== 'production') {
1348
- assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
1349
- }
1350
- throw new TypeError();
1336
+ throw new TypeError(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
1351
1337
  }
1352
1338
  if (!isFunction$1(set)) {
1353
- if (process.env.NODE_ENV !== 'production') {
1354
- assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
1355
- }
1356
- throw new TypeError();
1339
+ throw new TypeError(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
1357
1340
  }
1358
1341
  return {
1359
1342
  enumerable,
@@ -1373,10 +1356,18 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1373
1356
  const vm = getAssociatedVM(this);
1374
1357
  if (process.env.NODE_ENV !== 'production') {
1375
1358
  const vmBeingRendered = getVMBeingRendered();
1376
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
1377
- assert.invariant(!isUpdatingTemplate, `When updating the template of ${vmBeingRendered}, one of the accessors used by the template has side effects on the state of ${vm}.${propName}`);
1378
- assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1379
- assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1359
+ if (isInvokingRender) {
1360
+ logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
1361
+ }
1362
+ if (isUpdatingTemplate) {
1363
+ logError(`When updating the template of ${vmBeingRendered}, one of the accessors used by the template has side effects on the state of ${vm}.${propName}`);
1364
+ }
1365
+ if (isBeingConstructed(vm)) {
1366
+ logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1367
+ }
1368
+ if (isObject(newValue) && !isNull(newValue)) {
1369
+ logError(`Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1370
+ }
1380
1371
  }
1381
1372
  updateComponentValue(vm, propName, newValue);
1382
1373
  return set.call(vm.elm, newValue);
@@ -1429,7 +1420,6 @@ const LightningElement = function () {
1429
1420
  // Adding extra guard rails in DEV mode.
1430
1421
  if (process.env.NODE_ENV !== 'production') {
1431
1422
  patchCustomElementWithRestrictions(elm);
1432
- patchComponentWithRestrictions(component);
1433
1423
  }
1434
1424
  return this;
1435
1425
  };
@@ -1465,9 +1455,15 @@ LightningElement.prototype = {
1465
1455
  const { elm, renderer: { addEventListener }, } = vm;
1466
1456
  if (process.env.NODE_ENV !== 'production') {
1467
1457
  const vmBeingRendered = getVMBeingRendered();
1468
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
1469
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
1470
- assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
1458
+ if (isInvokingRender) {
1459
+ logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
1460
+ }
1461
+ if (isUpdatingTemplate) {
1462
+ logError(`Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
1463
+ }
1464
+ if (!isFunction$1(listener)) {
1465
+ logError(`Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
1466
+ }
1471
1467
  }
1472
1468
  const wrappedListener = getWrappedComponentsListener(vm, listener);
1473
1469
  addEventListener(elm, type, wrappedListener, options);
@@ -1517,7 +1513,9 @@ LightningElement.prototype = {
1517
1513
  const vm = getAssociatedVM(this);
1518
1514
  const { elm, renderer: { setAttribute }, } = vm;
1519
1515
  if (process.env.NODE_ENV !== 'production') {
1520
- assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1516
+ if (isBeingConstructed(vm)) {
1517
+ logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1518
+ }
1521
1519
  }
1522
1520
  unlockAttribute(elm, name);
1523
1521
  setAttribute(elm, name, value);
@@ -1527,7 +1525,9 @@ LightningElement.prototype = {
1527
1525
  const vm = getAssociatedVM(this);
1528
1526
  const { elm, renderer: { setAttribute }, } = vm;
1529
1527
  if (process.env.NODE_ENV !== 'production') {
1530
- assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1528
+ if (isBeingConstructed(vm)) {
1529
+ logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1530
+ }
1531
1531
  }
1532
1532
  unlockAttribute(elm, name);
1533
1533
  setAttribute(elm, name, value, namespace);
@@ -1550,9 +1550,9 @@ LightningElement.prototype = {
1550
1550
  const vm = getAssociatedVM(this);
1551
1551
  const { elm, renderer: { getClassList }, } = vm;
1552
1552
  if (process.env.NODE_ENV !== 'production') {
1553
- // TODO [#1290]: this still fails in dev but works in production, eventually, we should
1554
- // just throw in all modes
1555
- assert.isFalse(isBeingConstructed(vm), `Failed to construct ${vm}: The result must not have attributes. Adding or tampering with classname in constructor is not allowed in a web component, use connectedCallback() instead.`);
1553
+ if (isBeingConstructed(vm)) {
1554
+ logError(`Failed to construct ${vm}: The result must not have attributes. Adding or tampering with classname in constructor is not allowed in a web component, use connectedCallback() instead.`);
1555
+ }
1556
1556
  }
1557
1557
  return getClassList(elm);
1558
1558
  },
@@ -2058,8 +2058,12 @@ function createPublicPropertyDescriptor(key) {
2058
2058
  const vm = getAssociatedVM(this);
2059
2059
  if (process.env.NODE_ENV !== 'production') {
2060
2060
  const vmBeingRendered = getVMBeingRendered();
2061
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2062
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2061
+ if (isInvokingRender) {
2062
+ logError(`render() method has side effects on the state of property "${toString$1(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
2063
+ }
2064
+ if (isUpdatingTemplate) {
2065
+ logError(`Updating the template has side effects on the state of property "${toString$1(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
2066
+ }
2063
2067
  }
2064
2068
  vm.cmpProps[key] = newValue;
2065
2069
  componentValueMutated(vm, key);
@@ -2083,14 +2087,18 @@ function createPublicAccessorDescriptor(key, descriptor) {
2083
2087
  const vm = getAssociatedVM(this);
2084
2088
  if (process.env.NODE_ENV !== 'production') {
2085
2089
  const vmBeingRendered = getVMBeingRendered();
2086
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2087
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2090
+ if (isInvokingRender) {
2091
+ logError(`render() method has side effects on the state of property "${toString$1(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
2092
+ }
2093
+ if (isUpdatingTemplate) {
2094
+ logError(`Updating the template has side effects on the state of property "${toString$1(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
2095
+ }
2088
2096
  }
2089
2097
  if (set) {
2090
2098
  set.call(this, newValue);
2091
2099
  }
2092
2100
  else if (process.env.NODE_ENV !== 'production') {
2093
- assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
2101
+ logError(`Invalid attempt to set a new value for property "${toString$1(key)}" that does not has a setter decorated with @api.`, vm);
2094
2102
  }
2095
2103
  },
2096
2104
  enumerable,
@@ -2124,8 +2132,12 @@ function internalTrackDecorator(key) {
2124
2132
  const vm = getAssociatedVM(this);
2125
2133
  if (process.env.NODE_ENV !== 'production') {
2126
2134
  const vmBeingRendered = getVMBeingRendered();
2127
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2128
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2135
+ if (isInvokingRender) {
2136
+ logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2137
+ }
2138
+ if (isUpdatingTemplate) {
2139
+ logError(`Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2140
+ }
2129
2141
  }
2130
2142
  const reactiveOrAnyValue = getReactiveProxy(newValue);
2131
2143
  updateComponentValue(vm, key, reactiveOrAnyValue);
@@ -2902,13 +2914,20 @@ function createComponentDef(Ctor) {
2902
2914
  const ctorName = Ctor.name;
2903
2915
  // Removing the following assert until https://bugs.webkit.org/show_bug.cgi?id=190140 is fixed.
2904
2916
  // assert.isTrue(ctorName && isString(ctorName), `${toString(Ctor)} should have a "name" property with string value, but found ${ctorName}.`);
2905
- assert.isTrue(Ctor.constructor, `Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
2906
- if (!isUndefined$1(ctorShadowSupportMode)) {
2907
- assert.invariant(ctorShadowSupportMode === "any" /* ShadowSupportMode.Any */ ||
2908
- ctorShadowSupportMode === "reset" /* ShadowSupportMode.Default */, `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
2917
+ if (!Ctor.constructor) {
2918
+ // This error seems impossible to hit, due to an earlier check in `isComponentConstructor()`.
2919
+ // But we keep it here just in case.
2920
+ logError(`Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
2909
2921
  }
2910
- if (!isUndefined$1(ctorRenderMode)) {
2911
- assert.invariant(ctorRenderMode === 'light' || ctorRenderMode === 'shadow', `Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
2922
+ if (!isUndefined$1(ctorShadowSupportMode) &&
2923
+ ctorShadowSupportMode !== "any" /* ShadowSupportMode.Any */ &&
2924
+ ctorShadowSupportMode !== "reset" /* ShadowSupportMode.Default */) {
2925
+ logError(`Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
2926
+ }
2927
+ if (!isUndefined$1(ctorRenderMode) &&
2928
+ ctorRenderMode !== 'light' &&
2929
+ ctorRenderMode !== 'shadow') {
2930
+ logError(`Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
2912
2931
  }
2913
2932
  }
2914
2933
  const decoratorsMeta = getDecoratorsMeta(Ctor);
@@ -4690,7 +4709,7 @@ function k(compilerKey, obj) {
4690
4709
  return compilerKey + ':' + obj;
4691
4710
  case 'object':
4692
4711
  if (process.env.NODE_ENV !== 'production') {
4693
- assert.fail(`Invalid key value "${obj}" in ${getVMBeingRendered()}. Key must be a string or number.`);
4712
+ logError(`Invalid key value "${obj}" in ${getVMBeingRendered()}. Key must be a string or number.`);
4694
4713
  }
4695
4714
  }
4696
4715
  }
@@ -4980,13 +4999,19 @@ function validateSlots(vm) {
4980
4999
  }
4981
5000
  }
4982
5001
  function validateLightDomTemplate(template, vm) {
4983
- if (template === defaultEmptyTemplate)
5002
+ assertNotProd(); // should never leak to prod mode
5003
+ if (template === defaultEmptyTemplate) {
4984
5004
  return;
5005
+ }
4985
5006
  if (vm.renderMode === 0 /* RenderMode.Light */) {
4986
- assert.isTrue(template.renderMode === 'light', `Light DOM components can't render shadow DOM templates. Add an 'lwc:render-mode="light"' directive to the root template tag of ${getComponentTag(vm)}.`);
5007
+ if (template.renderMode !== 'light') {
5008
+ logError(`Light DOM components can't render shadow DOM templates. Add an 'lwc:render-mode="light"' directive to the root template tag of ${getComponentTag(vm)}.`);
5009
+ }
4987
5010
  }
4988
5011
  else {
4989
- assert.isTrue(isUndefined$1(template.renderMode), `Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${getComponentTag(vm)} or set it to 'lwc:render-mode="shadow"`);
5012
+ if (!isUndefined$1(template.renderMode)) {
5013
+ logError(`Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${getComponentTag(vm)} or set it to 'lwc:render-mode="shadow"`);
5014
+ }
4990
5015
  }
4991
5016
  }
4992
5017
  function buildParseFragmentFn(createFragmentFn) {
@@ -5119,7 +5144,9 @@ function evaluateTemplate(vm, html) {
5119
5144
  logOperationEnd(1 /* OperationId.Render */, vm);
5120
5145
  });
5121
5146
  if (process.env.NODE_ENV !== 'production') {
5122
- assert.invariant(isArray$1(vnodes), `Compiler should produce html functions that always return an array.`);
5147
+ if (!isArray$1(vnodes)) {
5148
+ logError(`Compiler should produce html functions that always return an array.`);
5149
+ }
5123
5150
  }
5124
5151
  return vnodes;
5125
5152
  }
@@ -6211,6 +6238,27 @@ function textNodeContentsAreEqual(node, vnode, renderer) {
6211
6238
  }
6212
6239
  return false;
6213
6240
  }
6241
+ // The validationOptOut static property can be an array of attribute names.
6242
+ // Any attribute names specified in that array will not be validated, and the
6243
+ // LWC runtime will assume that VDOM attrs and DOM attrs are in sync.
6244
+ function getValidationPredicate(optOutStaticProp) {
6245
+ if (isUndefined$1(optOutStaticProp)) {
6246
+ return (_attrName) => true;
6247
+ }
6248
+ // If validationOptOut is true, no attributes will be checked for correctness
6249
+ // and the runtime will assume VDOM attrs and DOM attrs are in sync.
6250
+ if (isTrue(optOutStaticProp)) {
6251
+ return (_attrName) => false;
6252
+ }
6253
+ // If validationOptOut is an array of strings, attributes specified in the
6254
+ // array will be "opted out". Attributes not specified in the array will still
6255
+ // be validated.
6256
+ if (isArray$1(optOutStaticProp) && arrayEvery(optOutStaticProp, isString)) {
6257
+ return (attrName) => !ArrayIncludes.call(optOutStaticProp, attrName);
6258
+ }
6259
+ logWarn('Validation opt out must be `true` or an array of attributes that should not be validated.');
6260
+ return (_attrName) => true;
6261
+ }
6214
6262
  function hydrateText(node, vnode, renderer) {
6215
6263
  var _a;
6216
6264
  if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
@@ -6289,8 +6337,19 @@ function hydrateElement(elm, vnode, renderer) {
6289
6337
  return elm;
6290
6338
  }
6291
6339
  function hydrateCustomElement(elm, vnode, renderer) {
6340
+ const { validationOptOut } = vnode.ctor;
6341
+ const shouldValidateAttr = getValidationPredicate(validationOptOut);
6342
+ // The validationOptOut static property can be an array of attribute names.
6343
+ // Any attribute names specified in that array will not be validated, and the
6344
+ // LWC runtime will assume that VDOM attrs and DOM attrs are in sync.
6345
+ //
6346
+ // If validationOptOut is true, no attributes will be checked for correctness
6347
+ // and the runtime will assume VDOM attrs and DOM attrs are in sync.
6348
+ //
6349
+ // Therefore, if validationOptOut is falsey or an array of strings, we need to
6350
+ // examine some or all of the custom element's attributes.
6292
6351
  if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) ||
6293
- !isMatchingElement(vnode, elm, renderer)) {
6352
+ !isMatchingElement(vnode, elm, renderer, shouldValidateAttr)) {
6294
6353
  return handleMismatch(elm, vnode, renderer);
6295
6354
  }
6296
6355
  const { sel, mode, ctor, owner } = vnode;
@@ -6384,7 +6443,7 @@ function hasCorrectNodeType(vnode, node, nodeType, renderer) {
6384
6443
  }
6385
6444
  return true;
6386
6445
  }
6387
- function isMatchingElement(vnode, elm, renderer) {
6446
+ function isMatchingElement(vnode, elm, renderer, shouldValidateAttr = () => true) {
6388
6447
  const { getProperty } = renderer;
6389
6448
  if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
6390
6449
  if (process.env.NODE_ENV !== 'production') {
@@ -6392,10 +6451,14 @@ function isMatchingElement(vnode, elm, renderer) {
6392
6451
  }
6393
6452
  return false;
6394
6453
  }
6395
- const hasIncompatibleAttrs = validateAttrs(vnode, elm, renderer);
6396
- const hasIncompatibleClass = validateClassAttr(vnode, elm, renderer);
6397
- const hasIncompatibleStyle = validateStyleAttr(vnode, elm, renderer);
6398
- return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
6454
+ const hasCompatibleAttrs = validateAttrs(vnode, elm, renderer, shouldValidateAttr);
6455
+ const hasCompatibleClass = shouldValidateAttr('class')
6456
+ ? validateClassAttr(vnode, elm, renderer)
6457
+ : true;
6458
+ const hasCompatibleStyle = shouldValidateAttr('style')
6459
+ ? validateStyleAttr(vnode, elm, renderer)
6460
+ : true;
6461
+ return hasCompatibleAttrs && hasCompatibleClass && hasCompatibleStyle;
6399
6462
  }
6400
6463
  function attributeValuesAreEqual(vnodeValue, value) {
6401
6464
  const vnodeValueAsString = String(vnodeValue);
@@ -6410,12 +6473,15 @@ function attributeValuesAreEqual(vnodeValue, value) {
6410
6473
  // In all other cases, the two values are not considered equal
6411
6474
  return false;
6412
6475
  }
6413
- function validateAttrs(vnode, elm, renderer) {
6476
+ function validateAttrs(vnode, elm, renderer, shouldValidateAttr) {
6414
6477
  const { data: { attrs = {} }, } = vnode;
6415
6478
  let nodesAreCompatible = true;
6416
6479
  // Validate attributes, though we could always recovery from those by running the update mods.
6417
6480
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6418
6481
  for (const [attrName, attrValue] of Object.entries(attrs)) {
6482
+ if (!shouldValidateAttr(attrName)) {
6483
+ continue;
6484
+ }
6419
6485
  const { owner } = vnode;
6420
6486
  const { getAttribute } = renderer;
6421
6487
  const elmAttrValue = getAttribute(elm, attrName);
@@ -6841,5 +6907,5 @@ function readonly(obj) {
6841
6907
  }
6842
6908
 
6843
6909
  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 };
6844
- /* version: 2.45.0 */
6910
+ /* version: 2.45.2 */
6845
6911
  //# sourceMappingURL=engine-core.js.map