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