lwc 2.23.6 → 2.25.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.
Files changed (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +147 -20
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +147 -20
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +125 -18
  5. package/dist/engine-dom/iife/es5/engine-dom.js +202 -41
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +171 -27
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +147 -20
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +125 -18
  11. package/dist/engine-dom/umd/es5/engine-dom.js +202 -41
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +171 -27
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +125 -17
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +125 -17
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +205 -168
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +205 -168
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +195 -158
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +25 -11
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +25 -11
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +205 -168
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +195 -158
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +25 -11
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +25 -11
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. package/package.json +7 -7
@@ -368,9 +368,9 @@
368
368
  // Increment whenever the LWC template compiler changes
369
369
 
370
370
 
371
- var LWC_VERSION = "2.23.6";
371
+ var LWC_VERSION = "2.25.0";
372
372
  var LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
373
- /** version: 2.23.6 */
373
+ /** version: 2.25.0 */
374
374
 
375
375
  /**
376
376
  * Copyright (C) 2018 salesforce.com, inc.
@@ -464,7 +464,7 @@
464
464
  patch$1(propName);
465
465
  }
466
466
  }
467
- /** version: 2.23.6 */
467
+ /** version: 2.25.0 */
468
468
 
469
469
  /**
470
470
  * Copyright (C) 2018 salesforce.com, inc.
@@ -557,7 +557,7 @@
557
557
  setFeatureFlag(name, value);
558
558
  }
559
559
  }
560
- /** version: 2.23.6 */
560
+ /** version: 2.25.0 */
561
561
 
562
562
  /*
563
563
  * Copyright (c) 2018, salesforce.com, inc.
@@ -735,6 +735,22 @@
735
735
  }
736
736
 
737
737
  return list;
738
+ } // Set a ref (lwc:ref) on a VM, from a template API
739
+
740
+
741
+ function setRefVNode(vm, ref, vnode) {
742
+ if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
743
+ throw new Error('refVNodes must be defined when setting a ref');
744
+ } // If this method is called, then vm.refVNodes is set as the template has refs.
745
+ // If not, then something went wrong and we threw an error above.
746
+
747
+
748
+ var refVNodes = vm.refVNodes; // In cases of conflict (two elements with the same ref), prefer, the last one,
749
+ // in depth-first traversal order.
750
+
751
+ if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
752
+ refVNodes[ref] = vnode;
753
+ }
738
754
  }
739
755
  /*
740
756
  * Copyright (c) 2019, salesforce.com, inc.
@@ -2397,13 +2413,15 @@
2397
2413
  }
2398
2414
  };
2399
2415
  }
2416
+
2417
+ var EMPTY_REFS = freeze(create(null));
2418
+ var refsCache = new WeakMap();
2400
2419
  /**
2401
2420
  * This class is the base class for any LWC element.
2402
2421
  * Some elements directly extends this class, others implement it via inheritance.
2403
2422
  **/
2404
2423
  // @ts-ignore
2405
2424
 
2406
-
2407
2425
  var LightningElement = function LightningElement() {
2408
2426
  // This should be as performant as possible, while any initialization should be done lazily
2409
2427
  if (isNull(vmBeingConstructed)) {
@@ -2630,6 +2648,91 @@
2630
2648
  return vm.shadowRoot;
2631
2649
  },
2632
2650
 
2651
+ get refs() {
2652
+ var vm = getAssociatedVM(this);
2653
+
2654
+ if (isUpdatingTemplate) {
2655
+ if (process.env.NODE_ENV !== 'production') {
2656
+ logError("this.refs should not be called while ".concat(getComponentTag(vm), " is rendering. Use this.refs only when the DOM is stable, e.g. in renderedCallback()."));
2657
+ } // If the template is in the process of being updated, then we don't want to go through the normal
2658
+ // process of returning the refs and caching them, because the state of the refs is unstable.
2659
+ // This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
2660
+ // based on `this.refs.bar`.
2661
+
2662
+
2663
+ return;
2664
+ }
2665
+
2666
+ if (process.env.NODE_ENV !== 'production') {
2667
+ warnIfInvokedDuringConstruction(vm, 'refs');
2668
+ }
2669
+
2670
+ var refVNodes = vm.refVNodes,
2671
+ hasRefVNodes = vm.hasRefVNodes,
2672
+ cmpTemplate = vm.cmpTemplate; // If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
2673
+ // if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
2674
+ // so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
2675
+ // `warnIfInvokedDuringConstruction` above).
2676
+
2677
+ if (process.env.NODE_ENV !== 'production' && isNull(cmpTemplate) && !isBeingConstructed(vm)) {
2678
+ logError("this.refs is undefined for ".concat(getComponentTag(vm), ". This is either because the attached template has no \"lwc:ref\" directive, or this.refs was ") + "invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have " + "been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().");
2679
+ } // For backwards compatibility with component written before template refs
2680
+ // were introduced, we return undefined if the template has no refs defined
2681
+ // anywhere. This fixes components that may want to add an expando called `refs`
2682
+ // and are checking if it exists with `if (this.refs)` before adding it.
2683
+ // Note it is not sufficient to just check if `refVNodes` is null or empty,
2684
+ // because a template may have `lwc:ref` defined within a falsy `if:true` block.
2685
+
2686
+
2687
+ if (!hasRefVNodes) {
2688
+ return;
2689
+ } // For templates that are using `lwc:ref`, if there are no refs currently available
2690
+ // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
2691
+
2692
+
2693
+ if (isNull(refVNodes)) {
2694
+ return EMPTY_REFS;
2695
+ } // The refNodes can be cached based on the refVNodes, since the refVNodes
2696
+ // are recreated from scratch every time the template is rendered.
2697
+ // This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
2698
+
2699
+
2700
+ var refs = refsCache.get(refVNodes);
2701
+
2702
+ if (isUndefined$1(refs)) {
2703
+ refs = create(null);
2704
+
2705
+ var _iterator3 = _createForOfIteratorHelper(keys(refVNodes)),
2706
+ _step3;
2707
+
2708
+ try {
2709
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2710
+ var key = _step3.value;
2711
+ refs[key] = refVNodes[key].elm;
2712
+ }
2713
+ } catch (err) {
2714
+ _iterator3.e(err);
2715
+ } finally {
2716
+ _iterator3.f();
2717
+ }
2718
+
2719
+ freeze(refs);
2720
+ refsCache.set(refVNodes, refs);
2721
+ }
2722
+
2723
+ return refs;
2724
+ },
2725
+
2726
+ // For backwards compat, we allow component authors to set `refs` as an expando
2727
+ set refs(value) {
2728
+ defineProperty(this, 'refs', {
2729
+ configurable: true,
2730
+ enumerable: true,
2731
+ writable: true,
2732
+ value: value
2733
+ });
2734
+ },
2735
+
2633
2736
  get shadowRoot() {
2634
2737
  // From within the component instance, the shadowRoot is always reported as "closed".
2635
2738
  // Authors should rely on this.template instead.
@@ -4334,6 +4437,18 @@
4334
4437
  context = owner.context;
4335
4438
  return context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken) || null;
4336
4439
  }
