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
@@ -43,7 +43,7 @@ var assert = /*#__PURE__*/Object.freeze({
43
43
  */
44
44
  const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getPrototypeOf: getPrototypeOf$1, hasOwnProperty: hasOwnProperty$1, isFrozen, keys, seal, setPrototypeOf, } = Object;
45
45
  const { isArray: isArray$1 } = Array;
46
- 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;
46
+ 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;
47
47
  const { fromCharCode: StringFromCharCode } = String;
48
48
  const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
49
49
  function isUndefined$1(obj) {
@@ -299,9 +299,9 @@ function htmlPropertyToAttribute(propName) {
299
299
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
300
300
  */
301
301
  // Increment whenever the LWC template compiler changes
302
- const LWC_VERSION = "2.27.0";
302
+ const LWC_VERSION = "2.28.1";
303
303
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
304
- /** version: 2.27.0 */
304
+ /** version: 2.28.1 */
305
305
 
306
306
  /**
307
307
  * Copyright (C) 2018 salesforce.com, inc.
@@ -383,7 +383,7 @@ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1)
383
383
  patch$1(propName);
384
384
  }
385
385
  }
386
- /** version: 2.27.0 */
386
+ /** version: 2.28.1 */
387
387
 
388
388
  /**
389
389
  * Copyright (C) 2018 salesforce.com, inc.
@@ -463,7 +463,7 @@ function setFeatureFlagForTest(name, value) {
463
463
  setFeatureFlag(name, value);
464
464
  }
465
465
  }
466
- /** version: 2.27.0 */
466
+ /** version: 2.28.1 */
467
467
 
468
468
  /*
469
469
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3686,6 +3686,9 @@ function isSameVnode(vnode1, vnode2) {
3686
3686
  function isVCustomElement(vnode) {
3687
3687
  return vnode.type === 3 /* VNodeType.CustomElement */;
3688
3688
  }
3689
+ function isVFragment(vnode) {
3690
+ return vnode.type === 5 /* VNodeType.Fragment */;
3691
+ }
3689
3692
  function isVScopedSlotFragment(vnode) {
3690
3693
  return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
3691
3694
  }
@@ -4213,9 +4216,14 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
4213
4216
  if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4214
4217
  disconnectRootElement(elm);
4215
4218
  }
4216
- };
4219
+ }; // Should never get a tag with upper case letter at this point; the compiler
4220
+ // should produce only tags with lowercase letters. However, the Java
4221
+ // compiler may generate tagnames with uppercase letters so - for backwards
4222
+ // compatibility, we lower case the tagname here.
4217
4223
 
4218
- const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
4224
+
4225
+ const normalizedTagname = sel.toLowerCase();
4226
+ const elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback);
4219
4227
  vnode.elm = elm;
4220
4228
  vnode.vm = vm;
4221
4229
  linkNodeToShadow(elm, owner, renderer);
@@ -4517,6 +4525,17 @@ function allocateChildren(vnode, vm) {
4517
4525
  shadowMode
4518
4526
  } = vm;
4519
4527
 
