@lwc/engine-core 2.45.1 → 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, 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';
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
 
@@ -6238,6 +6238,27 @@ function textNodeContentsAreEqual(node, vnode, renderer) {
6238
6238
  }
6239
6239
  return false;
6240
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
+ }
6241
6262
  function hydrateText(node, vnode, renderer) {
6242
6263
  var _a;
6243
6264
  if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
@@ -6316,8 +6337,19 @@ function hydrateElement(elm, vnode, renderer) {
6316
6337
  return elm;
6317
6338
  }
6318
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.
6319
6351
  if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) ||
6320
- !isMatchingElement(vnode, elm, renderer)) {
6352
+ !isMatchingElement(vnode, elm, renderer, shouldValidateAttr)) {
6321
6353
  return handleMismatch(elm, vnode, renderer);
6322
6354
  }
6323
6355
  const { sel, mode, ctor, owner } = vnode;
@@ -6411,7 +6443,7 @@ function hasCorrectNodeType(vnode, node, nodeType, renderer) {
6411
6443
  }
6412
6444
  return true;
6413
6445
  }
6414
- function isMatchingElement(vnode, elm, renderer) {
6446
+ function isMatchingElement(vnode, elm, renderer, shouldValidateAttr = () => true) {
6415
6447
  const { getProperty } = renderer;
6416
6448
  if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
6417
6449
  if (process.env.NODE_ENV !== 'production') {
@@ -6419,10 +6451,14 @@ function isMatchingElement(vnode, elm, renderer) {
6419
6451
  }
6420
6452
  return false;
6421
6453
  }
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;
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;
6426
6462
  }
6427
6463
  function attributeValuesAreEqual(vnodeValue, value) {
6428
6464
  const vnodeValueAsString = String(vnodeValue);
@@ -6437,12 +6473,15 @@ function attributeValuesAreEqual(vnodeValue, value) {
6437
6473
  // In all other cases, the two values are not considered equal
6438
6474
  return false;
6439
6475
  }
6440
- function validateAttrs(vnode, elm, renderer) {
6476
+ function validateAttrs(vnode, elm, renderer, shouldValidateAttr) {
6441
6477
  const { data: { attrs = {} }, } = vnode;
6442
6478
  let nodesAreCompatible = true;
6443
6479
  // Validate attributes, though we could always recovery from those by running the update mods.
6444
6480
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6445
6481
  for (const [attrName, attrValue] of Object.entries(attrs)) {
6482
+ if (!shouldValidateAttr(attrName)) {
6483
+ continue;
6484
+ }
6446
6485
  const { owner } = vnode;
6447
6486
  const { getAttribute } = renderer;
6448
6487
  const elmAttrValue = getAttribute(elm, attrName);
@@ -6868,5 +6907,5 @@ function readonly(obj) {
6868
6907
  }
6869
6908
 
6870
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 };
6871
- /* version: 2.45.1 */
6910
+ /* version: 2.45.2 */
6872
6911
  //# sourceMappingURL=engine-core.js.map