4440
+ /**
4441
+ * This function returns the host style token for a custom element if it
4442
+ * exists. Otherwise it returns null.
4443
+ */
4444
+
4445
+
4446
+ function getStylesheetTokenHost(vnode) {
4447
+ var _getComponentInternal = getComponentInternalDef(vnode.ctor),
4448
+ stylesheetToken = _getComponentInternal.template.stylesheetToken;
4449
+
4450
+ return !isUndefined$1(stylesheetToken) ? makeHostToken(stylesheetToken) : null;
4451
+ }
4337
4452
 
4338
4453
  function getNearestNativeShadowComponent(vm) {
4339
4454
  var owner = getNearestShadowComponent(vm);
@@ -4479,6 +4594,12 @@
4479
4594
  function isSameVnode(vnode1, vnode2) {
4480
4595
  return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
4481
4596
  }
4597
+
4598
+ function isVCustomElement(vnode) {
4599
+ return vnode.type === 3
4600
+ /* VNodeType.CustomElement */
4601
+ ;
4602
+ }
4482
4603
  /*
4483
4604
  * Copyright (c) 2018, salesforce.com, inc.
4484
4605
  * All rights reserved.
@@ -4545,15 +4666,33 @@
4545
4666
 
4546
4667
  function patchProps(oldVnode, vnode, renderer) {
4547
4668
  var props = vnode.data.props;
4669
+ var spread = vnode.data.spread;
4548
4670
 
4549
- if (isUndefined$1(props)) {
4671
+ if (isUndefined$1(props) && isUndefined$1(spread)) {
4550
4672
  return;
4551
4673
  }
4552
4674
 
4553
- var oldProps = isNull(oldVnode) ? EmptyObject : oldVnode.data.props;
4675
+ var oldProps;
4554
4676
 
4555
- if (oldProps === props) {
4556
- return;
4677
+ if (!isNull(oldVnode)) {
4678
+ oldProps = oldVnode.data.props;
4679
+ var oldSpread = oldVnode.data.spread;
4680
+
4681
+ if (oldProps === props && oldSpread === spread) {
4682
+ return;
4683
+ }
4684
+
4685
+ if (isUndefined$1(oldProps)) {
4686
+ oldProps = EmptyObject;
4687
+ }
4688
+
4689
+ if (!isUndefined$1(oldSpread)) {
4690
+ oldProps = assign({}, oldProps, oldSpread);
4691
+ }
4692
+ }
4693
+
4694
+ if (!isUndefined$1(spread)) {
4695
+ props = assign({}, props, spread);
4557
4696
  }
4558
4697
 
4559
4698
  var isFirstPatch = isNull(oldVnode);
@@ -4566,7 +4705,8 @@
4566
4705
  var cur = props[key]; // Set the property if it's the first time is is patched or if the previous property is
4567
4706
  // different than the one previously set.
4568
4707
 
4569
- if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
4708
+ if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key]) || !(key in oldProps) // this is required because the above case will pass when `cur` is `undefined` and key is missing in `oldProps`
4709
+ ) {
4570
4710
  // Additional verification if properties are supported by the element
4571
4711
  // Validation relies on html properties and public properties being defined on the element,
4572
4712
  // SSR has its own custom validation.
@@ -5634,19 +5774,25 @@
5634
5774
  });
5635
5775
  }
5636
5776
 
5637
- var elm;
5638
- var key = data.key;
5639
- return {
5777
+ var key = data.key,
5778
+ ref = data.ref;
5779
+ var vnode = {
5640
5780
  type: 2
5641
5781
  /* VNodeType.Element */
5642
5782
  ,
5643
5783
  sel: sel,
5644
5784
  data: data,
5645
5785
  children: children,
5646
- elm: elm,
5786
+ elm: undefined,
5647
5787
  key: key,
5648
5788
  owner: vmBeingRendered
5649
5789
  };
