lwc 2.23.5 → 2.24.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 +216 -69
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +216 -69
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +194 -67
  5. package/dist/engine-dom/iife/es5/engine-dom.js +494 -313
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +463 -299
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +216 -69
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +194 -67
  11. package/dist/engine-dom/umd/es5/engine-dom.js +494 -313
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +463 -299
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +124 -16
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +124 -16
  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
@@ -294,7 +294,7 @@
294
294
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
295
295
  return attributeName;
296
296
  }
297
- /** version: 2.23.5 */
297
+ /** version: 2.24.0 */
298
298
 
299
299
  /**
300
300
  * Copyright (C) 2018 salesforce.com, inc.
@@ -376,7 +376,7 @@
376
376
  patch$1(propName);
377
377
  }
378
378
  }
379
- /** version: 2.23.5 */
379
+ /** version: 2.24.0 */
380
380
 
381
381
  /**
382
382
  * Copyright (C) 2018 salesforce.com, inc.
@@ -504,6 +504,17 @@
504
504
  }
505
505
  return result;
506
506
  }
507
+ // Set a ref (lwc:ref) on a VM, from a template API
508
+ function setRefVNode(vm, ref, vnode) {
509
+ // If this method is called, then vm.refVNodes is set as the template has refs.
510
+ // If not, then something went wrong and we threw an error above.
511
+ const refVNodes = vm.refVNodes;
512
+ // In cases of conflict (two elements with the same ref), prefer, the last one,
513
+ // in depth-first traversal order.
514
+ if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
515
+ refVNodes[ref] = vnode;
516
+ }
517
+ }
507
518
 
508
519
  /*
509
520
  * Copyright (c) 2019, salesforce.com, inc.
@@ -1365,6 +1376,8 @@
1365
1376
  },
1366
1377
  };
1367
1378
  }
1379
+ const EMPTY_REFS = freeze(create(null));
1380
+ const refsCache = new WeakMap();
1368
1381
  /**
1369
1382
  * This class is the base class for any LWC element.
1370
1383
  * Some elements directly extends this class, others implement it via inheritance.
@@ -1502,6 +1515,53 @@
1502
1515
  const vm = getAssociatedVM(this);
1503
1516
  return vm.shadowRoot;
1504
1517
  },
1518
+ get refs() {
1519
+ const vm = getAssociatedVM(this);
1520
+ if (isUpdatingTemplate) {
1521
+ // If the template is in the process of being updated, then we don't want to go through the normal
1522
+ // process of returning the refs and caching them, because the state of the refs is unstable.
1523
+ // This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
1524
+ // based on `this.refs.bar`.
1525
+ return;
1526
+ }
1527
+ const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
1528
+ // For backwards compatibility with component written before template refs
1529
+ // were introduced, we return undefined if the template has no refs defined
1530
+ // anywhere. This fixes components that may want to add an expando called `refs`
1531
+ // and are checking if it exists with `if (this.refs)` before adding it.
1532
+ // Note it is not sufficient to just check if `refVNodes` is null or empty,
1533
+ // because a template may have `lwc:ref` defined within a falsy `if:true` block.
1534
+ if (!hasRefVNodes) {
1535
+ return;
1536
+ }
1537
+ // For templates that are using `lwc:ref`, if there are no refs currently available
1538
+ // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
1539
+ if (isNull(refVNodes)) {
1540
+ return EMPTY_REFS;
1541
+ }
1542
+ // The refNodes can be cached based on the refVNodes, since the refVNodes
1543
+ // are recreated from scratch every time the template is rendered.
1544
+ // This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
1545
+ let refs = refsCache.get(refVNodes);
1546
+ if (isUndefined$1(refs)) {
1547
+ refs = create(null);
1548
+ for (const key of keys(refVNodes)) {
1549
+ refs[key] = refVNodes[key].elm;
1550
+ }
1551
+ freeze(refs);
1552
+ refsCache.set(refVNodes, refs);
1553
+ }
1554
+ return refs;
1555
+ },
1556
+ // For backwards compat, we allow component authors to set `refs` as an expando
1557
+ set refs(value) {
1558
+ defineProperty(this, 'refs', {
1559
+ configurable: true,
1560
+ enumerable: true,
1561
+ writable: true,
1562
+ value,
1563
+ });
1564
+ },
1505
1565
  get shadowRoot() {
1506
1566
  // From within the component instance, the shadowRoot is always reported as "closed".
1507
1567
  // Authors should rely on this.template instead.
@@ -2602,13 +2662,27 @@
2602
2662
  return sel === 'input' && (key === 'value' || key === 'checked');
2603
2663
  }
2604
2664
  function patchProps(oldVnode, vnode, renderer) {
2605
- const { props } = vnode.data;
2606
- if (isUndefined$1(props)) {
2665
+ let { props } = vnode.data;
2666
+ const { spread } = vnode.data;
2667
+ if (isUndefined$1(props) && isUndefined$1(spread)) {
2607
2668
  return;
2608
2669
  }
2609
- const oldProps = isNull(oldVnode) ? EmptyObject : oldVnode.data.props;
2610
- if (oldProps === props) {
2611
- return;
2670
+ let oldProps;
2671
+ if (!isNull(oldVnode)) {
2672
+ oldProps = oldVnode.data.props;
2673
+ const oldSpread = oldVnode.data.spread;
2674
+ if (oldProps === props && oldSpread === spread) {
2675
+ return;
2676
+ }
2677
+ if (isUndefined$1(oldProps)) {
2678
+ oldProps = EmptyObject;
2679
+ }
2680
+ if (!isUndefined$1(oldSpread)) {
2681
+ oldProps = assign({}, oldProps, oldSpread);
2682
+ }
2683
+ }
2684
+ if (!isUndefined$1(spread)) {
2685
+ props = assign({}, props, spread);
2612
2686
  }
2613
2687
  const isFirstPatch = isNull(oldVnode);
2614
2688
  const { elm, sel } = vnode;
@@ -2618,7 +2692,9 @@
2618
2692
  // Set the property if it's the first time is is patched or if the previous property is
2619
2693
  // different than the one previously set.
2620
2694
  if (isFirstPatch ||
2621
- cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
2695
+ cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key]) ||
2696
+ !(key in oldProps) // this is required because the above case will pass when `cur` is `undefined` and key is missing in `oldProps`
2697
+ ) {
2622
2698
  setProperty(elm, key, cur);
2623
2699
  }
2624
2700
  }
@@ -3580,17 +3656,20 @@
3580
3656
  // [h]tml node
3581
3657
  function h(sel, data, children = EmptyArray) {
3582
3658
  const vmBeingRendered = getVMBeingRendered();
3583
- let elm;
3584
- const { key } = data;
3585
- return {
3659
+ const { key, ref } = data;
3660
+ const vnode = {
3586
3661
  type: 2 /* VNodeType.Element */,
