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
@@ -302,9 +302,9 @@ var LWC = (function (exports) {
302
302
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
303
303
  */
304
304
  // Increment whenever the LWC template compiler changes
305
- const LWC_VERSION = "2.23.5";
305
+ const LWC_VERSION = "2.24.0";
306
306
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
307
- /** version: 2.23.5 */
307
+ /** version: 2.24.0 */
308
308
 
309
309
  /**
310
310
  * Copyright (C) 2018 salesforce.com, inc.
@@ -386,7 +386,7 @@ var LWC = (function (exports) {
386
386
  patch$1(propName);
387
387
  }
388
388
  }
389
- /** version: 2.23.5 */
389
+ /** version: 2.24.0 */
390
390
 
391
391
  /**
392
392
  * Copyright (C) 2018 salesforce.com, inc.
@@ -465,7 +465,7 @@ var LWC = (function (exports) {
465
465
  setFeatureFlag(name, value);
466
466
  }
467
467
  }
468
- /** version: 2.23.5 */
468
+ /** version: 2.24.0 */
469
469
 
470
470
  /*
471
471
  * Copyright (c) 2018, salesforce.com, inc.
@@ -599,6 +599,20 @@ var LWC = (function (exports) {
599
599
  }
600
600
  return list;
601
601
  }
602
+ // Set a ref (lwc:ref) on a VM, from a template API
603
+ function setRefVNode(vm, ref, vnode) {
604
+ if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
605
+ throw new Error('refVNodes must be defined when setting a ref');
606
+ }
607
+ // If this method is called, then vm.refVNodes is set as the template has refs.
608
+ // If not, then something went wrong and we threw an error above.
609
+ const refVNodes = vm.refVNodes;
610
+ // In cases of conflict (two elements with the same ref), prefer, the last one,
611
+ // in depth-first traversal order.
612
+ if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
613
+ refVNodes[ref] = vnode;
614
+ }
615
+ }
602
616
 
603
617
  /*
604
618
  * Copyright (c) 2019, salesforce.com, inc.
@@ -1915,6 +1929,8 @@ var LWC = (function (exports) {
1915
1929
  },
1916
1930
  };
1917
1931
  }
1932
+ const EMPTY_REFS = freeze(create(null));
1933
+ const refsCache = new WeakMap();
1918
1934
  /**
1919
1935
  * This class is the base class for any LWC element.
1920
1936
  * Some elements directly extends this class, others implement it via inheritance.
@@ -2094,6 +2110,70 @@ var LWC = (function (exports) {
2094
2110
  }
2095
2111
  return vm.shadowRoot;
2096
2112
  },
2113
+ get refs() {
2114
+ const vm = getAssociatedVM(this);
2115
+ if (isUpdatingTemplate) {
2116
+ if (process.env.NODE_ENV !== 'production') {
2117
+ logError(`this.refs should not be called while ${getComponentTag(vm)} is rendering. Use this.refs only when the DOM is stable, e.g. in renderedCallback().`);
2118
+ }
2119
+ // If the template is in the process of being updated, then we don't want to go through the normal
2120
+ // process of returning the refs and caching them, because the state of the refs is unstable.
2121
+ // This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
2122
+ // based on `this.refs.bar`.
2123
+ return;
2124
+ }
2125
+ if (process.env.NODE_ENV !== 'production') {
2126
+ warnIfInvokedDuringConstruction(vm, 'refs');
2127
+ }
2128
+ const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
2129
+ // If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
2130
+ // if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
2131
+ // so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
2132
+ // `warnIfInvokedDuringConstruction` above).
2133
+ if (process.env.NODE_ENV !== 'production' &&
2134
+ isNull(cmpTemplate) &&
2135
+ !isBeingConstructed(vm)) {
2136
+ logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` +
2137
+ `invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` +
2138
+ `been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
2139
+ }
2140
+ // For backwards compatibility with component written before template refs
2141
+ // were introduced, we return undefined if the template has no refs defined
2142
+ // anywhere. This fixes components that may want to add an expando called `refs`
2143
+ // and are checking if it exists with `if (this.refs)` before adding it.
2144
+ // Note it is not sufficient to just check if `refVNodes` is null or empty,
2145
+ // because a template may have `lwc:ref` defined within a falsy `if:true` block.
2146
+ if (!hasRefVNodes) {
2147
+ return;
2148
+ }
2149
+ // For templates that are using `lwc:ref`, if there are no refs currently available
2150
+ // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
2151
+ if (isNull(refVNodes)) {
2152
+ return EMPTY_REFS;
2153
+ }
2154
+ // The refNodes can be cached based on the refVNodes, since the refVNodes
2155
+ // are recreated from scratch every time the template is rendered.
2156
+ // This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
2157
+ let refs = refsCache.get(refVNodes);
2158
+ if (isUndefined$1(refs)) {
2159
+ refs = create(null);
2160
+ for (const key of keys(refVNodes)) {
2161
+ refs[key] = refVNodes[key].elm;
2162
+ }
2163
+ freeze(refs);
2164
+ refsCache.set(refVNodes, refs);
2165
+ }
2166
+ return refs;
2167
+ },
2168
+ // For backwards compat, we allow component authors to set `refs` as an expando
2169
+ set refs(value) {
2170
+ defineProperty(this, 'refs', {
2171
+ configurable: true,
2172
+ enumerable: true,
2173
+ writable: true,
2174
+ value,
2175
+ });
2176
+ },
2097
2177
  get shadowRoot() {
2098
2178
  // From within the component instance, the shadowRoot is always reported as "closed".
2099
2179
  // Authors should rely on this.template instead.
@@ -3682,13 +3762,27 @@ var LWC = (function (exports) {
3682
3762
  return sel === 'input' && (key === 'value' || key === 'checked');
3683
3763
  }
3684
3764
  function patchProps(oldVnode, vnode, renderer) {
3685
- const { props } = vnode.data;
3686
- if (isUndefined$1(props)) {
3765
+ let { props } = vnode.data;
3766
+ const { spread } = vnode.data;
3767
+ if (isUndefined$1(props) && isUndefined$1(spread)) {
3687
3768
  return;
3688
3769
  }
3689
- const oldProps = isNull(oldVnode) ? EmptyObject : oldVnode.data.props;
3690
- if (oldProps === props) {
3691
- return;
3770
+ let oldProps;
3771
+ if (!isNull(oldVnode)) {
3772
+ oldProps = oldVnode.data.props;
3773
+ const oldSpread = oldVnode.data.spread;
3774
+ if (oldProps === props && oldSpread === spread) {
3775
+ return;
3776
+ }
3777
+ if (isUndefined$1(oldProps)) {
3778
+ oldProps = EmptyObject;
3779
+ }
3780
+ if (!isUndefined$1(oldSpread)) {
3781
+ oldProps = assign({}, oldProps, oldSpread);
3782
+ }
3783
+ }
3784
+ if (!isUndefined$1(spread)) {
3785
+ props = assign({}, props, spread);
3692
3786
  }
3693
3787
  const isFirstPatch = isNull(oldVnode);
3694
3788
  const { elm, sel } = vnode;
@@ -3698,7 +3792,9 @@ var LWC = (function (exports) {
3698
3792
  // Set the property if it's the first time is is patched or if the previous property is
3699
3793
  // different than the one previously set.
3700
3794
  if (isFirstPatch ||
3701
- cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
3795
+ cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key]) ||
3796
+ !(key in oldProps) // this is required because the above case will pass when `cur` is `undefined` and key is missing in `oldProps`
3797
+ ) {
3702
3798
  // Additional verification if properties are supported by the element
3703
3799
  // Validation relies on html properties and public properties being defined on the element,
3704
3800
  // SSR has its own custom validation.
@@ -4758,17 +4854,20 @@ var LWC = (function (exports) {
4758
4854
  }
4759
4855
  });
4760
4856
  }
4761
- let elm;
4762
- const { key } = data;
4763
- return {
4857
+ const { key, ref } = data;
4858
+ const vnode = {
4764
4859
  type: 2 /* VNodeType.Element */,
4765
4860
  sel,
4766
4861
  data,
4767
4862
  children,
4768
- elm,
4863
+ elm: undefined,
4769
4864
  key,
4770
4865
  owner: vmBeingRendered,
4771
4866
  };
4867
+ if (!isUndefined$1(ref)) {
4868
+ setRefVNode(vmBeingRendered, ref, vnode);
4869
+ }
4870
+ return vnode;
4772
4871
  }