5790
+
5791
+ if (!isUndefined$1(ref)) {
5792
+ setRefVNode(vmBeingRendered, ref, vnode);
5793
+ }
5794
+
5795
+ return vnode;
5650
5796
  } // [t]ab[i]ndex function
5651
5797
 
5652
5798
 
@@ -5727,7 +5873,8 @@
5727
5873
  }
5728
5874
  }
5729
5875
 
5730
- var key = data.key;
5876
+ var key = data.key,
5877
+ ref = data.ref;
5731
5878
  var elm, aChildren, vm;
5732
5879
  var vnode = {
5733
5880
  type: 3
@@ -5745,6 +5892,11 @@
5745
5892
  vm: vm
5746
5893
  };
5747
5894
  addVNodeToChildLWC(vnode);
5895
+
5896
+ if (!isUndefined$1(ref)) {
5897
+ setRefVNode(vmBeingRendered, ref, vnode);
5898
+ }
5899
+
5748
5900
  return vnode;
5749
5901
  } // [i]terable node
5750
5902
 
@@ -6399,10 +6551,14 @@
6399
6551
  validateSlots(vm, html); // add the VM to the list of host VMs that can be re-rendered if html is swapped
6400
6552
 
6401
6553
  setActiveVM(vm);
6402
- } // right before producing the vnodes, we clear up all internal references
6403
- // to custom elements from the template.
6554
+ } // reset the refs; they will be set during the tmpl() instantiation
6404
6555
 
