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
@@ -49,7 +49,7 @@
49
49
  */
50
50
  const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getPrototypeOf: getPrototypeOf$1, hasOwnProperty: hasOwnProperty$1, isFrozen, keys, seal, setPrototypeOf, } = Object;
51
51
  const { isArray: isArray$1 } = Array;
52
- 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;
52
+ 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;
53
53
  const { fromCharCode: StringFromCharCode } = String;
54
54
  const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
55
55
  function isUndefined$1(obj) {
@@ -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.27.0";
308
+ const LWC_VERSION = "2.28.1";
309
309
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
310
- /** version: 2.27.0 */
310
+ /** version: 2.28.1 */
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.27.0 */
392
+ /** version: 2.28.1 */
393
393
 
394
394
  /**
395
395
  * Copyright (C) 2018 salesforce.com, inc.
@@ -469,7 +469,7 @@
469
469
  setFeatureFlag(name, value);
470
470
  }
471
471
  }
472
- /** version: 2.27.0 */
472
+ /** version: 2.28.1 */
473
473
 
474
474
  /*
475
475
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3692,6 +3692,9 @@
3692
3692
  function isVCustomElement(vnode) {
3693
3693
  return vnode.type === 3 /* VNodeType.CustomElement */;
3694
3694
  }
3695
+ function isVFragment(vnode) {
3696
+ return vnode.type === 5 /* VNodeType.Fragment */;
3697
+ }
3695
3698
  function isVScopedSlotFragment(vnode) {
3696
3699
  return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
3697
3700
  }
@@ -4219,9 +4222,14 @@
4219
4222
  if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4220
4223
  disconnectRootElement(elm);
4221
4224
  }
4222
- };
4225
+ }; // Should never get a tag with upper case letter at this point; the compiler
4226
+ // should produce only tags with lowercase letters. However, the Java
4227
+ // compiler may generate tagnames with uppercase letters so - for backwards
4228
+ // compatibility, we lower case the tagname here.
4223
4229
 
4224
- const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
4230
+
4231
+ const normalizedTagname = sel.toLowerCase();
4232
+ const elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback);
4225
4233
  vnode.elm = elm;
4226
4234
  vnode.vm = vm;
4227
4235
  linkNodeToShadow(elm, owner, renderer);
@@ -4523,6 +4531,17 @@
4523
4531
  shadowMode
4524
4532
  } = vm;
4525
4533
 
4534
+ if (process.env.NODE_ENV !== 'production') {
4535
+ // If any of the children being allocated is a scoped slot fragment, make sure the receiving
4536
+ // component is a light DOM component. This is mainly to validate light dom parent running
4537
+ // in native shadow mode.
4538
+ if (renderMode !== 0
4539
+ /* RenderMode.Light */
4540
+ && ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
4541
+ logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
4542
+ }
4543
+ }
4544
+
4526
4545
  if (shadowMode === 1
4527
4546
  /* ShadowMode.Synthetic */
4528
4547
  || renderMode === 0
@@ -4564,26 +4583,26 @@
4564
4583
 
4565
4584
  return vm;
4566
4585
  }
4586
+ /**
4587
+ * Collects all slots into a SlotSet, traversing through VFragment Nodes
4588
+ */
4567
4589
 
4568
- function allocateInSlot(vm, children, owner) {
4569
- var _a, _b;
4570
4590
 
4571
- const {
4572
- cmpSlots: {
4573
- slotAssignments: oldSlotsMapping
4574
- }
4575
- } = vm;
4576
- const cmpSlotsMapping = create(null);
4577
- vm.cmpSlots = {
4578
- owner,
4579
- slotAssignments: cmpSlotsMapping
4580
- };
4591
+ function collectSlots(vm, children, cmpSlotsMapping) {
4592
+ var _a, _b;
4581
4593
 
4582
4594
  for (let i = 0, len = children.length; i < len; i += 1) {
4583
4595
  const vnode = children[i];
4584
4596
 
4585
4597
  if (isNull(vnode)) {
4586
4598
  continue;
4599
+ } // Dive further iff the content is wrapped in a VFragment
4600
+
4601
+
4602
+ if (isVFragment(vnode)) {
4603
+ // Remove the text delimiter nodes to avoid overriding default slot content
4604
+ collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
4605
+ continue;
4587
4606
  }
4588
4607
 
4589
4608
  let slotName = '';
@@ -4597,6 +4616,20 @@
4597
4616
  const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
4598
4617
  ArrayPush$1.call(vnodes, vnode);
4599
4618
  }
4619
+ }
4620
+
4621
+ function allocateInSlot(vm, children, owner) {
4622
+ const {
4623
+ cmpSlots: {
4624
+ slotAssignments: oldSlotsMapping
4625
+ }
4626
+ } = vm;
4627
+ const cmpSlotsMapping = create(null);
4628
+ collectSlots(vm, children, cmpSlotsMapping);
4629
+ vm.cmpSlots = {
4630
+ owner,
4631
+ slotAssignments: cmpSlotsMapping
4632
+ };
4600
4633
 
4601
4634
  if (isFalse(vm.isDirty)) {
4602
4635
  // We need to determine if the old allocation is really different from the new one
@@ -4917,27 +4950,42 @@
4917
4950
  !isUndefined$1(slotset.slotAssignments) &&
4918
4951
  !isUndefined$1(slotset.slotAssignments[slotName]) &&
4919
4952
  slotset.slotAssignments[slotName].length !== 0) {
4920
- children = slotset.slotAssignments[slotName].reduce((acc, vnode) => {
4921
- // If the passed slot content is factory, evaluate it and use the produced vnodes
4922
- if (vnode && isVScopedSlotFragment(vnode)) {
4923
- const vmBeingRenderedInception = getVMBeingRendered();
4924
- let children = [];
4925
- // Evaluate in the scope of the slot content's owner
4926
- // if a slotset is provided, there will always be an owner. The only case where owner is
4927
- // undefined is for root components, but root components cannot accept slotted content
4928
- setVMBeingRendered(slotset.owner);
4929
- try {
4930
- children = vnode.factory(data.slotData);
4953
+ children = slotset.slotAssignments[slotName].reduce((accumulator, vnode) => {
4954
+ if (vnode) {
4955
+ const assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
4956
+ // The only sniff test for a scoped <slot> element is the presence of `slotData`
4957
+ const isScopedSlotElement = !isUndefined$1(data.slotData);
4958
+ // Check if slot types of parent and child are matching
4959
+ if (assignedNodeIsScopedSlot !== isScopedSlotElement) {
4960
+ if (process.env.NODE_ENV !== 'production') {
4961
+ 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);
4962
+ }
4963
+ // Ignore slot content from parent
4964
+ return accumulator;
4965
+ }
4966
+ // If the passed slot content is factory, evaluate it and add the produced vnodes
4967
+ if (assignedNodeIsScopedSlot) {
4968
+ const vmBeingRenderedInception = getVMBeingRendered();
4969
+ let scopedSlotChildren = [];
4970
+ // Evaluate in the scope of the slot content's owner
4971
+ // if a slotset is provided, there will always be an owner. The only case where owner is
4972
+ // undefined is for root components, but root components cannot accept slotted content
4973
+ setVMBeingRendered(slotset.owner);
4974
+ try {
4975
+ scopedSlotChildren = vnode.factory(data.slotData);
4976
+ }
4977
+ finally {
4978
+ setVMBeingRendered(vmBeingRenderedInception);
4979
+ }
4980
+ return ArrayConcat$1.call(accumulator, scopedSlotChildren);
4931
4981
  }
4932
- finally {
4933
- setVMBeingRendered(vmBeingRenderedInception);
4982
+ else {
4983
+ // If the slot content is standard type, the content is static, no additional
4984
+ // processing needed on the vnode
4985
+ return ArrayConcat$1.call(accumulator, vnode);
4934
4986
  }
4935
- return ArrayConcat$1.call(acc, children);
4936
- }
4937
- else {
4938
- // If the slot content is a static list of child nodes provided by the parent, nothing to do
4939
- return ArrayConcat$1.call(acc, vnode);
4940
4987
  }
4988
+ return accumulator;
4941
4989
  }, []);
4942
4990
  }
4943
4991
  const vmBeingRendered = getVMBeingRendered();
@@ -7067,11 +7115,12 @@
7067
7115
  }
7068
7116
  }
7069
7117
  let nodesAreCompatible = true;
7070
- let vnodeClassName;
7071
- if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
7118
+ let readableVnodeClassname;
7119
+ const elmClassName = getProperty(elm, 'className');
7120
+ if (!isUndefined$1(className) && String(className) !== elmClassName) {
7072
7121
  // className is used when class is bound to an expr.
7073
7122
  nodesAreCompatible = false;
7074
- vnodeClassName = className;
7123
+ readableVnodeClassname = className;
7075
7124
  }
7076
7125
  else if (!isUndefined$1(classMap)) {
7077
7126
  // classMap is used when class is set to static value.
@@ -7084,14 +7133,19 @@
7084
7133
  nodesAreCompatible = false;
7085
7134
  }
7086
7135
  }
7087
- vnodeClassName = computedClassName.trim();
7136
+ readableVnodeClassname = computedClassName.trim();
7088
7137
  if (classList.length > keys(classMap).length) {
7089
7138
  nodesAreCompatible = false;
7090
7139
  }
7091
7140
  }
7141
+ else if (isUndefined$1(className) && elmClassName !== '') {
7142
+ // SSR contains a className but client-side VDOM does not
7143
+ nodesAreCompatible = false;
7144
+ readableVnodeClassname = '';
7145
+ }
7092
7146
  if (!nodesAreCompatible) {
7093
7147
  if (process.env.NODE_ENV !== 'production') {
7094
- logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
7148
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${readableVnodeClassname}" but found "${elmClassName}"`, vnode.owner);
7095
7149
  }
7096
7150
  }
7097
7151
  return nodesAreCompatible;
@@ -7305,7 +7359,7 @@
7305
7359
  }
7306
7360
  return ctor;
7307
7361
  }
7308
- /* version: 2.27.0 */
7362
+ /* version: 2.28.1 */
7309
7363
 
