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