3587
3662
  sel,
3588
3663
  data,
3589
3664
  children,
3590
- elm,
3665
+ elm: undefined,
3591
3666
  key,
3592
3667
  owner: vmBeingRendered,
3593
3668
  };
3669
+ if (!isUndefined$1(ref)) {
3670
+ setRefVNode(vmBeingRendered, ref, vnode);
3671
+ }
3672
+ return vnode;
3594
3673
  }
3595
3674
  // [t]ab[i]ndex function
3596
3675
  function ti(value) {
@@ -3622,7 +3701,7 @@
3622
3701
  // [c]ustom element node
3623
3702
  function c(sel, Ctor, data, children = EmptyArray) {
3624
3703
  const vmBeingRendered = getVMBeingRendered();
3625
- const { key } = data;
3704
+ const { key, ref } = data;
3626
3705
  let elm, aChildren, vm;
3627
3706
  const vnode = {
3628
3707
  type: 3 /* VNodeType.CustomElement */,
@@ -3638,6 +3717,9 @@
3638
3717
  vm,
3639
3718
  };
3640
3719
  addVNodeToChildLWC(vnode);
3720
+ if (!isUndefined$1(ref)) {
3721
+ setRefVNode(vmBeingRendered, ref, vnode);
3722
+ }
3641
3723
  return vnode;
3642
3724
  }
3643
3725
  // [i]terable node
@@ -4010,6 +4092,10 @@
4010
4092
  : createStylesheet(vm, stylesheetsContent);
4011
4093
  }
4012
4094
  if ("production" !== 'production') ;
4095
+ // reset the refs; they will be set during the tmpl() instantiation
4096
+ const hasRefVNodes = Boolean(html.hasRefs);
4097
+ vm.hasRefVNodes = hasRefVNodes;
4098
+ vm.refVNodes = hasRefVNodes ? create(null) : null;
4013
4099
  // right before producing the vnodes, we clear up all internal references
4014
4100
  // to custom elements from the template.
4015
4101
  vm.velements = [];
@@ -4321,6 +4407,8 @@
4321
4407
  tagName,
4322
4408
  mode,
4323
4409
  owner,
4410
+ refVNodes: null,
4411
+ hasRefVNodes: false,
4324
4412
  children: EmptyArray,