7310
7364
  /*
7311
7365
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7579,10 +7633,12 @@
7579
7633
  const pendingRegistryForElement = new WeakMap();
7580
7634
  const definitionForConstructor = new WeakMap();
7581
7635
  const registeredUserCtors = new WeakSet();
7636
+ const registeredPivotCtors = new WeakSet();
7582
7637
  const pivotCtorByTag = new Map();
7583
7638
  const globalDefinitionsByTag = new Map();
7584
7639
  const globalDefinitionsByClass = new Map();
7585
7640
  const awaitingUpgrade = new Map();
7641
+ const pendingWhenDefinedCallbacks = new Map();
7586
7642
  const EMPTY_SET = new Set();
7587
7643
  function createDefinitionRecord(constructor) {
7588
7644
  var _a;
@@ -7688,6 +7744,7 @@
7688
7744
  }
7689
7745
  }
7690
7746
  PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
7747
+ registeredPivotCtors.add(PivotCtor);
7691
7748
  return PivotCtor;
7692
7749
  }
7693
7750
  function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
@@ -7821,6 +7878,27 @@
7821
7878
  }
7822
7879
  return createDefinitionRecord(constructor);
7823
7880
  }
7881
+ // Defer a `whenDefined()` callback until an externally-visible custom element is defined
7882
+ function createPendingWhenDefinedCallback(tagName) {
7883
+ return new Promise((resolve) => {
7884
+ let resolvers = pendingWhenDefinedCallbacks.get(tagName);
7885
+ if (isUndefined$1(resolvers)) {
7886
+ resolvers = [];
7887
+ pendingWhenDefinedCallbacks.set(tagName, resolvers);
7888
+ }
7889
+ resolvers.push(resolve);
7890
+ });
7891
+ }
7892
+ // Call any pending `whenDefined()` callbacks
7893
+ function flushPendingWhenDefinedCallbacks(tagName, ctor) {
7894
+ const resolvers = pendingWhenDefinedCallbacks.get(tagName);
7895
+ if (!isUndefined$1(resolvers)) {
7896
+ for (const resolver of resolvers) {
7897
+ resolver(ctor);
7898
+ }
7899
+ }
7900
+ pendingWhenDefinedCallbacks.delete(tagName);
7901
+ }
7824
7902
  const { customElements: nativeRegistry } = window;
7825
7903
  const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
7826
7904
  // patch for the global registry define mechanism
@@ -7875,6 +7953,8 @@
7875
7953
  }
7876
7954
  }
7877
7955
  }
7956
+ // If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
7957
+ flushPendingWhenDefinedCallbacks(tagName, constructor);
7878
7958
  };
7879
7959
  CustomElementRegistry.prototype.get = function get(tagName) {
7880
7960
  const NativeCtor = nativeGet.call(nativeRegistry, tagName);
@@ -7883,8 +7963,10 @@
7883
7963
  if (!isUndefined$1(definition)) {
7884
7964
  return definition.UserCtor; // defined by the patched custom elements registry
7885
7965
  }
7886
- // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7887
- return NativeCtor; // return the pivot constructor or constructor that existed before patching
7966
+ if (registeredPivotCtors.has(NativeCtor)) {
7967
+ return undefined; // pivot constructors should not be observable, return undefined
7968
+ }
7969
+ return NativeCtor; // constructor that existed before patching
7888
7970
  }
7889
7971
  };
7890
7972
  CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
@@ -7893,13 +7975,17 @@
7893
7975
  if (!isUndefined$1(definition)) {
7894
7976
  return definition.UserCtor;
7895
7977
  }
7896
- // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7897
7978
  // In this case, the custom element must have been defined before the registry patches
7898
7979
  // were applied. So return the non-pivot constructor
7899
7980
  if (isUndefined$1(NativeCtor)) {
7900
7981
  // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
7901
7982
  // We can patch the correct behavior using customElements.get()
7902
- return nativeGet.call(nativeRegistry, tagName);
7983
+ NativeCtor = nativeGet.call(nativeRegistry, tagName);
7984
+ }
7985
+ if (registeredPivotCtors.has(NativeCtor)) {
7986
+ // Pivot constructors should not be observable. Wait to resolve the promise
7987
+ // if a constructor is ever defined in userland
7988
+ return createPendingWhenDefinedCallback(tagName);
7903
7989
  }
7904
7990
  return NativeCtor;
7905
7991
  });
@@ -8129,7 +8215,7 @@
8129
8215
  function isNull(obj) {
8130
8216
  return obj === null;
8131
8217
  }
8132
- /** version: 2.27.0 */
8218
+ /** version: 2.28.1 */
8133
8219
 
8134
8220
  /*
8135
8221
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8708,7 +8794,7 @@
8708
8794
  });
8709
8795
  freeze(LightningElement);
8710
8796
  seal(LightningElement.prototype);
8711
- /* version: 2.27.0 */
8797
+ /* version: 2.28.1 */
8712
8798
 
8713
8799
  exports.LightningElement = LightningElement;
8714
8800
  exports.__unstable__ProfilerControl = profilerControl;