4528
+ if (process.env.NODE_ENV !== 'production') {
4529
+ // If any of the children being allocated is a scoped slot fragment, make sure the receiving
4530
+ // component is a light DOM component. This is mainly to validate light dom parent running
4531
+ // in native shadow mode.
4532
+ if (renderMode !== 0
4533
+ /* RenderMode.Light */
4534
+ && ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
4535
+ logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
4536
+ }
4537
+ }
4538
+
4520
4539
  if (shadowMode === 1
4521
4540
  /* ShadowMode.Synthetic */
4522
4541
  || renderMode === 0
@@ -4558,26 +4577,26 @@ function createViewModelHook(elm, vnode, renderer) {
4558
4577
 
4559
4578
  return vm;
4560
4579
  }
4580
+ /**
4581
+ * Collects all slots into a SlotSet, traversing through VFragment Nodes
4582
+ */
4561
4583
 
4562
- function allocateInSlot(vm, children, owner) {
4563
- var _a, _b;
4564
4584
 
4565
- const {
4566
- cmpSlots: {
4567
- slotAssignments: oldSlotsMapping
4568
- }
4569
- } = vm;
4570
- const cmpSlotsMapping = create(null);
4571
- vm.cmpSlots = {
4572
- owner,
4573
- slotAssignments: cmpSlotsMapping
4574
- };
4585
+ function collectSlots(vm, children, cmpSlotsMapping) {
4586
+ var _a, _b;
4575
4587
 
4576
4588
  for (let i = 0, len = children.length; i < len; i += 1) {
4577
4589
  const vnode = children[i];
4578
4590
 
4579
4591
  if (isNull(vnode)) {
4580
4592
  continue;
4593
+ } // Dive further iff the content is wrapped in a VFragment
4594
+
4595
+
4596
+ if (isVFragment(vnode)) {
4597
+ // Remove the text delimiter nodes to avoid overriding default slot content
4598
+ collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
4599
+ continue;
4581
4600
  }
4582
4601
 
4583
4602
  let slotName = '';
@@ -4591,6 +4610,20 @@ function allocateInSlot(vm, children, owner) {
4591
4610
  const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
4592
4611
  ArrayPush$1.call(vnodes, vnode);
4593
4612
  }
4613
+ }
4614
+
4615
+ function allocateInSlot(vm, children, owner) {
4616
+ const {
4617
+ cmpSlots: {
4618
+ slotAssignments: oldSlotsMapping
4619
+ }
4620
+ } = vm;
4621
+ const cmpSlotsMapping = create(null);
4622
+ collectSlots(vm, children, cmpSlotsMapping);
4623
+ vm.cmpSlots = {
4624
+ owner,
4625
+ slotAssignments: cmpSlotsMapping
4626
+ };
4594
4627
 
4595
4628
  if (isFalse(vm.isDirty)) {
4596
4629
  // We need to determine if the old allocation is really different from the new one
@@ -4911,27 +4944,42 @@ function s(slotName, data, children, slotset) {
4911
4944
  !isUndefined$1(slotset.slotAssignments) &&
4912
4945
  !isUndefined$1(slotset.slotAssignments[slotName]) &&
4913
4946
  slotset.slotAssignments[slotName].length !== 0) {
4914
- children = slotset.slotAssignments[slotName].reduce((acc, vnode) => {
4915
- // If the passed slot content is factory, evaluate it and use the produced vnodes
4916
- if (vnode && isVScopedSlotFragment(vnode)) {
4917
- const vmBeingRenderedInception = getVMBeingRendered();
4918
- let children = [];
4919
- // Evaluate in the scope of the slot content's owner
4920
- // if a slotset is provided, there will always be an owner. The only case where owner is
4921
- // undefined is for root components, but root components cannot accept slotted content
4922
- setVMBeingRendered(slotset.owner);
4923
- try {
4924
- children = vnode.factory(data.slotData);
4947
+ children = slotset.slotAssignments[slotName].reduce((accumulator, vnode) => {
4948
+ if (vnode) {
4949
+ const assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
4950
+ // The only sniff test for a scoped <slot> element is the presence of `slotData`
4951
+ const isScopedSlotElement = !isUndefined$1(data.slotData);
4952
+ // Check if slot types of parent and child are matching
4953
+ if (assignedNodeIsScopedSlot !== isScopedSlotElement) {
4954
+ if (process.env.NODE_ENV !== 'production') {
4955
+ 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);
4956
+ }
4957
+ // Ignore slot content from parent
4958
+ return accumulator;
4959
+ }
4960
+ // If the passed slot content is factory, evaluate it and add the produced vnodes
4961
+ if (assignedNodeIsScopedSlot) {
4962
+ const vmBeingRenderedInception = getVMBeingRendered();
4963
+ let scopedSlotChildren = [];
4964
+ // Evaluate in the scope of the slot content's owner
4965
+ // if a slotset is provided, there will always be an owner. The only case where owner is
4966
+ // undefined is for root components, but root components cannot accept slotted content
4967
+ setVMBeingRendered(slotset.owner);
4968
+ try {
4969
+ scopedSlotChildren = vnode.factory(data.slotData);
4970
+ }
4971
+ finally {
4972
+ setVMBeingRendered(vmBeingRenderedInception);
4973
+ }
4974
+ return ArrayConcat$1.call(accumulator, scopedSlotChildren);
4925
4975
  }
4926
- finally {
4927
- setVMBeingRendered(vmBeingRenderedInception);
4976
+ else {
4977
+ // If the slot content is standard type, the content is static, no additional
4978
+ // processing needed on the vnode
4979
+ return ArrayConcat$1.call(accumulator, vnode);
4928
4980
  }
4929
- return ArrayConcat$1.call(acc, children);
4930
- }
4931
- else {
4932
- // If the slot content is a static list of child nodes provided by the parent, nothing to do
4933
- return ArrayConcat$1.call(acc, vnode);
4934
4981
  }
4982
+ return accumulator;
4935
4983
  }, []);
4936
4984
  }
4937
4985
  const vmBeingRendered = getVMBeingRendered();
@@ -7061,11 +7109,12 @@ function validateClassAttr(vnode, elm, renderer) {
7061
7109
  }
7062
7110
  }
7063
7111
  let nodesAreCompatible = true;
7064
- let vnodeClassName;
7065
- if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
7112
+ let readableVnodeClassname;
7113
+ const elmClassName = getProperty(elm, 'className');
7114
+ if (!isUndefined$1(className) && String(className) !== elmClassName) {
7066
7115
  // className is used when class is bound to an expr.
7067
7116
  nodesAreCompatible = false;
7068
- vnodeClassName = className;
7117
+ readableVnodeClassname = className;
7069
7118
  }
7070
7119
  else if (!isUndefined$1(classMap)) {
7071
7120
  // classMap is used when class is set to static value.
@@ -7078,14 +7127,19 @@ function validateClassAttr(vnode, elm, renderer) {
7078
7127
  nodesAreCompatible = false;
7079
7128
  }
7080
7129
  }
7081
- vnodeClassName = computedClassName.trim();
7130
+ readableVnodeClassname = computedClassName.trim();
7082
7131
  if (classList.length > keys(classMap).length) {
7083
7132
  nodesAreCompatible = false;
7084
7133
  }
7085
7134
  }
7135
+ else if (isUndefined$1(className) && elmClassName !== '') {
7136
+ // SSR contains a className but client-side VDOM does not
7137
+ nodesAreCompatible = false;
7138
+ readableVnodeClassname = '';
7139
+ }
7086
7140
  if (!nodesAreCompatible) {
7087
7141
  if (process.env.NODE_ENV !== 'production') {
7088
- logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
7142
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${readableVnodeClassname}" but found "${elmClassName}"`, vnode.owner);
7089
7143
  }
7090
7144
  }
7091
7145
  return nodesAreCompatible;
@@ -7299,7 +7353,7 @@ function getComponentConstructor(elm) {
7299
7353
  }
7300
7354
  return ctor;
7301
7355
  }
7302
- /* version: 2.27.0 */
7356
+ /* version: 2.28.1 */
7303
7357
 
7304
7358
  /*
7305
7359
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7573,10 +7627,12 @@ function createScopedRegistry() {
7573
7627
  const pendingRegistryForElement = new WeakMap();
7574
7628
  const definitionForConstructor = new WeakMap();
7575
7629
  const registeredUserCtors = new WeakSet();
7630
+ const registeredPivotCtors = new WeakSet();
7576
7631
  const pivotCtorByTag = new Map();
7577
7632
  const globalDefinitionsByTag = new Map();
7578
7633
  const globalDefinitionsByClass = new Map();
7579
7634
  const awaitingUpgrade = new Map();
7635
+ const pendingWhenDefinedCallbacks = new Map();
7580
7636
  const EMPTY_SET = new Set();
7581
7637
  function createDefinitionRecord(constructor) {
7582
7638
  var _a;
@@ -7682,6 +7738,7 @@ function createScopedRegistry() {
7682
7738
  }
7683
7739
  }
7684
7740
  PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
7741
+ registeredPivotCtors.add(PivotCtor);
7685
7742
  return PivotCtor;
7686
7743
  }
7687
7744
  function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
@@ -7815,6 +7872,27 @@ function createScopedRegistry() {
7815
7872
  }
7816
7873
  return createDefinitionRecord(constructor);
7817
7874
  }
7875
+ // Defer a `whenDefined()` callback until an externally-visible custom element is defined
7876
+ function createPendingWhenDefinedCallback(tagName) {
7877
+ return new Promise((resolve) => {
7878
+ let resolvers = pendingWhenDefinedCallbacks.get(tagName);
7879
+ if (isUndefined$1(resolvers)) {
7880
+ resolvers = [];
7881
+ pendingWhenDefinedCallbacks.set(tagName, resolvers);
7882
+ }
7883
+ resolvers.push(resolve);
7884
+ });
7885
+ }
7886
+ // Call any pending `whenDefined()` callbacks
7887
+ function flushPendingWhenDefinedCallbacks(tagName, ctor) {
7888
+ const resolvers = pendingWhenDefinedCallbacks.get(tagName);
7889
+ if (!isUndefined$1(resolvers)) {
7890
+ for (const resolver of resolvers) {
7891
+ resolver(ctor);
7892
+ }
7893
+ }
7894
+ pendingWhenDefinedCallbacks.delete(tagName);
7895
+ }
7818
7896
  const { customElements: nativeRegistry } = window;
7819
7897
  const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
7820
7898
  // patch for the global registry define mechanism
@@ -7869,6 +7947,8 @@ function createScopedRegistry() {
7869
7947
  }
7870
7948
  }
7871
7949
  }
7950
+ // If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
7951
+ flushPendingWhenDefinedCallbacks(tagName, constructor);
7872
7952
  };
7873
7953
  CustomElementRegistry.prototype.get = function get(tagName) {
7874
7954
  const NativeCtor = nativeGet.call(nativeRegistry, tagName);
@@ -7877,8 +7957,10 @@ function createScopedRegistry() {
7877
7957
  if (!isUndefined$1(definition)) {
7878
7958
  return definition.UserCtor; // defined by the patched custom elements registry
7879
7959
  }
7880
- // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7881
- return NativeCtor; // return the pivot constructor or constructor that existed before patching
7960
+ if (registeredPivotCtors.has(NativeCtor)) {
7961
+ return undefined; // pivot constructors should not be observable, return undefined
7962
+ }
7963
+ return NativeCtor; // constructor that existed before patching
7882
7964
  }
7883
7965
  };
7884
7966
  CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
@@ -7887,13 +7969,17 @@ function createScopedRegistry() {
7887
7969
  if (!isUndefined$1(definition)) {
7888
7970
  return definition.UserCtor;
7889
7971
  }
7890
- // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7891
7972
  // In this case, the custom element must have been defined before the registry patches
7892
7973
  // were applied. So return the non-pivot constructor
7893
7974
  if (isUndefined$1(NativeCtor)) {
7894
7975
  // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
7895
7976
  // We can patch the correct behavior using customElements.get()
7896
- return nativeGet.call(nativeRegistry, tagName);
7977
+ NativeCtor = nativeGet.call(nativeRegistry, tagName);
7978
+ }
7979
+ if (registeredPivotCtors.has(NativeCtor)) {
7980
+ // Pivot constructors should not be observable. Wait to resolve the promise
7981
+ // if a constructor is ever defined in userland
7982
+ return createPendingWhenDefinedCallback(tagName);
7897
7983
  }
7898
7984
  return NativeCtor;
7899
7985
  });
@@ -8123,7 +8209,7 @@ function rendererFactory(baseRenderer) {
8123
8209
  function isNull(obj) {
8124
8210
  return obj === null;
8125
8211
  }
8126
- /** version: 2.27.0 */
8212
+ /** version: 2.28.1 */
8127
8213
 
8128
8214
  /*
8129
8215
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8702,6 +8788,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
8702
8788
  });
8703
8789
  freeze(LightningElement);
8704
8790
  seal(LightningElement.prototype);
8705
- /* version: 2.27.0 */
8791
+ /* version: 2.28.1 */
8706
8792
 
8707
8793
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };