lwc 2.20.4 → 2.22.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 (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +181 -127
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +181 -127
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +168 -115
  5. package/dist/engine-dom/iife/es5/engine-dom.js +226 -147
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +201 -119
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +181 -127
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +168 -115
  11. package/dist/engine-dom/umd/es5/engine-dom.js +226 -147
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +201 -119
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +89 -318
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +89 -318
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. 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.20.4 */
297
+ /** version: 2.22.0 */
298
298
 
299
299
  /*
300
300
  * Copyright (c) 2018, salesforce.com, inc.
@@ -595,18 +595,21 @@
595
595
  ArrayPush$1.call(this.listeners, reactiveObservers);
596
596
  }
597
597
  }
598
-
599
- /*
600
- * Copyright (c) 2018, salesforce.com, inc.
601
- * All rights reserved.
602
- * SPDX-License-Identifier: MIT
603
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
604
- */
605
598
  function componentValueMutated(vm, key) {
606
- valueMutated(vm.component, key);
599
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
600
+ {
601
+ valueMutated(vm.component, key);
602
+ }
607
603
  }
608
604
  function componentValueObserved(vm, key) {
609
- valueObserved(vm.component, key);
605
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
606
+ {
607
+ valueObserved(vm.component, key);
608
+ }
609
+ }
610
+ function createReactiveObserver(callback) {
611
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
612
+ return new ReactiveObserver(callback) ;
610
613
  }
611
614
 
612
615
  /*
@@ -1289,7 +1292,24 @@
1289
1292
  * change or being removed.
1290
1293
  */
1291
1294
  function unwrap(value) {
1292
- return reactiveMembrane.unwrapProxy(value);
1295
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1296
+ return reactiveMembrane.unwrapProxy(value) ;
1297
+ }
1298
+ function getReadOnlyProxy(value) {
1299
+ // We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
1300
+ // them from their parents. This applies to both the client and server.
1301
+ return reactiveMembrane.getReadOnlyProxy(value);
1302
+ }
1303
+ function getReactiveProxy(value) {
1304
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1305
+ return reactiveMembrane.getProxy(value) ;
1306
+ }
1307
+ // Making the component instance a live value when using Locker to support expandos.
1308
+ function markLockerLiveObject(obj) {
1309
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1310
+ {
1311
+ obj[lockerLivePropertyKey] = undefined;
1312
+ }
1293
1313
  }
1294
1314
 
1295
1315
  /*
@@ -1359,8 +1379,7 @@
1359
1379
  vm.setHook = setHook;
1360
1380
  vm.getHook = getHook;
1361
1381
  }
1362
- // Making the component instance a live value when using Locker to support expandos.
1363
- this[lockerLivePropertyKey] = undefined;
1382
+ markLockerLiveObject(this);
1364
1383
  // Linking elm, shadow root and component with the VM.
1365
1384
  associateVM(component, vm);
1366
1385
  associateVM(elm, vm);
@@ -1567,6 +1586,45 @@
1567
1586
  configurable: true,
1568
1587
  };
1569
1588
  }
1589
+ class AccessorReactiveObserver extends ReactiveObserver {
1590
+ constructor(vm, set) {
1591
+ super(() => {
1592
+ if (isFalse(this.debouncing)) {
1593
+ this.debouncing = true;
1594
+ addCallbackToNextTick(() => {
1595
+ if (isTrue(this.debouncing)) {
1596
+ const { value } = this;
1597
+ const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
1598
+ set.call(component, value);
1599
+ // de-bouncing after the call to the original setter to prevent
1600
+ // infinity loop if the setter itself is mutating things that
1601
+ // were accessed during the previous invocation.
1602
+ this.debouncing = false;
1603
+ if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
1604
+ // immediate rehydration due to a setter driven mutation, otherwise
1605
+ // the component will get rendered on the second tick, which it is not
1606
+ // desirable.
1607
+ rerenderVM(vm);
1608
+ }
1609
+ }
1610
+ });
1611
+ }
1612
+ });
1613
+ this.debouncing = false;
1614
+ }
1615
+ reset(value) {
1616
+ super.reset();
1617
+ this.debouncing = false;
1618
+ if (arguments.length > 0) {
1619
+ this.value = value;
1620
+ }
1621
+ }
1622
+ }
1623
+ function createAccessorReactiveObserver(vm, set) {
1624
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1625
+ return new AccessorReactiveObserver(vm, set)
1626
+ ;
1627
+ }
1570
1628
 
1571
1629
  /*
1572
1630
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1603,50 +1661,6 @@
1603
1661
  configurable: true
1604
1662
  };
1605
1663
  }
1606
- class AccessorReactiveObserver extends ReactiveObserver {
1607
- constructor(vm, set) {
1608
- super(() => {
1609
- if (isFalse(this.debouncing)) {
1610
- this.debouncing = true;
1611
- addCallbackToNextTick(() => {
1612
- if (isTrue(this.debouncing)) {
1613
- const {
1614
- value
1615
- } = this;
1616
- const {
1617
- isDirty: dirtyStateBeforeSetterCall,
1618
- component,
1619
- idx
1620
- } = vm;
1621
- set.call(component, value); // de-bouncing after the call to the original setter to prevent
1622
- // infinity loop if the setter itself is mutating things that
1623
- // were accessed during the previous invocation.
1624
-
1625
- this.debouncing = false;
1626
-
1627
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
1628
- // immediate rehydration due to a setter driven mutation, otherwise
1629
- // the component will get rendered on the second tick, which it is not
1630
- // desirable.
1631
- rerenderVM(vm);
1632
- }
1633
- }
1634
- });
1635
- }
1636
- });
1637
- this.debouncing = false;
1638
- }
1639
-
1640
- reset(value) {
1641
- super.reset();
1642
- this.debouncing = false;
1643
-
1644
- if (arguments.length > 0) {
1645
- this.value = value;
1646
- }
1647
- }
1648
-
1649
- }
1650
1664
  function createPublicAccessorDescriptor(key, descriptor) {
1651
1665
  const {
1652
1666
  get,
@@ -1674,7 +1688,7 @@
1674
1688
  let ro = vm.oar[key];
1675
1689
 
1676
1690
  if (isUndefined$1(ro)) {
1677
- ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
1691
+ ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
1678
1692
  } // every time we invoke this setter from outside (through this wrapper setter)
1679
1693
  // we should reset the value and then debounce just in case there is a pending
1680
1694
  // invocation the next tick that is not longer relevant since the value is changing
@@ -1704,7 +1718,7 @@
1704
1718
  */
1705
1719
  function track(target) {
1706
1720
  if (arguments.length === 1) {
1707
- return reactiveMembrane.getProxy(target);
1721
+ return getReactiveProxy(target);
1708
1722
  }
1709
1723
  throw new Error();
1710
1724
  }
@@ -1717,7 +1731,7 @@
1717
1731
  },
1718
1732
  set(newValue) {
1719
1733
  const vm = getAssociatedVM(this);
1720
- const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
1734
+ const reactiveOrAnyValue = getReactiveProxy(newValue);
1721
1735
  if (reactiveOrAnyValue !== vm.cmpFields[key]) {
1722
1736
  vm.cmpFields[key] = reactiveOrAnyValue;
1723
1737
  componentValueMutated(vm, key);
@@ -1970,7 +1984,7 @@
1970
1984
  fn = cachedSetterByKey[key] = function (newValue) {
1971
1985
  const vm = getAssociatedVM(this);
1972
1986
  const { setHook } = vm;
1973
- newValue = reactiveMembrane.getReadOnlyProxy(newValue);
1987
+ newValue = getReadOnlyProxy(newValue);
1974
1988
  setHook(vm.component, key, newValue);
1975
1989
  };
1976
1990
  }
@@ -2814,10 +2828,10 @@
2814
2828
  const { sel, owner, data: { svg }, } = vnode;
2815
2829
  const { createElement } = renderer;
2816
2830
  const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
2817
- const elm = createElement(sel, namespace);
2831
+ const elm = (vnode.elm = createElement(sel, namespace));
2818
2832
  linkNodeToShadow(elm, owner, renderer);
2819
- fallbackElmHook(elm, vnode, renderer);
2820
- vnode.elm = elm;
2833
+ applyStyleScoping(elm, owner, renderer);
2834
+ applyDomManual(elm, vnode);
2821
2835
  patchElementPropsAndAttrs$1(null, vnode, renderer);
2822
2836
  insertNode(elm, parent, anchor, renderer);
2823
2837
  mountVNodes(vnode.children, elm, renderer, null);
@@ -2855,9 +2869,10 @@
2855
2869
  // the custom element from the registry is expecting an upgrade callback
2856
2870
  vm = createViewModelHook(elm, vnode, renderer);
2857
2871
  });
2858
- linkNodeToShadow(elm, owner, renderer);
2859
2872
  vnode.elm = elm;
2860
2873
  vnode.vm = vm;
2874
+ linkNodeToShadow(elm, owner, renderer);
2875
+ applyStyleScoping(elm, owner, renderer);
2861
2876
  if (vm) {
2862
2877
  allocateChildren(vnode, vm);
2863
2878
  }
@@ -2938,22 +2953,6 @@
2938
2953
  function isVNode(vnode) {
2939
2954
  return vnode != null;
2940
2955
  }
2941
- function observeElementChildNodes(elm) {
2942
- elm.$domManual$ = true;
2943
- }
2944
- function setElementShadowToken(elm, token) {
2945
- elm.$shadowToken$ = token;
2946
- }
2947
- // Set the scope token class for *.scoped.css styles
2948
- function setScopeTokenClassIfNecessary(elm, owner, renderer) {
2949
- const token = getScopeTokenClass(owner);
2950
- if (!isNull(token)) {
2951
- const { getClassList } = renderer;
2952
- // TODO [#2762]: this dot notation with add is probably problematic
2953
- // probably we should have a renderer api for just the add operation
2954
- getClassList(elm).add(token);
2955
- }
2956
- }
2957
2956
  function linkNodeToShadow(elm, owner, renderer) {
2958
2957
  const { renderRoot, renderMode, shadowMode } = owner;
2959
2958
  const { isSyntheticShadowDefined } = renderer;
@@ -2988,23 +2987,26 @@
2988
2987
  patchAttributes(oldVnode, vnode, renderer);
2989
2988
  patchProps(oldVnode, vnode, renderer);
2990
2989
  }
2991
- function fallbackElmHook(elm, vnode, renderer) {
2992
- const { owner } = vnode;
2993
- setScopeTokenClassIfNecessary(elm, owner, renderer);
2994
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
2995
- const { data: { context }, } = vnode;
2996
- const { stylesheetToken } = owner.context;
2997
- if (!isUndefined$1(context) &&
2998
- !isUndefined$1(context.lwc) &&
2999
- context.lwc.dom === "manual" /* LwcDomMode.Manual */) {
3000
- // this element will now accept any manual content inserted into it
3001
- observeElementChildNodes(elm);
3002
- }
3003
- if (!isUndefined$1(stylesheetToken)) {
3004
- // when running in synthetic shadow mode, we need to set the shadowToken value
3005
- // into each element from the template, so they can be styled accordingly.
3006
- setElementShadowToken(elm, stylesheetToken);
3007
- }
2990
+ function applyStyleScoping(elm, owner, renderer) {
2991
+ // Set the class name for `*.scoped.css` style scoping.
2992
+ const scopeToken = getScopeTokenClass(owner);
2993
+ if (!isNull(scopeToken)) {
2994
+ const { getClassList } = renderer;
2995
+ // TODO [#2762]: this dot notation with add is probably problematic
2996
+ // probably we should have a renderer api for just the add operation
2997
+ getClassList(elm).add(scopeToken);
2998
+ }
2999
+ // Set property element for synthetic shadow DOM style scoping.
3000
+ const { stylesheetToken: syntheticToken } = owner.context;
3001
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
3002
+ elm.$shadowToken$ = syntheticToken;
3003
+ }
3004
+ }
3005
+ function applyDomManual(elm, vnode) {
3006
+ var _a;
3007
+ const { owner, data: { context }, } = vnode;
3008
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
3009
+ elm.$domManual$ = true;
3008
3010
  }
3009
3011
  }
3010
3012
  function allocateChildren(vnode, vm) {
@@ -3039,15 +3041,6 @@
3039
3041
  return vm;
3040
3042
  }
3041
3043
  const { sel, mode, ctor, owner } = vnode;
