lwc 2.27.0 → 2.28.1

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 (37) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +135 -49
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +135 -49
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +114 -43
  5. package/dist/engine-dom/iife/es5/engine-dom.js +176 -63
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +152 -57
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +135 -49
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +114 -43
  11. package/dist/engine-dom/umd/es5/engine-dom.js +176 -63
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +152 -57
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +93 -39
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +93 -39
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +4 -4
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +4 -4
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +4 -4
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +4 -4
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +4 -4
  26. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  28. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  29. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  31. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  37. package/package.json +7 -7
@@ -46,7 +46,7 @@ var LWC = (function (exports) {
46
46
  */
47
47
  const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getPrototypeOf: getPrototypeOf$1, hasOwnProperty: hasOwnProperty$1, isFrozen, keys, seal, setPrototypeOf, } = Object;
48
48
  const { isArray: isArray$1 } = Array;
49
- const { concat: ArrayConcat$1, copyWithin: ArrayCopyWithin, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
49
+ const { concat: ArrayConcat$1, copyWithin: ArrayCopyWithin, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
50
50
  const { fromCharCode: StringFromCharCode } = String;
51
51
  const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
52
52
  function isUndefined$1(obj) {
@@ -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.27.0";
305
+ const LWC_VERSION = "2.28.1";
306
306
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
307
- /** version: 2.27.0 */
307
+ /** version: 2.28.1 */
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.27.0 */
389
+ /** version: 2.28.1 */
390
390
 
391
391
  /**
392
392
  * Copyright (C) 2018 salesforce.com, inc.
@@ -466,7 +466,7 @@ var LWC = (function (exports) {
466
466
  setFeatureFlag(name, value);
467
467
  }
468
468
  }
469
- /** version: 2.27.0 */
469
+ /** version: 2.28.1 */
470
470
 
471
471
  /*
472
472
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3689,6 +3689,9 @@ var LWC = (function (exports) {
3689
3689
  function isVCustomElement(vnode) {
3690
3690
  return vnode.type === 3 /* VNodeType.CustomElement */;
3691
3691
  }
3692
+ function isVFragment(vnode) {
3693
+ return vnode.type === 5 /* VNodeType.Fragment */;
3694
+ }
3692
3695
  function isVScopedSlotFragment(vnode) {
3693
3696
  return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
3694
3697
  }
@@ -4216,9 +4219,14 @@ var LWC = (function (exports) {
4216
4219
  if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4217
4220
  disconnectRootElement(elm);
4218
4221
  }
4219
- };
4222
+ }; // Should never get a tag with upper case letter at this point; the compiler
4223
+ // should produce only tags with lowercase letters. However, the Java
4224
+ // compiler may generate tagnames with uppercase letters so - for backwards
4225
+ // compatibility, we lower case the tagname here.
4220
4226
 
4221
- const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
4227
+
4228
+ const normalizedTagname = sel.toLowerCase();
4229
+ const elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback);
4222
4230
  vnode.elm = elm;
4223
4231
  vnode.vm = vm;
4224
4232
  linkNodeToShadow(elm, owner, renderer);
@@ -4520,6 +4528,17 @@ var LWC = (function (exports) {
4520
4528
  shadowMode
4521
4529
  } = vm;
4522
4530
 
4531
+ if (process.env.NODE_ENV !== 'production') {
4532
+ // If any of the children being allocated is a scoped slot fragment, make sure the receiving
4533
+ // component is a light DOM component. This is mainly to validate light dom parent running
4534
+ // in native shadow mode.
4535
+ if (renderMode !== 0
4536
+ /* RenderMode.Light */
4537
+ && ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
4538
+ logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
4539
+ }
4540
+ }
4541
+
4523
4542
  if (shadowMode === 1
4524
4543
  /* ShadowMode.Synthetic */
4525
4544
  || renderMode === 0
@@ -4561,26 +4580,26 @@ var LWC = (function (exports) {
4561
4580
 
4562
4581
  return vm;
4563
4582
  }
4583
+ /**
4584
+ * Collects all slots into a SlotSet, traversing through VFragment Nodes
4585
+ */
4564
4586
 
4565
- function allocateInSlot(vm, children, owner) {
4566
- var _a, _b;
4567
4587
 
4568
- const {
4569
- cmpSlots: {
4570
- slotAssignments: oldSlotsMapping
4571
- }
4572
- } = vm;
4573
- const cmpSlotsMapping = create(null);
4574
- vm.cmpSlots = {
4575
- owner,
4576
- slotAssignments: cmpSlotsMapping
4577
- };
4588
+ function collectSlots(vm, children, cmpSlotsMapping) {
4589
+ var _a, _b;
4578
4590
 
4579
4591
  for (let i = 0, len = children.length; i < len; i += 1) {
4580
4592
  const vnode = children[i];
4581
4593
 
4582
4594
  if (isNull(vnode)) {
4583
4595
  continue;
4596
+ } // Dive further iff the content is wrapped in a VFragment
4597
+
4598
+
4599
+ if (isVFragment(vnode)) {
4600
+ // Remove the text delimiter nodes to avoid overriding default slot content
4601
+ collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
4602
+ continue;
4584
4603
  }
4585
4604
 
4586
4605
  let slotName = '';
@@ -4594,6 +4613,20 @@ var LWC = (function (exports) {
4594
4613
  const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
4595
4614
  ArrayPush$1.call(vnodes, vnode);
4596
4615
  }
4616
+ }
4617
+
4618
+ function allocateInSlot(vm, children, owner) {
4619
+ const {
4620
+ cmpSlots: {
4621
+ slotAssignments: oldSlotsMapping
4622
+ }
4623
+ } = vm;
4624
+ const cmpSlotsMapping = create(null);
4625
+ collectSlots(vm, children, cmpSlotsMapping);
4626
+ vm.cmpSlots = {
4627
+ owner,
4628
+ slotAssignments: cmpSlotsMapping
4629
+ };
4597
4630
 
4598
4631
  if (isFalse(vm.isDirty)) {
4599
4632
  // We need to determine if the old allocation is really different from the new one
@@ -4914,27 +4947,42 @@ var LWC = (function (exports) {
4914
4947
  !isUndefined$1(slotset.slotAssignments) &&
4915
4948
  !isUndefined$1(slotset.slotAssignments[slotName]) &&
4916
4949
  slotset.slotAssignments[slotName].length !== 0) {
4917
- children = slotset.slotAssignments[slotName].reduce((acc, vnode) => {
4918
- // If the passed slot content is factory, evaluate it and use the produced vnodes
4919
- if (vnode && isVScopedSlotFragment(vnode)) {
4920
- const vmBeingRenderedInception = getVMBeingRendered();
4921
- let children = [];
4922
- // Evaluate in the scope of the slot content's owner
4923
- // if a slotset is provided, there will always be an owner. The only case where owner is
4924
- // undefined is for root components, but root components cannot accept slotted content
4925
- setVMBeingRendered(slotset.owner);
4926
- try {
4927
- children = vnode.factory(data.slotData);
4950
+ children = slotset.slotAssignments[slotName].reduce((accumulator, vnode) => {
4951
+ if (vnode) {
4952
+ const assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
4953
+ // The only sniff test for a scoped <slot> element is the presence of `slotData`
4954
+ const isScopedSlotElement = !isUndefined$1(data.slotData);
4955
+ // Check if slot types of parent and child are matching
4956
+ if (assignedNodeIsScopedSlot !== isScopedSlotElement) {
4957
+ if (process.env.NODE_ENV !== 'production') {
4958
+ logError(`Mismatched slot types for ${slotName === '' ? '(default)' : slotName} slot. Both parent and child component must use standard type or scoped type for a given slot.`, slotset.owner);
4959
+ }
4960
+ // Ignore slot content from parent
4961
+ return accumulator;
4962
+ }
4963
+ // If the passed slot content is factory, evaluate it and add the produced vnodes
4964
+ if (assignedNodeIsScopedSlot) {
4965
+ const vmBeingRenderedInception = getVMBeingRendered();
4966
+ let scopedSlotChildren = [];
4967
+ // Evaluate in the scope of the slot content's owner
4968
+ // if a slotset is provided, there will always be an owner. The only case where owner is
4969
+ // undefined is for root components, but root components cannot accept slotted content
4970
+ setVMBeingRendered(slotset.owner);
4971
+ try {
4972
+ scopedSlotChildren = vnode.factory(data.slotData);
4973
+ }
4974
+ finally {
4975
+ setVMBeingRendered(vmBeingRenderedInception);
4976
+ }
4977
+ return ArrayConcat$1.call(accumulator, scopedSlotChildren);
4928
4978
  }
4929
- finally {
4930
- setVMBeingRendered(vmBeingRenderedInception);
4979
+ else {
4980
+ // If the slot content is standard type, the content is static, no additional
4981
+ // processing needed on the vnode
4982
+ return ArrayConcat$1.call(accumulator, vnode);
4931
4983
  }
4932
- return ArrayConcat$1.call(acc, children);
4933
- }
4934
- else {
4935
- // If the slot content is a static list of child nodes provided by the parent, nothing to do
4936
- return ArrayConcat$1.call(acc, vnode);
4937
4984
  }
4985
+ return accumulator;
4938
4986
  }, []);
4939
4987
  }
4940
4988
  const vmBeingRendered = getVMBeingRendered();
@@ -7064,11 +7112,12 @@ var LWC = (function (exports) {
7064
7112
  }
7065
7113
  }
7066
7114
  let nodesAreCompatible = true;
7067
- let vnodeClassName;
7068
- if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
7115
+ let readableVnodeClassname;
7116
+ const elmClassName = getProperty(elm, 'className');
7117
+ if (!isUndefined$1(className) && String(className) !== elmClassName) {
7069
7118
  // className is used when class is bound to an expr.
7070
7119
  nodesAreCompatible = false;
7071
- vnodeClassName = className;
7120
+ readableVnodeClassname = className;
7072
7121
  }
7073
7122
  else if (!isUndefined$1(classMap)) {
7074
7123
  // classMap is used when class is set to static value.
@@ -7081,14 +7130,19 @@ var LWC = (function (exports) {
7081
7130
  nodesAreCompatible = false;
7082
7131
  }
7083
7132
  }
7084
- vnodeClassName = computedClassName.trim();
7133
+ readableVnodeClassname = computedClassName.trim();
7085
7134
  if (classList.length > keys(classMap).length) {
7086
7135
  nodesAreCompatible = false;
7087
7136
  }
7088
7137
  }
7138
+ else if (isUndefined$1(className) && elmClassName !== '') {
7139
+ // SSR contains a className but client-side VDOM does not
7140
+ nodesAreCompatible = false;
7141
+ readableVnodeClassname = '';
7142
+ }
7089
7143
  if (!nodesAreCompatible) {
7090
7144
  if (process.env.NODE_ENV !== 'production') {
7091
- logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
7145
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${readableVnodeClassname}" but found "${elmClassName}"`, vnode.owner);
7092
7146
  }
7093
7147
  }
7094
7148
  return nodesAreCompatible;
@@ -7302,7 +7356,7 @@ var LWC = (function (exports) {
7302
7356
  }
7303
7357
  return ctor;
7304
7358
  }
7305
- /* version: 2.27.0 */
7359
+ /* version: 2.28.1 */
7306
7360
 
7307
7361
  /*
7308
7362
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7576,10 +7630,12 @@ var LWC = (function (exports) {
7576
7630
  const pendingRegistryForElement = new WeakMap();
7577
7631
  const definitionForConstructor = new WeakMap();
7578
7632
  const registeredUserCtors = new WeakSet();
7633
+ const registeredPivotCtors = new WeakSet();
7579
7634
  const pivotCtorByTag = new Map();
7580
7635
  const globalDefinitionsByTag = new Map();
7581
7636
  const globalDefinitionsByClass = new Map();
7582
7637
  const awaitingUpgrade = new Map();
7638
+ const pendingWhenDefinedCallbacks = new Map();
7583
7639
  const EMPTY_SET = new Set();
7584
7640
  function createDefinitionRecord(constructor) {
7585
7641
  var _a;
@@ -7685,6 +7741,7 @@ var LWC = (function (exports) {
7685
7741
  }
7686
7742
  }
7687
7743
  PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
7744
+ registeredPivotCtors.add(PivotCtor);
7688
7745
  return PivotCtor;
7689
7746
  }
7690
7747
  function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
@@ -7818,6 +7875,27 @@ var LWC = (function (exports) {
7818
7875
  }
7819
7876
  return createDefinitionRecord(constructor);
7820
7877
  }
7878
+ // Defer a `whenDefined()` callback until an externally-visible custom element is defined
7879
+ function createPendingWhenDefinedCallback(tagName) {
7880
+ return new Promise((resolve) => {
7881
+ let resolvers = pendingWhenDefinedCallbacks.get(tagName);
7882
+ if (isUndefined$1(resolvers)) {
7883
+ resolvers = [];
7884
+ pendingWhenDefinedCallbacks.set(tagName, resolvers);
7885
+ }
7886
+ resolvers.push(resolve);
7887
+ });
7888
+ }
7889
+ // Call any pending `whenDefined()` callbacks
7890
+ function flushPendingWhenDefinedCallbacks(tagName, ctor) {
7891
+ const resolvers = pendingWhenDefinedCallbacks.get(tagName);
7892
+ if (!isUndefined$1(resolvers)) {
7893
+ for (const resolver of resolvers) {
7894
+ resolver(ctor);
7895
+ }
7896
+ }
7897
+ pendingWhenDefinedCallbacks.delete(tagName);
7898
+ }
7821
7899
  const { customElements: nativeRegistry } = window;
7822
7900
  const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
7823
7901
  // patch for the global registry define mechanism
@@ -7872,6 +7950,8 @@ var LWC = (function (exports) {
7872
7950
  }
7873
7951
  }
7874
7952
  }
7953
+ // If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
7954
+ flushPendingWhenDefinedCallbacks(tagName, constructor);
7875
7955
  };
7876
7956
  CustomElementRegistry.prototype.get = function get(tagName) {
7877
7957
  const NativeCtor = nativeGet.call(nativeRegistry, tagName);
@@ -7880,8 +7960,10 @@ var LWC = (function (exports) {
7880
7960
  if (!isUndefined$1(definition)) {
7881
7961
  return definition.UserCtor; // defined by the patched custom elements registry
7882
7962
  }
7883
- // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7884
- return NativeCtor; // return the pivot constructor or constructor that existed before patching
7963
+ if (registeredPivotCtors.has(NativeCtor)) {
7964
+ return undefined; // pivot constructors should not be observable, return undefined
7965
+ }
7966
+ return NativeCtor; // constructor that existed before patching
7885
7967
  }
7886
7968
  };
7887
7969
  CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
@@ -7890,13 +7972,17 @@ var LWC = (function (exports) {
7890
7972
  if (!isUndefined$1(definition)) {
7891
7973
  return definition.UserCtor;
7892
7974
  }
7893
- // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7894
7975
  // In this case, the custom element must have been defined before the registry patches
7895
7976
  // were applied. So return the non-pivot constructor
7896
7977
  if (isUndefined$1(NativeCtor)) {
7897
7978
  // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
7898
7979
  // We can patch the correct behavior using customElements.get()
7899
- return nativeGet.call(nativeRegistry, tagName);
7980
+ NativeCtor = nativeGet.call(nativeRegistry, tagName);
7981
+ }
7982
+ if (registeredPivotCtors.has(NativeCtor)) {
7983
+ // Pivot constructors should not be observable. Wait to resolve the promise
7984
+ // if a constructor is ever defined in userland
7985
+ return createPendingWhenDefinedCallback(tagName);
7900
7986
  }
7901
7987
  return NativeCtor;
7902
7988
  });
@@ -8126,7 +8212,7 @@ var LWC = (function (exports) {
8126
8212
  function isNull(obj) {
8127
8213
  return obj === null;
8128
8214
  }
8129
- /** version: 2.27.0 */
8215
+ /** version: 2.28.1 */
8130
8216
 
8131
8217
  /*
8132
8218
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8705,7 +8791,7 @@ var LWC = (function (exports) {
8705
8791
  });
8706
8792
  freeze(LightningElement);
8707
8793
  seal(LightningElement.prototype);
8708
- /* version: 2.27.0 */
8794
+ /* version: 2.28.1 */
8709
8795
 
8710
8796
  exports.LightningElement = LightningElement;
8711
8797
  exports.__unstable__ProfilerControl = profilerControl;