4325
4413
  aChildren: EmptyArray,
4326
4414
  velements: EmptyArray,
@@ -5500,7 +5588,7 @@
5500
5588
  }
5501
5589
  return ctor;
5502
5590
  }
5503
- /* version: 2.23.5 */
5591
+ /* version: 2.24.0 */
5504
5592
 
5505
5593
  /*
5506
5594
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5652,20 +5740,59 @@
5652
5740
  * @param baseRenderer Either null or the base renderer imported from 'lwc'.
5653
5741
  */
5654
5742
  function rendererFactory(baseRenderer) {
5655
- // Util functions
5656
- function assertInvariant(value, msg) {
5743
+ const renderer = (function (exports) {
5744
+
5745
+ /**
5746
+ * Copyright (C) 2018 salesforce.com, inc.
5747
+ */
5748
+ /*
5749
+ * Copyright (c) 2018, salesforce.com, inc.
5750
+ * All rights reserved.
5751
+ * SPDX-License-Identifier: MIT
5752
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5753
+ */
5754
+ function invariant(value, msg) {
5657
5755
  if (!value) {
5658
5756
  throw new Error(`Invariant Violation: ${msg}`);
5659
5757
  }
5660
5758
  }
5661
- function isNull(obj) {
5662
- return obj === null;
5759
+ function isTrue$1(value, msg) {
5760
+ if (!value) {
5761
+ throw new Error(`Assert Violation: ${msg}`);
5762
+ }
5663
5763
  }
5764
+ function isFalse$1(value, msg) {
5765
+ if (value) {
5766
+ throw new Error(`Assert Violation: ${msg}`);
5767
+ }
5768
+ }
5769
+ function fail(msg) {
5770
+ throw new Error(msg);
5771
+ }
5772
+
5773
+ var assert = /*#__PURE__*/Object.freeze({
5774
+ __proto__: null,
5775
+ invariant: invariant,
5776
+ isTrue: isTrue$1,
5777
+ isFalse: isFalse$1,
5778
+ fail: fail
5779
+ });
5664
5780
  function isUndefined(obj) {
5665
5781
  return obj === undefined;
5666
5782
  }
5667
- let getCustomElement;
5668
- let defineCustomElement;
5783
+ function isNull(obj) {
5784
+ return obj === null;
5785
+ }
5786
+ /** version: 2.24.0 */
5787
+
5788
+ /*
5789
+ * Copyright (c) 2018, salesforce.com, inc.
5790
+ * All rights reserved.
5791
+ * SPDX-License-Identifier: MIT
5792
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5793
+ */
5794
+ exports.getCustomElement = void 0;
5795
+ exports.defineCustomElement = void 0;
5669
5796
  let HTMLElementConstructor;
5670
5797
  function isCustomElementRegistryAvailable() {
5671
5798
  if (typeof customElements === 'undefined') {
@@ -5691,21 +5818,21 @@
5691
5818
  }
5692
5819
  }
5693
5820
  if (isCustomElementRegistryAvailable()) {
5694
- getCustomElement = customElements.get.bind(customElements);
5695
- defineCustomElement = customElements.define.bind(customElements);
5821
+ exports.getCustomElement = customElements.get.bind(customElements);
5822
+ exports.defineCustomElement = customElements.define.bind(customElements);
5696
5823
  HTMLElementConstructor = HTMLElement;
5697
5824
  }
5698
5825
  else {
5699
5826
  const registry = Object.create(null);
5700
5827
  const reverseRegistry = new WeakMap();
5701
- defineCustomElement = function define(name, ctor) {
5828
+ exports.defineCustomElement = function define(name, ctor) {
5702
5829
  if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
5703
5830
  throw new TypeError(`Invalid Registration`);
5704
5831
  }
5705
5832
  registry[name] = ctor;
5706
5833
  reverseRegistry.set(ctor, name);
5707
5834
  };
5708
- getCustomElement = function get(name) {
5835
+ exports.getCustomElement = function get(name) {
5709
5836
  return registry[name];
5710
5837
  };
5711
5838
  HTMLElementConstructor = function HTMLElement() {
@@ -5737,12 +5864,12 @@
5737
5864
  function createComment(content) {
5738
5865
  return document.createComment(content);
5739
5866
  }
5740
- let createFragment;
5867
+ exports.createFragment = void 0;
5741
5868
  // IE11 lacks support for this feature
5742
5869
  const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
5743
5870
  if (SUPPORTS_TEMPLATE) {
5744
5871
  // Parse the fragment HTML string into DOM
5745
- createFragment = function (html) {
5872
+ exports.createFragment = function (html) {
5746
5873
  const template = document.createElement('template');
5747
5874
  template.innerHTML = html;
5748
5875
  return template.content.firstChild;
@@ -5774,7 +5901,7 @@
5774
5901
  return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
5775
5902
  };
5776
5903
  // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
5777
- createFragment = function (html) {
5904
+ exports.createFragment = function (html) {
5778
5905
  const wrapperTags = topLevelWrappingMap[getTagName(html)];
5779
5906
  if (!isUndefined(wrapperTags)) {
5780
5907
  for (const wrapperTag of wrapperTags) {
@@ -5894,47 +6021,47 @@
5894
6021
  return node.isConnected;
5895
6022
  }
5896
6023
  function assertInstanceOfHTMLElement(elm, msg) {
5897
- assertInvariant(elm instanceof HTMLElement, msg);
6024
+ assert.invariant(elm instanceof HTMLElement, msg);
5898
6025
  }
5899
6026
  const HTMLElementExported = HTMLElementConstructor;
5900
- const renderer = {
5901
- HTMLElementExported,
5902
- insert,
5903
- remove,
5904
- cloneNode,
5905
- createFragment,
5906
- createElement,
5907
- createText,
5908
- createComment,
5909
- nextSibling,
5910
- attachShadow,
5911
- getProperty,
5912
- setProperty,
5913
- setText,
5914
- getAttribute,
5915
- setAttribute,
5916
- removeAttribute,
5917
- addEventListener,
5918
- removeEventListener,
5919
- dispatchEvent,
5920
- getClassList,
5921
- setCSSStyleProperty,
5922
- getBoundingClientRect,
5923
- querySelector,
5924
- querySelectorAll,
5925
- getElementsByTagName,
5926
- getElementsByClassName,
5927
- getChildren,
5928
- getChildNodes,
5929
- getFirstChild,
5930
- getFirstElementChild,
5931
- getLastChild,
5932
- getLastElementChild,
5933
- isConnected,
5934
- assertInstanceOfHTMLElement,
5935
- defineCustomElement,
5936
- getCustomElement,
5937
- };
6027
+
6028
+ exports.HTMLElementExported = HTMLElementExported;
6029
+ exports.addEventListener = addEventListener;
6030
+ exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
6031
+ exports.attachShadow = attachShadow;
6032
+ exports.cloneNode = cloneNode;
6033
+ exports.createComment = createComment;
6034
+ exports.createElement = createElement;
6035
+ exports.createText = createText;
6036
+ exports.dispatchEvent = dispatchEvent;
6037
+ exports.getAttribute = getAttribute;
6038
+ exports.getBoundingClientRect = getBoundingClientRect;
6039
+ exports.getChildNodes = getChildNodes;
6040
+ exports.getChildren = getChildren;
6041
+ exports.getClassList = getClassList;
6042
+ exports.getElementsByClassName = getElementsByClassName;
6043
+ exports.getElementsByTagName = getElementsByTagName;
6044
+ exports.getFirstChild = getFirstChild;
6045
+ exports.getFirstElementChild = getFirstElementChild;
6046
+ exports.getLastChild = getLastChild;
6047
+ exports.getLastElementChild = getLastElementChild;
6048
+ exports.getProperty = getProperty;
6049
+ exports.insert = insert;
6050
+ exports.isConnected = isConnected;
6051
+ exports.nextSibling = nextSibling;
6052
+ exports.querySelector = querySelector;
6053
+ exports.querySelectorAll = querySelectorAll;
6054
+ exports.remove = remove;
6055
+ exports.removeAttribute = removeAttribute;
6056
+ exports.removeEventListener = removeEventListener;
6057
+ exports.setAttribute = setAttribute;
6058
+ exports.setCSSStyleProperty = setCSSStyleProperty;
6059
+ exports.setProperty = setProperty;
6060
+ exports.setText = setText;
6061
+
6062
+ return exports;
6063
+
6064
+ })({});
5938
6065
  // Meant to inherit any properties passed via the base renderer as the argument to the factory.
5939
6066
  Object.setPrototypeOf(renderer, baseRenderer);
5940
6067
  return renderer;
@@ -6267,7 +6394,7 @@
6267
6394
  });
6268
6395
  freeze(LightningElement);
6269
6396
  seal(LightningElement.prototype);
6270
- /* version: 2.23.5 */
6397
+ /* version: 2.24.0 */
6271
6398
 
6272
6399
  exports.LightningElement = LightningElement;
6273
6400
  exports.__unstable__ProfilerControl = profilerControl;