@lwc/engine-core 8.3.0 → 8.4.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.cjs.js CHANGED
@@ -296,6 +296,16 @@ function toPrettyMemberNotation(parent, child) {
296
296
  return `${shared.toString(parent)}[${JSON.stringify(child)}]`;
297
297
  }
298
298
  }
299
+ function safelyCallGetter(target, key) {
300
+ // Arbitrary getters can throw. We don't want to throw an error just due to dev-mode-only mutation tracking
301
+ // (which is only used for performance debugging) so ignore errors here.
302
+ try {
303
+ return target[key];
304
+ }
305
+ catch (_err) {
306
+ /* ignore */
307
+ }
308
+ }
299
309
  /**
300
310
  * Flush all the logs we've written so far and return the current logs.
301
311
  */
@@ -364,7 +374,7 @@ function trackTargetForMutationLogging(key, target) {
364
374
  // Deeply traverse arrays and objects to track every object within
365
375
  if (shared.isArray(target)) {
366
376
  for (let i = 0; i < target.length; i++) {
367
- trackTargetForMutationLogging(toPrettyMemberNotation(key, i), target[i]);
377
+ trackTargetForMutationLogging(toPrettyMemberNotation(key, i), safelyCallGetter(target, i));
368
378
  }
369
379
  }
370
380
  else {
@@ -373,10 +383,10 @@ function trackTargetForMutationLogging(key, target) {
373
383
  // https://github.com/salesforce/observable-membrane/blob/b85417f/src/base-handler.ts#L142-L143
374
384
  // Note this code path is very hot, hence doing two separate for-loops rather than creating a new array.
375
385
  for (const prop of shared.getOwnPropertyNames(target)) {
376
- trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), target[prop]);
386
+ trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), safelyCallGetter(target, prop));
377
387
  }
378
388
  for (const prop of shared.getOwnPropertySymbols(target)) {
379
- trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), target[prop]);
389
+ trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), safelyCallGetter(target, prop));
380
390
  }
381
391
  }
382
392
  }
@@ -669,8 +679,9 @@ for (const [propName, attrName] of shared.entries(shared.AriaPropNameToAttrNameM
669
679
  return this.getAttribute(attrName);
670
680
  },
671
681
  set(newValue) {
672
- // TODO [#3284]: there is disagreement between browsers and the spec on how to treat undefined
673
- // Our historical behavior is to only treat null as removing the attribute
682
+ // TODO [#3284]: According to the spec, IDL nullable type values
683
+ // (null and undefined) should remove the attribute; however, we
684
+ // only do so in the case of null for historical reasons.
674
685
  // See also https://github.com/w3c/aria/issues/1858
675
686
  if (shared.isNull(newValue)) {
676
687
  this.removeAttribute(attrName);
@@ -8008,7 +8019,10 @@ function validateClassAttr(vnode, elm, data, renderer) {
8008
8019
  let nodesAreCompatible = true;
8009
8020
  let readableVnodeClassname;
8010
8021
  const elmClassName = getAttribute(elm, 'class');
8011
- if (!shared.isUndefined(className) && String(className) !== elmClassName) {
8022
+ if (!shared.isUndefined(className) &&
8023
+ String(className) !== elmClassName &&
8024
+ // No mismatch if SSR `class` attribute is missing and CSR `class` is the empty string
8025
+ !(className === '' && shared.isNull(elmClassName))) {
8012
8026
  // className is used when class is bound to an expr.
8013
8027
  nodesAreCompatible = false;
8014
8028
  // stringify for pretty-printing
@@ -8493,5 +8507,5 @@ exports.swapTemplate = swapTemplate;
8493
8507
  exports.track = track;
8494
8508
  exports.unwrap = unwrap;
8495
8509
  exports.wire = wire;
8496
- /** version: 8.3.0 */
8510
+ /** version: 8.4.0 */
8497
8511
  //# sourceMappingURL=index.cjs.js.map