lwc 2.23.6 → 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 +126 -18
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +126 -18
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +104 -16
  5. package/dist/engine-dom/iife/es5/engine-dom.js +178 -38
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +147 -24
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +126 -18
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +104 -16
  11. package/dist/engine-dom/umd/es5/engine-dom.js +178 -38
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +147 -24
  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
@@ -365,9 +365,9 @@ var LWC = (function (exports) {
365
365
  // Increment whenever the LWC template compiler changes
366
366
 
367
367
 
368
- var LWC_VERSION = "2.23.6";
368
+ var LWC_VERSION = "2.24.0";
369
369
  var LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
370
- /** version: 2.23.6 */
370
+ /** version: 2.24.0 */
371
371
 
372
372
  /**
373
373
  * Copyright (C) 2018 salesforce.com, inc.
@@ -461,7 +461,7 @@ var LWC = (function (exports) {
461
461
  patch$1(propName);
462
462
  }
463
463
  }
464
- /** version: 2.23.6 */
464
+ /** version: 2.24.0 */
465
465
 
466
466
  /**
467
467
  * Copyright (C) 2018 salesforce.com, inc.
@@ -554,7 +554,7 @@ var LWC = (function (exports) {
554
554
  setFeatureFlag(name, value);
555
555
  }
556
556
  }
557
- /** version: 2.23.6 */
557
+ /** version: 2.24.0 */
558
558
 
559
559
  /*
560
560
  * Copyright (c) 2018, salesforce.com, inc.
@@ -732,6 +732,22 @@ var LWC = (function (exports) {
732
732
  }
733
733
 
734
734
  return list;
735
+ } // Set a ref (lwc:ref) on a VM, from a template API
736
+
737
+
738
+ function setRefVNode(vm, ref, vnode) {
739
+ if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
740
+ throw new Error('refVNodes must be defined when setting a ref');
741
+ } // If this method is called, then vm.refVNodes is set as the template has refs.
742
+ // If not, then something went wrong and we threw an error above.
743
+
744
+
745
+ var refVNodes = vm.refVNodes; // In cases of conflict (two elements with the same ref), prefer, the last one,
746
+ // in depth-first traversal order.
747
+
748
+ if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
749
+ refVNodes[ref] = vnode;
750
+ }
735
751
  }
736
752
  /*
737
753
  * Copyright (c) 2019, salesforce.com, inc.
@@ -2394,13 +2410,15 @@ var LWC = (function (exports) {
2394
2410
  }
2395
2411
  };
2396
2412
  }
2413
+
2414
+ var EMPTY_REFS = freeze(create(null));
2415
+ var refsCache = new WeakMap();
2397
2416
  /**
2398
2417
  * This class is the base class for any LWC element.
2399
2418
  * Some elements directly extends this class, others implement it via inheritance.
2400
2419
  **/
2401
2420
  // @ts-ignore
2402
2421
 
2403
-
2404
2422
  var LightningElement = function LightningElement() {
2405
2423
  // This should be as performant as possible, while any initialization should be done lazily
2406
2424
  if (isNull(vmBeingConstructed)) {
@@ -2627,6 +2645,91 @@ var LWC = (function (exports) {
2627
2645
  return vm.shadowRoot;
2628
2646
  },
2629
2647
 
2648
+ get refs() {
2649
+ var vm = getAssociatedVM(this);
2650
+
2651
+ if (isUpdatingTemplate) {
2652
+ if (process.env.NODE_ENV !== 'production') {
2653
+ 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()."));
2654
+ } // If the template is in the process of being updated, then we don't want to go through the normal
2655
+ // process of returning the refs and caching them, because the state of the refs is unstable.
2656
+ // This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
2657
+ // based on `this.refs.bar`.
2658
+
2659
+
2660
+ return;
2661
+ }
2662
+
2663
+ if (process.env.NODE_ENV !== 'production') {
2664
+ warnIfInvokedDuringConstruction(vm, 'refs');
2665
+ }
2666
+
2667
+ var refVNodes = vm.refVNodes,
2668
+ hasRefVNodes = vm.hasRefVNodes,
2669
+ cmpTemplate = vm.cmpTemplate; // If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
2670
+ // if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
2671
+ // so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
2672
+ // `warnIfInvokedDuringConstruction` above).
2673
+
2674
+ if (process.env.NODE_ENV !== 'production' && isNull(cmpTemplate) && !isBeingConstructed(vm)) {
2675
+ 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().");
2676
+ } // For backwards compatibility with component written before template refs
2677
+ // were introduced, we return undefined if the template has no refs defined
2678
+ // anywhere. This fixes components that may want to add an expando called `refs`
2679
+ // and are checking if it exists with `if (this.refs)` before adding it.
2680
+ // Note it is not sufficient to just check if `refVNodes` is null or empty,
2681
+ // because a template may have `lwc:ref` defined within a falsy `if:true` block.
2682
+
2683
+
2684
+ if (!hasRefVNodes) {
2685
+ return;
2686
+ } // For templates that are using `lwc:ref`, if there are no refs currently available
2687
+ // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
2688
+
2689
+
2690
+ if (isNull(refVNodes)) {
2691
+ return EMPTY_REFS;
2692
+ } // The refNodes can be cached based on the refVNodes, since the refVNodes
2693
+ // are recreated from scratch every time the template is rendered.
2694
+ // This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
2695
+
2696
+
2697
+ var refs = refsCache.get(refVNodes);
2698
+
2699
+ if (isUndefined$1(refs)) {
2700
+ refs = create(null);
2701
+
2702
+ var _iterator3 = _createForOfIteratorHelper(keys(refVNodes)),
2703
+ _step3;
2704
+
2705
+ try {
2706
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2707
+ var key = _step3.value;
2708
+ refs[key] = refVNodes[key].elm;
2709
+ }
2710
+ } catch (err) {
2711
+ _iterator3.e(err);
2712
+ } finally {
2713
+ _iterator3.f();
2714
+ }
2715
+
2716
+ freeze(refs);
2717
+ refsCache.set(refVNodes, refs);
2718
+ }
2719
+
2720
+ return refs;
2721
+ },
2722
+
2723
+ // For backwards compat, we allow component authors to set `refs` as an expando
2724
+ set refs(value) {
2725
+ defineProperty(this, 'refs', {
2726
+ configurable: true,
2727
+ enumerable: true,
2728
+ writable: true,
2729
+ value: value
2730
+ });
2731
+ },
2732
+
2630
2733
  get shadowRoot() {
2631
2734
  // From within the component instance, the shadowRoot is always reported as "closed".
2632
2735
  // Authors should rely on this.template instead.
@@ -4542,15 +4645,33 @@ var LWC = (function (exports) {
4542
4645
 
4543
4646
  function patchProps(oldVnode, vnode, renderer) {
4544
4647
  var props = vnode.data.props;
4648
+ var spread = vnode.data.spread;
4545
4649
 
4546
- if (isUndefined$1(props)) {
4650
+ if (isUndefined$1(props) && isUndefined$1(spread)) {
4547
4651
  return;
4548
4652
  }
4549
4653
 
4550
- var oldProps = isNull(oldVnode) ? EmptyObject : oldVnode.data.props;
4654
+ var oldProps;
4551
4655
 
4552
- if (oldProps === props) {
4553
- return;
4656
+ if (!isNull(oldVnode)) {
4657
+ oldProps = oldVnode.data.props;
4658
+ var oldSpread = oldVnode.data.spread;
4659
+
4660
+ if (oldProps === props && oldSpread === spread) {
4661
+ return;
4662
+ }
4663
+
4664
+ if (isUndefined$1(oldProps)) {
4665
+ oldProps = EmptyObject;
4666
+ }
4667
+
4668
+ if (!isUndefined$1(oldSpread)) {
4669
+ oldProps = assign({}, oldProps, oldSpread);
4670
+ }
4671
+ }
4672
+
4673
+ if (!isUndefined$1(spread)) {
4674
+ props = assign({}, props, spread);
4554
4675
  }
4555
4676
 
4556
4677
  var isFirstPatch = isNull(oldVnode);
@@ -4563,7 +4684,8 @@ var LWC = (function (exports) {
4563
4684
  var cur = props[key]; // Set the property if it's the first time is is patched or if the previous property is
4564
4685
  // different than the one previously set.
4565
4686
 
4566
- if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
4687
+ 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`
4688
+ ) {
4567
4689
  // Additional verification if properties are supported by the element
4568
4690
  // Validation relies on html properties and public properties being defined on the element,
4569
4691
  // SSR has its own custom validation.
@@ -5631,19 +5753,25 @@ var LWC = (function (exports) {
5631
5753
  });
5632
5754
  }
5633
5755
 
5634
- var elm;
5635
- var key = data.key;
5636
- return {
5756
+ var key = data.key,
5757
+ ref = data.ref;
5758
+ var vnode = {
5637
5759
  type: 2
5638
5760
  /* VNodeType.Element */
5639
5761
  ,
5640
5762
  sel: sel,
5641
5763
  data: data,
5642
5764
  children: children,
5643
- elm: elm,
5765
+ elm: undefined,
5644
5766
  key: key,
5645
5767
  owner: vmBeingRendered
5646
5768
  };
5769
+
5770
+ if (!isUndefined$1(ref)) {
5771
+ setRefVNode(vmBeingRendered, ref, vnode);
5772
+ }
5773
+
5774
+ return vnode;
5647
5775
  } // [t]ab[i]ndex function
5648
5776
 
5649
5777
 
@@ -5724,7 +5852,8 @@ var LWC = (function (exports) {
5724
5852
  }
5725
5853
  }
5726
5854
 
5727
- var key = data.key;
5855
+ var key = data.key,
5856
+ ref = data.ref;
5728
5857
  var elm, aChildren, vm;
5729
5858
  var vnode = {
5730
5859
  type: 3
@@ -5742,6 +5871,11 @@ var LWC = (function (exports) {
5742
5871
  vm: vm
5743
5872
  };
5744
5873
  addVNodeToChildLWC(vnode);
5874
+
5875
+ if (!isUndefined$1(ref)) {
5876
+ setRefVNode(vmBeingRendered, ref, vnode);
5877
+ }
5878
+
5745
5879
  return vnode;
5746
5880
  } // [i]terable node
5747
5881
 
@@ -6396,10 +6530,14 @@ var LWC = (function (exports) {
6396
6530
  validateSlots(vm, html); // add the VM to the list of host VMs that can be re-rendered if html is swapped
6397
6531
 
6398
6532
  setActiveVM(vm);
6399
- } // right before producing the vnodes, we clear up all internal references
6400
- // to custom elements from the template.
6533
+ } // reset the refs; they will be set during the tmpl() instantiation
6401
6534
 
6402
6535
 
6536
+ var hasRefVNodes = Boolean(html.hasRefs);
6537
+ vm.hasRefVNodes = hasRefVNodes;
6538
+ vm.refVNodes = hasRefVNodes ? create(null) : null; // right before producing the vnodes, we clear up all internal references
6539
+ // to custom elements from the template.
6540
+
6403
6541
  vm.velements = []; // Set the global flag that template is being updated
6404
6542
 
6405
6543
  isUpdatingTemplate = true;
@@ -6811,6 +6949,8 @@ var LWC = (function (exports) {
6811
6949
  tagName: tagName,
6812
6950
  mode: mode,
6813
6951
  owner: owner,
6952
+ refVNodes: null,
6953
+ hasRefVNodes: false,
6814
6954
  children: EmptyArray,
6815
6955
  aChildren: EmptyArray,
6816
6956
  velements: EmptyArray,
@@ -8272,12 +8412,12 @@ var LWC = (function (exports) {
8272
8412
  function warnOnArrayMutation(stylesheets) {
8273
8413
  // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
8274
8414
  // we can at least warn when they use the most common mutation methods.
8275
- var _iterator3 = _createForOfIteratorHelper(ARRAY_MUTATION_METHODS),
8276
- _step3;
8415
+ var _iterator4 = _createForOfIteratorHelper(ARRAY_MUTATION_METHODS),
8416
+ _step4;
8277
8417
 
8278
8418
  try {
8279
8419
  var _loop2 = function _loop2() {
8280
- var prop = _step3.value;
8420
+ var prop = _step4.value;
8281
8421
  var originalArrayMethod = getOriginalArrayMethod(prop);
8282
8422
 
8283
8423
  stylesheets[prop] = function arrayMutationWarningWrapper() {
@@ -8287,13 +8427,13 @@ var LWC = (function (exports) {
8287
8427
  };
8288
8428
  };
8289
8429
 
8290
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
8430
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
8291
8431
  _loop2();
8292
8432
  }
8293
8433
  } catch (err) {
8294
- _iterator3.e(err);
8434
+ _iterator4.e(err);
8295
8435
  } finally {
8296
- _iterator3.f();
8436
+ _iterator4.f();
8297
8437
  }
8298
8438
  } // TODO [#2782]: eventually freezeTemplate() will _actually_ freeze the tmpl object. Today it
8299
8439
  // just warns on mutation.
@@ -8305,12 +8445,12 @@ var LWC = (function (exports) {
8305
8445
  warnOnArrayMutation(tmpl.stylesheets);
8306
8446
  }
8307
8447
 
8308
- var _iterator4 = _createForOfIteratorHelper(TEMPLATE_PROPS),
8309
- _step4;
8448
+ var _iterator5 = _createForOfIteratorHelper(TEMPLATE_PROPS),
8449
+ _step5;
8310
8450
 
8311
8451
  try {
8312
8452
  var _loop3 = function _loop3() {
8313
- var prop = _step4.value;
8453
+ var prop = _step5.value;
8314
8454
  var value = tmpl[prop];
8315
8455
  defineProperty(tmpl, prop, {
8316
8456
  enumerable: true,
@@ -8328,13 +8468,13 @@ var LWC = (function (exports) {
8328
8468
  });
8329
8469
  };
8330
8470
 
8331
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
8471
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
8332
8472
  _loop3();
8333
8473
  }
8334
8474
  } catch (err) {
8335
- _iterator4.e(err);
8475
+ _iterator5.e(err);
8336
8476
  } finally {
8337
- _iterator4.f();
8477
+ _iterator5.f();
8338
8478
  }
8339
8479
 
8340
8480
  var originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
@@ -8379,7 +8519,7 @@ var LWC = (function (exports) {
8379
8519
 
8380
8520
  return ctor;
8381
8521
  }
8382
- /* version: 2.23.6 */
8522
+ /* version: 2.24.0 */
8383
8523
 
8384
8524
  /*
8385
8525
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8607,7 +8747,7 @@ var LWC = (function (exports) {
8607
8747
  function isNull(obj) {
8608
8748
  return obj === null;
8609
8749
  }
8610
- /** version: 2.23.6 */
8750
+ /** version: 2.24.0 */
8611
8751
 
8612
8752
  /*
8613
8753
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8756,18 +8896,18 @@ var LWC = (function (exports) {
8756
8896
  var wrapperTags = topLevelWrappingMap[getTagName(html)];
8757
8897
 
8758
8898
  if (!isUndefined(wrapperTags)) {
8759
- var _iterator5 = _createForOfIteratorHelper(wrapperTags),
8760
- _step5;
8899
+ var _iterator6 = _createForOfIteratorHelper(wrapperTags),
8900
+ _step6;
8761
8901
 
8762
8902
  try {
8763
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
8764
- var wrapperTag = _step5.value;
8903
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
8904
+ var wrapperTag = _step6.value;
8765
8905
  html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
8766
8906
  }
8767
8907
  } catch (err) {
8768
- _iterator5.e(err);
8908
+ _iterator6.e(err);
8769
8909
  } finally {
8770
- _iterator5.f();
8910
+ _iterator6.f();
8771
8911
  }
8772
8912
  } // For IE11, the document title must not be undefined, but it can be an empty string
8773
8913
  // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
@@ -9337,7 +9477,7 @@ var LWC = (function (exports) {
9337
9477
  });
9338
9478
  freeze(LightningElement);
9339
9479
  seal(LightningElement.prototype);
9340
- /* version: 2.23.6 */
9480
+ /* version: 2.24.0 */
9341
9481
 
9342
9482
  exports.LightningElement = LightningElement;
9343
9483
  exports.__unstable__ProfilerControl = profilerControl;