3042
- setScopeTokenClassIfNecessary(elm, owner, renderer);
3043
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
3044
- const { stylesheetToken } = owner.context;
3045
- // when running in synthetic shadow mode, we need to set the shadowToken value
3046
- // into each element from the template, so they can be styled accordingly.
3047
- if (!isUndefined$1(stylesheetToken)) {
3048
- setElementShadowToken(elm, stylesheetToken);
3049
- }
3050
- }
3051
3044
  vm = createVM(elm, ctor, renderer, {
3052
3045
  mode,
3053
3046
  owner,
@@ -3864,7 +3857,7 @@
3864
3857
  return signedTemplateMap.get(Ctor);
3865
3858
  }
3866
3859
  function getTemplateReactiveObserver(vm) {
3867
- return new ReactiveObserver(() => {
3860
+ return createReactiveObserver(() => {
3868
3861
  const { isDirty } = vm;
3869
3862
  if (isFalse(isDirty)) {
3870
3863
  markComponentAsDirty(vm);
@@ -4599,7 +4592,7 @@
4599
4592
  function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
4600
4593
  let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
4601
4594
 
4602
- const ro = new ReactiveObserver(() => {
4595
+ const ro = createReactiveObserver(() => {
4603
4596
  if (hasPendingConfig === false) {
4604
4597
  hasPendingConfig = true; // collect new config in the micro-task
4605
4598
 
@@ -4885,7 +4878,7 @@
4885
4878
  * being removed.
4886
4879
  */
4887
4880
  function readonly(obj) {
4888
- return reactiveMembrane.getReadOnlyProxy(obj);
4881
+ return getReadOnlyProxy(obj);
4889
4882
  }
4890
4883
 
4891
4884
  /*
@@ -5237,7 +5230,7 @@
5237
5230
  }
5238
5231
  return ctor;
5239
5232
  }
5240
- /* version: 2.20.4 */
5233
+ /* version: 2.22.0 */
5241
5234
 
5242
5235
  /*
5243
5236
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5372,6 +5365,69 @@
5372
5365
  }
5373
5366
  }
5374
5367
 
5368
+ /*
5369
+ * Copyright (c) 2018, salesforce.com, inc.
5370
+ * All rights reserved.
5371
+ * SPDX-License-Identifier: MIT
5372
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5373
+ */
5374
+ const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
5375
+ let createFragment;
5376
+ if (SUPPORTS_TEMPLATE) {
5377
+ // Parse the fragment HTML string into DOM
5378
+ createFragment = function (html) {
5379
+ const template = document.createElement('template');
5380
+ template.innerHTML = html;
5381
+ return template.content.firstChild;
5382
+ };
5383
+ }
5384
+ else {
5385
+ // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
5386
+ // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
5387
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
5388
+ // With other elements added from:
5389
+ // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
5390
+ // Using the test:
5391
+ // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
5392
+ // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
5393
+ const topLevelWrappingMap = {
5394
+ caption: ['table'],
5395
+ col: ['colgroup', 'table'],
5396
+ colgroup: ['table'],
5397
+ option: ['select'],
5398
+ tbody: ['table'],
5399
+ td: ['tr', 'tbody', 'table'],
5400
+ th: ['tr', 'tbody', 'table'],
5401
+ thead: ['table'],
5402
+ tfoot: ['table'],
5403
+ tr: ['tbody', 'table'],
5404
+ };
5405
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
5406
+ const getTagName = function (text) {
5407
+ return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
5408
+ };
5409
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
5410
+ createFragment = function (html) {
5411
+ const wrapperTags = topLevelWrappingMap[getTagName(html)];
5412
+ if (!isUndefined$1(wrapperTags)) {
5413
+ for (const wrapperTag of wrapperTags) {
5414
+ html = `<${wrapperTag}>${html}</${wrapperTag}>`;
5415
+ }
5416
+ }
5417
+ // For IE11, the document title must not be undefined, but it can be an empty string
5418
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
5419
+ const doc = document.implementation.createHTMLDocument('');
5420
+ doc.body.innerHTML = html;
5421
+ let content = doc.body;
5422
+ if (!isUndefined$1(wrapperTags)) {
5423
+ for (let i = 0; i < wrapperTags.length; i++) {
5424
+ content = content.firstChild;
5425
+ }
5426
+ }
5427
+ return content.firstChild;
5428
+ };
5429
+ }
5430
+
5375
5431
  /*
5376
5432
  * Copyright (c) 2018, salesforce.com, inc.
5377
5433
  * All rights reserved.
@@ -5450,9 +5506,6 @@
5450
5506
  function cloneNode(node, deep) {
5451
5507
  return node.cloneNode(deep);
5452
5508
  }
5453
- function createFragment(html) {
5454
- return document.createRange().createContextualFragment(html).firstChild;
5455
- }
5456
5509
  function createElement$1(tagName, namespace) {
5457
5510
  return isUndefined$1(namespace)
5458
5511
  ? document.createElement(tagName)
@@ -5902,7 +5955,7 @@
5902
5955
  });
5903
5956
  freeze(LightningElement);
5904
5957
  seal(LightningElement.prototype);
5905
- /* version: 2.20.4 */
5958
+ /* version: 2.22.0 */
5906
5959
 
5907
5960
  exports.LightningElement = LightningElement;
5908
5961
  exports.__unstable__ProfilerControl = profilerControl;