4773
4872
  // [t]ab[i]ndex function
4774
4873
  function ti(value) {
@@ -4833,7 +4932,7 @@ var LWC = (function (exports) {
4833
4932
  });
4834
4933
  }
4835
4934
  }
4836
- const { key } = data;
4935
+ const { key, ref } = data;
4837
4936
  let elm, aChildren, vm;
4838
4937
  const vnode = {
4839
4938
  type: 3 /* VNodeType.CustomElement */,
@@ -4849,6 +4948,9 @@ var LWC = (function (exports) {
4849
4948
  vm,
4850
4949
  };
4851
4950
  addVNodeToChildLWC(vnode);
4951
+ if (!isUndefined$1(ref)) {
4952
+ setRefVNode(vmBeingRendered, ref, vnode);
4953
+ }
4852
4954
  return vnode;
4853
4955
  }
4854
4956
  // [i]terable node
@@ -5377,6 +5479,10 @@ var LWC = (function (exports) {
5377
5479
  // add the VM to the list of host VMs that can be re-rendered if html is swapped
5378
5480
  setActiveVM(vm);
5379
5481
  }
5482
+ // reset the refs; they will be set during the tmpl() instantiation
5483
+ const hasRefVNodes = Boolean(html.hasRefs);
5484
+ vm.hasRefVNodes = hasRefVNodes;
5485
+ vm.refVNodes = hasRefVNodes ? create(null) : null;
5380
5486
  // right before producing the vnodes, we clear up all internal references
5381
5487
  // to custom elements from the template.
5382
5488
  vm.velements = [];
@@ -5735,6 +5841,8 @@ var LWC = (function (exports) {
5735
5841
  tagName,
5736
5842
  mode,
5737
5843
  owner,
5844
+ refVNodes: null,
5845
+ hasRefVNodes: false,
5738
5846
  children: EmptyArray,
5739
5847
  aChildren: EmptyArray,
5740
5848
  velements: EmptyArray,
@@ -7137,7 +7245,7 @@ var LWC = (function (exports) {
7137
7245
  }
7138
7246
  return ctor;
7139
7247
  }
7140
- /* version: 2.23.5 */
7248
+ /* version: 2.24.0 */
7141
7249
 
7142
7250
  /*
7143
7251
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7298,20 +7406,59 @@ var LWC = (function (exports) {
7298
7406
  * @param baseRenderer Either null or the base renderer imported from 'lwc'.
7299
7407
  */
7300
7408
  function rendererFactory(baseRenderer) {
7301
- // Util functions
7302
- function assertInvariant(value, msg) {
7409
+ const renderer = (function (exports) {
7410
+
7411
+ /**
7412
+ * Copyright (C) 2018 salesforce.com, inc.
7413
+ */
7414
+ /*
7415
+ * Copyright (c) 2018, salesforce.com, inc.
7416
+ * All rights reserved.
7417
+ * SPDX-License-Identifier: MIT
7418
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7419
+ */
7420
+ function invariant(value, msg) {
7303
7421
  if (!value) {
7304
7422
  throw new Error(`Invariant Violation: ${msg}`);
7305
7423
  }
7306
7424
  }
7307
- function isNull(obj) {
7308
- return obj === null;
7425
+ function isTrue$1(value, msg) {
7426
+ if (!value) {
7427
+ throw new Error(`Assert Violation: ${msg}`);
7428
+ }
7309
7429
  }
7430
+ function isFalse$1(value, msg) {
7431
+ if (value) {
7432
+ throw new Error(`Assert Violation: ${msg}`);
7433
+ }
7434
+ }
7435
+ function fail(msg) {
7436
+ throw new Error(msg);
7437
+ }
7438
+
7439
+ var assert = /*#__PURE__*/Object.freeze({
7440
+ __proto__: null,
7441
+ invariant: invariant,
7442
+ isTrue: isTrue$1,
7443
+ isFalse: isFalse$1,
7444
+ fail: fail
7445
+ });
7310
7446
  function isUndefined(obj) {
7311
7447
  return obj === undefined;
7312
7448
  }
7313
- let getCustomElement;
7314
- let defineCustomElement;
7449
+ function isNull(obj) {
7450
+ return obj === null;
7451
+ }
7452
+ /** version: 2.24.0 */
7453
+
7454
+ /*
7455
+ * Copyright (c) 2018, salesforce.com, inc.
7456
+ * All rights reserved.
7457
+ * SPDX-License-Identifier: MIT
7458
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7459
+ */
7460
+ exports.getCustomElement = void 0;
7461
+ exports.defineCustomElement = void 0;
7315
7462
  let HTMLElementConstructor;
7316
7463
  function isCustomElementRegistryAvailable() {
7317
7464
  if (typeof customElements === 'undefined') {
@@ -7337,21 +7484,21 @@ var LWC = (function (exports) {
7337
7484
  }
7338
7485
  }
7339
7486
  if (isCustomElementRegistryAvailable()) {
7340
- getCustomElement = customElements.get.bind(customElements);
7341
- defineCustomElement = customElements.define.bind(customElements);
7487
+ exports.getCustomElement = customElements.get.bind(customElements);
7488
+ exports.defineCustomElement = customElements.define.bind(customElements);
7342
7489
  HTMLElementConstructor = HTMLElement;
7343
7490
  }
7344
7491
  else {
7345
7492
  const registry = Object.create(null);
7346
7493
  const reverseRegistry = new WeakMap();
7347
- defineCustomElement = function define(name, ctor) {
7494
+ exports.defineCustomElement = function define(name, ctor) {
7348
7495
  if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
7349
7496
  throw new TypeError(`Invalid Registration`);
7350
7497
  }
7351
7498
  registry[name] = ctor;
7352
7499
  reverseRegistry.set(ctor, name);
7353
7500
  };
7354
- getCustomElement = function get(name) {
7501
+ exports.getCustomElement = function get(name) {
7355
7502
  return registry[name];
7356
7503
  };
7357
7504
  HTMLElementConstructor = function HTMLElement() {
@@ -7383,12 +7530,12 @@ var LWC = (function (exports) {
7383
7530
  function createComment(content) {
7384
7531
  return document.createComment(content);
7385
7532
  }
7386
- let createFragment;
7533
+ exports.createFragment = void 0;
7387
7534
  // IE11 lacks support for this feature
7388
7535
  const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
7389
7536
  if (SUPPORTS_TEMPLATE) {
7390
7537
  // Parse the fragment HTML string into DOM
7391
- createFragment = function (html) {
7538
+ exports.createFragment = function (html) {
7392
7539
  const template = document.createElement('template');
7393
7540
  template.innerHTML = html;
7394
7541
  return template.content.firstChild;
@@ -7420,7 +7567,7 @@ var LWC = (function (exports) {
7420
7567
  return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
7421
7568
  };
7422
7569
  // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
7423
- createFragment = function (html) {
7570
+ exports.createFragment = function (html) {
7424
7571
  const wrapperTags = topLevelWrappingMap[getTagName(html)];
7425
7572
  if (!isUndefined(wrapperTags)) {
7426
7573
  for (const wrapperTag of wrapperTags) {
@@ -7540,47 +7687,47 @@ var LWC = (function (exports) {
7540
7687
  return node.isConnected;
7541
7688
  }
7542
7689
  function assertInstanceOfHTMLElement(elm, msg) {
7543
- assertInvariant(elm instanceof HTMLElement, msg);
7690
+ assert.invariant(elm instanceof HTMLElement, msg);
7544
7691
  }
7545
7692
  const HTMLElementExported = HTMLElementConstructor;
7546
- const renderer = {
7547
- HTMLElementExported,
7548
- insert,
7549
- remove,
7550
- cloneNode,
7551
- createFragment,
7552
- createElement,
7553
- createText,
7554
- createComment,
7555
- nextSibling,
7556
- attachShadow,
7557
- getProperty,
7558
- setProperty,
7559
- setText,
7560
- getAttribute,
7561
- setAttribute,
7562
- removeAttribute,
7563
- addEventListener,
7564
- removeEventListener,
7565
- dispatchEvent,
7566
- getClassList,
7567
- setCSSStyleProperty,
7568
- getBoundingClientRect,
7569
- querySelector,
7570
- querySelectorAll,
7571
- getElementsByTagName,
7572
- getElementsByClassName,
7573
- getChildren,
7574
- getChildNodes,
7575
- getFirstChild,
7576
- getFirstElementChild,
7577
- getLastChild,
7578
- getLastElementChild,
7579
- isConnected,
7580
- assertInstanceOfHTMLElement,
7581
- defineCustomElement,
7582
- getCustomElement,
7583
- };
7693
+
7694
+ exports.HTMLElementExported = HTMLElementExported;
7695
+ exports.addEventListener = addEventListener;
7696
+ exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
7697
+ exports.attachShadow = attachShadow;
7698
+ exports.cloneNode = cloneNode;
7699
+ exports.createComment = createComment;
7700
+ exports.createElement = createElement;
7701
+ exports.createText = createText;
7702
+ exports.dispatchEvent = dispatchEvent;
7703
+ exports.getAttribute = getAttribute;
7704
+ exports.getBoundingClientRect = getBoundingClientRect;
7705
+ exports.getChildNodes = getChildNodes;
7706
+ exports.getChildren = getChildren;
7707
+ exports.getClassList = getClassList;
7708
+ exports.getElementsByClassName = getElementsByClassName;
7709
+ exports.getElementsByTagName = getElementsByTagName;
7710
+ exports.getFirstChild = getFirstChild;
7711
+ exports.getFirstElementChild = getFirstElementChild;
7712
+ exports.getLastChild = getLastChild;
7713
+ exports.getLastElementChild = getLastElementChild;
7714
+ exports.getProperty = getProperty;
7715
+ exports.insert = insert;
7716
+ exports.isConnected = isConnected;
7717
+ exports.nextSibling = nextSibling;
7718
+ exports.querySelector = querySelector;
7719
+ exports.querySelectorAll = querySelectorAll;
7720
+ exports.remove = remove;
7721
+ exports.removeAttribute = removeAttribute;
7722
+ exports.removeEventListener = removeEventListener;
7723
+ exports.setAttribute = setAttribute;
7724
+ exports.setCSSStyleProperty = setCSSStyleProperty;
7725
+ exports.setProperty = setProperty;
7726
+ exports.setText = setText;
7727
+
7728
+ return exports;
7729
+
7730
+ })({});
7584
7731
  // Meant to inherit any properties passed via the base renderer as the argument to the factory.
7585
7732
  Object.setPrototypeOf(renderer, baseRenderer);
7586
7733
  return renderer;
@@ -7921,7 +8068,7 @@ var LWC = (function (exports) {
7921
8068
  });
7922
8069
  freeze(LightningElement);
7923
8070
  seal(LightningElement.prototype);
7924
- /* version: 2.23.5 */
8071
+ /* version: 2.24.0 */
7925
8072
 
7926
8073
  exports.LightningElement = LightningElement;
7927
8074
  exports.__unstable__ProfilerControl = profilerControl;