6405
6556
 
6557
+ var hasRefVNodes = Boolean(html.hasRefs);
6558
+ vm.hasRefVNodes = hasRefVNodes;
6559
+ vm.refVNodes = hasRefVNodes ? create(null) : null; // right before producing the vnodes, we clear up all internal references
6560
+ // to custom elements from the template.
6561
+
6406
6562
  vm.velements = []; // Set the global flag that template is being updated
6407
6563
 
6408
6564
  isUpdatingTemplate = true;
@@ -6814,6 +6970,8 @@
6814
6970
  tagName: tagName,
6815
6971
  mode: mode,
6816
6972
  owner: owner,
6973
+ refVNodes: null,
6974
+ hasRefVNodes: false,
6817
6975
  children: EmptyArray,
6818
6976
  aChildren: EmptyArray,
6819
6977
  velements: EmptyArray,
@@ -8055,7 +8213,8 @@
8055
8213
  classMap = data.classMap;
8056
8214
  var getProperty = renderer.getProperty,
8057
8215
  getClassList = renderer.getClassList;
8058
- var scopedToken = getScopeTokenClass(owner); // Classnames for scoped CSS are added directly to the DOM during rendering,
8216
+ var scopedToken = getScopeTokenClass(owner);
8217
+ var stylesheetTokenHost = isVCustomElement(vnode) ? getStylesheetTokenHost(vnode) : null; // Classnames for scoped CSS are added directly to the DOM during rendering,
8059
8218
  // or to the VDOM on the server in the case of SSR. As such, these classnames
8060
8219
  // are never present in VDOM nodes in the browser.
8061
8220
  //
@@ -8064,9 +8223,11 @@
8064
8223
 
8065
8224
  if (scopedToken) {
8066
8225
  if (!isUndefined$1(className)) {
8067
- className = "".concat(scopedToken, " ").concat(className);
8226
+ className = isNull(stylesheetTokenHost) ? "".concat(scopedToken, " ").concat(className) : "".concat(scopedToken, " ").concat(className, " ").concat(stylesheetTokenHost);
8068
8227
  } else if (!isUndefined$1(classMap)) {
8069
- classMap = Object.assign(Object.assign({}, classMap), _defineProperty({}, scopedToken, true));
8228
+ classMap = Object.assign(Object.assign(Object.assign({}, classMap), _defineProperty({}, scopedToken, true)), isNull(stylesheetTokenHost) ? {} : _defineProperty({}, stylesheetTokenHost, true));
8229
+ } else {
8230
+ className = isNull(stylesheetTokenHost) ? "".concat(scopedToken) : "".concat(scopedToken, " ").concat(stylesheetTokenHost);
8070
8231
  }
8071
8232
  }
8072
8233
 
@@ -8275,12 +8436,12 @@
8275
8436
  function warnOnArrayMutation(stylesheets) {
8276
8437
  // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
8277
8438
  // we can at least warn when they use the most common mutation methods.
8278
- var _iterator3 = _createForOfIteratorHelper(ARRAY_MUTATION_METHODS),
8279
- _step3;
8439
+ var _iterator4 = _createForOfIteratorHelper(ARRAY_MUTATION_METHODS),
8440
+ _step4;
8280
8441
 
8281
8442
  try {
8282
8443
  var _loop2 = function _loop2() {
8283
- var prop = _step3.value;
8444
+ var prop = _step4.value;
8284
8445
  var originalArrayMethod = getOriginalArrayMethod(prop);
8285
8446
 
8286
8447
  stylesheets[prop] = function arrayMutationWarningWrapper() {
@@ -8290,13 +8451,13 @@
8290
8451
  };
8291
8452
  };
8292
8453
 
8293
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
8454
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
8294
8455
  _loop2();
8295
8456
  }
8296
8457
  } catch (err) {
8297
- _iterator3.e(err);
8458
+ _iterator4.e(err);
8298
8459
  } finally {
8299
- _iterator3.f();
8460
+ _iterator4.f();
8300
8461
  }
8301
8462
  } // TODO [#2782]: eventually freezeTemplate() will _actually_ freeze the tmpl object. Today it
8302
8463
  // just warns on mutation.
@@ -8308,12 +8469,12 @@
8308
8469
  warnOnArrayMutation(tmpl.stylesheets);
8309
8470
  }
8310
8471
 
8311
- var _iterator4 = _createForOfIteratorHelper(TEMPLATE_PROPS),
8312
- _step4;
8472
+ var _iterator5 = _createForOfIteratorHelper(TEMPLATE_PROPS),
8473
+ _step5;
8313
8474
 
8314
8475
  try {
8315
8476
  var _loop3 = function _loop3() {
8316
- var prop = _step4.value;
8477
+ var prop = _step5.value;
8317
8478
  var value = tmpl[prop];
8318
8479
  defineProperty(tmpl, prop, {
8319
8480
  enumerable: true,
@@ -8331,13 +8492,13 @@
8331
8492
  });
8332
8493
  };
8333
8494
 
8334
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
8495
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
8335
8496
  _loop3();
8336
8497
  }
8337
8498
  } catch (err) {
8338
- _iterator4.e(err);
8499
+ _iterator5.e(err);
8339
8500
  } finally {
8340
- _iterator4.f();
8501
+ _iterator5.f();
8341
8502
  }
8342
8503
 
8343
8504
  var originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
@@ -8382,7 +8543,7 @@
8382
8543
 
8383
8544
  return ctor;
8384
8545
  }
8385
- /* version: 2.23.6 */
8546
+ /* version: 2.25.0 */
8386
8547
 
8387
8548
  /*
8388
8549
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8610,7 +8771,7 @@
8610
8771
  function isNull(obj) {
8611
8772
  return obj === null;
8612
8773
  }
8613
- /** version: 2.23.6 */
8774
+ /** version: 2.25.0 */
8614
8775
 
8615
8776
  /*
8616
8777
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8759,18 +8920,18 @@
8759
8920
  var wrapperTags = topLevelWrappingMap[getTagName(html)];
8760
8921
 
8761
8922
  if (!isUndefined(wrapperTags)) {
8762
- var _iterator5 = _createForOfIteratorHelper(wrapperTags),
8763
- _step5;
8923
+ var _iterator6 = _createForOfIteratorHelper(wrapperTags),
8924
+ _step6;
8764
8925
 
8765
8926
  try {
8766
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
8767
- var wrapperTag = _step5.value;
8927
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
8928
+ var wrapperTag = _step6.value;
8768
8929
  html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
8769
8930
  }
8770
8931
  } catch (err) {
8771
- _iterator5.e(err);
8932
+ _iterator6.e(err);
8772
8933
  } finally {
8773
- _iterator5.f();
8934
+ _iterator6.f();
8774
8935
  }
8775
8936
  } // For IE11, the document title must not be undefined, but it can be an empty string
8776
8937
  // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
@@ -9340,7 +9501,7 @@
9340
9501
  });
9341
9502
  freeze(LightningElement);
9342
9503
  seal(LightningElement.prototype);
9343
- /* version: 2.23.6 */
9504
+ /* version: 2.25.0 */
9344
9505
 
9345
9506
  exports.LightningElement = LightningElement;
9346
9507
  exports.__unstable__ProfilerControl = profilerControl;