lwc 2.13.3 → 2.14.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 (43) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +351 -129
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +351 -128
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +195 -122
  5. package/dist/engine-dom/iife/es5/engine-dom.js +7581 -5773
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +5966 -4601
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +351 -128
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +195 -122
  11. package/dist/engine-dom/umd/es5/engine-dom.js +7581 -5773
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +5966 -4601
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +188 -52
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +188 -53
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +29 -4
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +29 -4
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +10 -13
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +4 -4
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +4601 -3603
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +10 -1
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +4424 -3481
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +29 -4
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +10 -13
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +4 -4
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +4601 -3603
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +10 -1
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +4424 -3481
  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.min.js +1 -1
  33. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service.js +243 -258
  35. package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
  36. package/dist/wire-service/iife/es5/wire-service_debug.js +243 -258
  37. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es2017/wire-service.min.js +1 -1
  39. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  40. package/dist/wire-service/umd/es5/wire-service.js +243 -258
  41. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  42. package/dist/wire-service/umd/es5/wire-service_debug.js +243 -258
  43. 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 { filter: ArrayFilter, find: ArrayFind, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, slice: ArraySlice, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
52
+ const { 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;
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) {
@@ -304,9 +304,9 @@
304
304
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
305
305
  */
306
306
  // Increment whenever the LWC template compiler changes
307
- const LWC_VERSION = "2.13.3";
307
+ const LWC_VERSION = "2.14.1";
308
308
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
309
- /** version: 2.13.3 */
309
+ /** version: 2.14.1 */
310
310
 
311
311
  /*
312
312
  * Copyright (c) 2018, salesforce.com, inc.
@@ -396,6 +396,7 @@
396
396
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
397
397
  */
398
398
  const features = {
399
+ DUMMY_TEST_FLAG: null,
399
400
  ENABLE_ELEMENT_PATCH: null,
400
401
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
401
402
  ENABLE_HMR: null,
@@ -459,10 +460,35 @@
459
460
  setFeatureFlag(name, value);
460
461
  }
461
462
  }
462
- /** version: 2.13.3 */
463
+ /** version: 2.14.1 */
463
464
 
464
465
  /* proxy-compat-disable */
465
466
 
467
+ /*
468
+ * Copyright (c) 2018, salesforce.com, inc.
469
+ * All rights reserved.
470
+ * SPDX-License-Identifier: MIT
471
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
472
+ */
473
+ // @ts-ignore
474
+
475
+ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
476
+ window.addEventListener('test-dummy-flag', () => {
477
+ let hasFlag = false;
478
+
479
+ if (runtimeFlags.DUMMY_TEST_FLAG) {
480
+ hasFlag = true;
481
+ }
482
+
483
+ window.dispatchEvent(new CustomEvent('has-dummy-flag', {
484
+ detail: {
485
+ package: '@lwc/engine-core',
486
+ hasFlag
487
+ }
488
+ }));
489
+ });
490
+ }
491
+
466
492
  /*
467
493
  * Copyright (c) 2018, salesforce.com, inc.
468
494
  * All rights reserved.
@@ -563,10 +589,6 @@
563
589
  function setHTMLElement(HTMLElementImpl) {
564
590
  HTMLElementExported$1 = HTMLElementImpl;
565
591
  }
566
- let isHydrating$1;
567
- function setIsHydrating$1(isHydratingImpl) {
568
- isHydrating$1 = isHydratingImpl;
569
- }
570
592
  let insert$1;
571
593
  function setInsert(insertImpl) {
572
594
  insert$1 = insertImpl;
@@ -687,10 +709,6 @@
687
709
  function setIsConnected(isConnectedImpl) {
688
710
  isConnected$1 = isConnectedImpl;
689
711
  }
690
- let insertGlobalStylesheet$1;
691
- function setInsertGlobalStylesheet(insertGlobalStylesheetImpl) {
692
- insertGlobalStylesheet$1 = insertGlobalStylesheetImpl;
693
- }
694
712
  let insertStylesheet$1;
695
713
  function setInsertStylesheet(insertStylesheetImpl) {
696
714
  insertStylesheet$1 = insertStylesheetImpl;
@@ -2757,7 +2775,8 @@
2757
2775
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2758
2776
  */
2759
2777
  let warned = false;
2760
- if (process.env.NODE_ENV === 'development') {
2778
+ // @ts-ignore
2779
+ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
2761
2780
  // @ts-ignore
2762
2781
  window.__lwcResetWarnedOnVersionMismatch = () => {
2763
2782
  warned = false;
@@ -2806,6 +2825,8 @@
2806
2825
  // on top of stylesheetToken for anyone who is accessing the old internal API.
2807
2826
  // Details: https://salesforce.quip.com/v1rmAFu2cKAr
2808
2827
  defineProperty(tpl, 'stylesheetTokens', {
2828
+ enumerable: true,
2829
+ configurable: true,
2809
2830
  get() {
2810
2831
  const { stylesheetToken } = this;
2811
2832
  if (isUndefined$1(stylesheetToken)) {
@@ -3889,16 +3910,20 @@
3889
3910
  }
3890
3911
  }
3891
3912
  function unmount(vnode, parent, doRemove = false) {
3892
- const { type, elm } = vnode;
3913
+ const { type, elm, sel } = vnode;
3893
3914
  // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3894
3915
  // subtree root, is the only element worth unmounting from the subtree.
3895
3916
  if (doRemove) {
3896
3917
  removeNode(elm, parent);
3897
3918
  }
3898
3919
  switch (type) {
3899
- case 2 /* Element */:
3900
- unmountVNodes(vnode.children, elm);
3920
+ case 2 /* Element */: {
3921
+ // Slot content is removed to trigger slotchange event when removing slot.
3922
+ // Only required for synthetic shadow.
3923
+ const removeChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
3924
+ unmountVNodes(vnode.children, elm, removeChildren);
3901
3925
  break;
3926
+ }
3902
3927
  case 3 /* CustomElement */: {
3903
3928
  const { vm } = vnode;
3904
3929
  // No need to unmount the children here, `removeVM` will take care of removing the
@@ -4815,10 +4840,10 @@
4815
4840
  const { renderMode, shadowMode } = vm;
4816
4841
  if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
4817
4842
  for (let i = 0; i < stylesheets.length; i++) {
4818
- insertGlobalStylesheet$1(stylesheets[i]);
4843
+ insertStylesheet$1(stylesheets[i]);
4819
4844
  }
4820
4845
  }
4821
- else if (ssr$1 || isHydrating$1()) {
4846
+ else if (ssr$1 || vm.hydrated) {
4822
4847
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4823
4848
  // This works in the client, because the stylesheets are created, and cached in the VM
4824
4849
  // the first time the VM renders.
@@ -4829,15 +4854,10 @@
4829
4854
  else {
4830
4855
  // native shadow or light DOM, DOM renderer
4831
4856
  const root = getNearestNativeShadowComponent(vm);
4832
- const isGlobal = isNull(root);
4857
+ // null root means a global style
4858
+ const target = isNull(root) ? undefined : root.shadowRoot;
4833
4859
  for (let i = 0; i < stylesheets.length; i++) {
4834
- if (isGlobal) {
4835
- insertGlobalStylesheet$1(stylesheets[i]);
4836
- }
4837
- else {
4838
- // local level
4839
- insertStylesheet$1(stylesheets[i], root.shadowRoot);
4840
- }
4860
+ insertStylesheet$1(stylesheets[i], target);
4841
4861
  }
4842
4862
  }
4843
4863
  return null;
@@ -5379,13 +5399,25 @@
5379
5399
 
5380
5400
  resetComponentStateWhenRemoved(vm);
5381
5401
  }
5382
- function createVM(elm, ctor, options) {
5383
- var _a;
5384
5402
 
5403
+ function getNearestShadowAncestor(vm) {
5404
+ let ancestor = vm.owner;
5405
+
5406
+ while (!isNull(ancestor) && ancestor.renderMode === 0
5407
+ /* Light */
5408
+ ) {
5409
+ ancestor = ancestor.owner;
5410
+ }
5411
+
5412
+ return ancestor;
5413
+ }
5414
+
5415
+ function createVM(elm, ctor, options) {
5385
5416
  const {
5386
5417
  mode,
5387
5418
  owner,
5388
- tagName
5419
+ tagName,
5420
+ hydrated
5389
5421
  } = options;
5390
5422
  const def = getComponentInternalDef(ctor);
5391
5423
  const vm = {
@@ -5408,9 +5440,8 @@
5408
5440
  cmpSlots: create(null),
5409
5441
  oar: create(null),
5410
5442
  cmpTemplate: null,
5443
+ hydrated: Boolean(hydrated),
5411
5444
  renderMode: def.renderMode,
5412
- shadowMode: computeShadowMode(def, owner),
5413
- nearestShadowMode: (owner === null || owner === void 0 ? void 0 : owner.shadowRoot) ? owner.shadowMode : (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : null,
5414
5445
  context: {
5415
5446
  stylesheetToken: undefined,
5416
5447
  hasTokenInClass: undefined,
@@ -5423,6 +5454,7 @@
5423
5454
  },
5424
5455
  // Properties set right after VM creation.
5425
5456
  tro: null,
5457
+ shadowMode: null,
5426
5458
  // Properties set by the LightningElement constructor.
5427
5459
  component: null,
5428
5460
  shadowRoot: null,
@@ -5431,6 +5463,7 @@
5431
5463
  setHook,
5432
5464
  getHook
5433
5465
  };
5466
+ vm.shadowMode = computeShadowMode(vm);
5434
5467
  vm.tro = getTemplateReactiveObserver(vm);
5435
5468
 
5436
5469
  if (process.env.NODE_ENV !== 'production') {
@@ -5455,9 +5488,10 @@
5455
5488
  return vm;
5456
5489
  }
5457
5490
 
5458
- function computeShadowMode(def, owner) {
5459
- var _a;
5460
-
5491
+ function computeShadowMode(vm) {
5492
+ const {
5493
+ def
5494
+ } = vm;
5461
5495
  let shadowMode;
5462
5496
 
5463
5497
  if (isSyntheticShadowDefined$1) {
@@ -5480,13 +5514,23 @@
5480
5514
  /* Native */
5481
5515
  ;
5482
5516
  } else {
5483
- // Transitive support for native Shadow DOM. A component in native mode
5484
- // transitively opts all of its descendants into native.
5485
- // Synthetic if neither this component nor any of its ancestors are configured
5486
- // to be native.
5487
- shadowMode = (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : 1
5488
- /* Synthetic */
5489
- ;
5517
+ const shadowAncestor = getNearestShadowAncestor(vm);
5518
+
5519
+ if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
5520
+ /* Native */
5521
+ ) {
5522
+ // Transitive support for native Shadow DOM. A component in native mode
5523
+ // transitively opts all of its descendants into native.
5524
+ shadowMode = 0
5525
+ /* Native */
5526
+ ;
5527
+ } else {
5528
+ // Synthetic if neither this component nor any of its ancestors are configured
5529
+ // to be native.
5530
+ shadowMode = 1
5531
+ /* Synthetic */
5532
+ ;
5533
+ }
5490
5534
  }
5491
5535
  } else {
5492
5536
  shadowMode = 1
@@ -6382,6 +6426,7 @@
6382
6426
  mode,
6383
6427
  owner,
6384
6428
  tagName: sel,
6429
+ hydrated: true,
6385
6430
  });
6386
6431
  vnode.elm = elm;
6387
6432
  vnode.vm = vm;
@@ -6576,6 +6621,105 @@
6576
6621
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6577
6622
  }
6578
6623
 
6624
+ /*
6625
+ * Copyright (c) 2018, salesforce.com, inc.
6626
+ * All rights reserved.
6627
+ * SPDX-License-Identifier: MIT
6628
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6629
+ */
6630
+ // See @lwc/engine-core/src/framework/template.ts
6631
+ const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
6632
+ // Via https://www.npmjs.com/package/object-observer
6633
+ const ARRAY_MUTATION_METHODS = [
6634
+ 'pop',
6635
+ 'push',
6636
+ 'shift',
6637
+ 'unshift',
6638
+ 'reverse',
6639
+ 'sort',
6640
+ 'fill',
6641
+ 'splice',
6642
+ 'copyWithin',
6643
+ ];
6644
+ function getOriginalArrayMethod(prop) {
6645
+ switch (prop) {
6646
+ case 'pop':
6647
+ return ArrayPop;
6648
+ case 'push':
6649
+ return ArrayPush$1;
6650
+ case 'shift':
6651
+ return ArrayShift;
6652
+ case 'unshift':
6653
+ return ArrayUnshift;
6654
+ case 'reverse':
6655
+ return ArrayReverse;
6656
+ case 'sort':
6657
+ return ArraySort;
6658
+ case 'fill':
6659
+ return ArrayFill;
6660
+ case 'splice':
6661
+ return ArraySplice;
6662
+ case 'copyWithin':
6663
+ return ArrayCopyWithin;
6664
+ }
6665
+ }
6666
+ let mutationWarningsSilenced = false;
6667
+ // Warn if the user tries to mutate tmpl.stylesheets, e.g.:
6668
+ // `tmpl.stylesheets.push(someStylesheetFunction)`
6669
+ function warnOnArrayMutation(stylesheets) {
6670
+ // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
6671
+ // we can at least warn when they use the most common mutation methods.
6672
+ for (const prop of ARRAY_MUTATION_METHODS) {
6673
+ const originalArrayMethod = getOriginalArrayMethod(prop);
6674
+ stylesheets[prop] = function arrayMutationWarningWrapper() {
6675
+ logError(`Mutating the "stylesheets" array on a template function ` +
6676
+ `is deprecated and may be removed in a future version of LWC.`);
6677
+ // @ts-ignore
6678
+ return originalArrayMethod.apply(this, arguments);
6679
+ };
6680
+ }
6681
+ }
6682
+ // TODO [#2782]: eventually freezeTemplate() will _actually_ freeze the tmpl object. Today it
6683
+ // just warns on mutation.
6684
+ function freezeTemplate(tmpl) {
6685
+ if (process.env.NODE_ENV !== 'production') {
6686
+ if (!isUndefined$1(tmpl.stylesheets)) {
6687
+ warnOnArrayMutation(tmpl.stylesheets);
6688
+ }
6689
+ for (const prop of TEMPLATE_PROPS) {
6690
+ let value = tmpl[prop];
6691
+ defineProperty(tmpl, prop, {
6692
+ enumerable: true,
6693
+ configurable: true,
6694
+ get() {
6695
+ return value;
6696
+ },
6697
+ set(newValue) {
6698
+ if (!mutationWarningsSilenced) {
6699
+ logError(`Dynamically setting the "${prop}" property on a template function ` +
6700
+ `is deprecated and may be removed in a future version of LWC.`);
6701
+ }
6702
+ value = newValue;
6703
+ },
6704
+ });
6705
+ }
6706
+ const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
6707
+ defineProperty(tmpl, 'stylesheetTokens', {
6708
+ enumerable: true,
6709
+ configurable: true,
6710
+ get: originalDescriptor.get,
6711
+ set(value) {
6712
+ logError(`Dynamically setting the "stylesheetTokens" property on a template function ` +
6713
+ `is deprecated and may be removed in a future version of LWC.`);
6714
+ // Avoid logging twice (for both stylesheetToken and stylesheetTokens)
6715
+ mutationWarningsSilenced = true;
6716
+ originalDescriptor.set.call(this, value);
6717
+ mutationWarningsSilenced = false;
6718
+ },
6719
+ });
6720
+ }
6721
+ }
6722
+
6579
6723
  /*
6580
6724
  * Copyright (c) 2018, salesforce.com, inc.
6581
6725
  * All rights reserved.
@@ -6598,7 +6742,7 @@
6598
6742
  }
6599
6743
  return ctor;
6600
6744
  }
6601
- /* version: 2.13.3 */
6745
+ /* version: 2.14.1 */
6602
6746
 
6603
6747
  /*
6604
6748
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6606,25 +6750,147 @@
6606
6750
  * SPDX-License-Identifier: MIT
6607
6751
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6608
6752
  */
6609
- const globalStylesheets = create(null);
6753
+ //
6754
+ // Feature detection
6755
+ //
6756
+ // This check for constructable style sheets is similar to Fast's:
6757
+ // https://github.com/microsoft/fast/blob/d49d1ec/packages/web-components/fast-element/src/dom.ts#L51-L53
6758
+ // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
6759
+ const supportsConstructableStylesheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
6760
+ // The original adoptedStylesheet proposal used a frozen array. A follow-up proposal made the array mutable.
6761
+ // Chromium 99+ and Firefox 101+ support mutable arrays. We check if the array is mutable, to ensure backward compat.
6762
+ // (If the length is writable, then the array is mutable.) See: https://chromestatus.com/feature/5638996492288000
6763
+ // TODO [#2828]: Re-evaluate this in the future once we drop support for older browser versions.
6764
+ const supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets &&
6765
+ getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
6766
+ // Detect IE, via https://stackoverflow.com/a/9851769
6767
+ const isIE11 = !isUndefined$1(document.documentMode);
6768
+ const stylesheetCache = new Map();
6769
+ //
6770
+ // Test utilities
6771
+ //
6610
6772
  if (process.env.NODE_ENV === 'development') {
6611
6773
  // @ts-ignore
6612
6774
  window.__lwcResetGlobalStylesheets = () => {
6613
- for (const key of Object.keys(globalStylesheets)) {
6614
- delete globalStylesheets[key];
6615
- }
6775
+ stylesheetCache.clear();
6616
6776
  };
6617
6777
  }
6618
- const globalStylesheetsParentElement = document.head || document.body || document;
6619
- // This check for constructable stylesheets is similar to Fast's:
6620
- // https://github.com/microsoft/fast/blob/d49d1ec/packages/web-components/fast-element/src/dom.ts#L51-L53
6621
- // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
6622
- const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
6623
- const supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets &&
6624
- getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
6625
- const styleElements = create(null);
6626
- const styleSheets = create(null);
6627
- const shadowRootsToStyleSheets = new WeakMap();
6778
+ function isDocument(target) {
6779
+ return !isUndefined$1(target.head);
6780
+ }
6781
+ function createFreshStyleElement(content) {
6782
+ const elm = document.createElement('style');
6783
+ elm.type = 'text/css';
6784
+ elm.textContent = content;
6785
+ return elm;
6786
+ }
6787
+ function createStyleElement(content, cacheData) {
6788
+ const { stylesheet, used } = cacheData;
6789
+ // If the <style> was already used, then we should clone it. We cannot insert
6790
+ // the same <style> in two places in the DOM.
6791
+ if (used) {
6792
+ // For a mysterious reason, IE11 doesn't like the way we clone <style> nodes
6793
+ // and will render the incorrect styles if we do things that way. It's just
6794
+ // a perf optimization, so we can skip it for IE11.
6795
+ if (isIE11) {
6796
+ return createFreshStyleElement(content);
6797
+ }
6798
+ // This `<style>` may be repeated multiple times in the DOM, so cache it. It's a bit
6799
+ // faster to call `cloneNode()` on an existing node than to recreate it every time.
6800
+ return stylesheet.cloneNode(true);
6801
+ }
6802
+ // We don't clone every time, because that would be a perf tax on the first time
6803
+ cacheData.used = true;
6804
+ return stylesheet;
6805
+ }
6806
+ function createConstructableStylesheet(content) {
6807
+ const stylesheet = new CSSStyleSheet();
6808
+ stylesheet.replaceSync(content);
6809
+ return stylesheet;
6810
+ }
6811
+ function insertConstructableStylesheet(content, target, cacheData) {
6812
+ const { adoptedStyleSheets } = target;
6813
+ const { stylesheet } = cacheData;
6814
+ // Mutable adopted stylesheets are only supported in certain browsers.
6815
+ // The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2683
6816
+ if (supportsMutableAdoptedStyleSheets) {
6817
+ adoptedStyleSheets.push(stylesheet);
6818
+ }
6819
+ else {
6820
+ target.adoptedStyleSheets = [...adoptedStyleSheets, stylesheet];
6821
+ }
6822
+ }
6823
+ function insertStyleElement(content, target, cacheData) {
6824
+ const elm = createStyleElement(content, cacheData);
6825
+ const targetAnchorPoint = isDocument(target) ? target.head : target;
6826
+ targetAnchorPoint.appendChild(elm);
6827
+ }
6828
+ function doInsertStylesheet(content, target, cacheData) {
6829
+ // Constructable stylesheets are only supported in certain browsers:
6830
+ // https://caniuse.com/mdn-api_document_adoptedstylesheets
6831
+ // The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2460
6832
+ if (supportsConstructableStylesheets) {
6833
+ insertConstructableStylesheet(content, target, cacheData);
6834
+ }
6835
+ else {
6836
+ // Fall back to <style> element
6837
+ insertStyleElement(content, target, cacheData);
6838
+ }
6839
+ }
6840
+ function getCacheData(content) {
6841
+ let cacheData = stylesheetCache.get(content);
6842
+ if (isUndefined$1(cacheData)) {
6843
+ cacheData = {
6844
+ stylesheet: supportsConstructableStylesheets
6845
+ ? createConstructableStylesheet(content)
6846
+ : createFreshStyleElement(content),
6847
+ roots: undefined,
6848
+ global: false,
6849
+ used: false,
6850
+ };
6851
+ stylesheetCache.set(content, cacheData);
6852
+ }
6853
+ return cacheData;
6854
+ }
6855
+ function insertGlobalStylesheet(content) {
6856
+ const cacheData = getCacheData(content);
6857
+ if (cacheData.global) {
6858
+ // already inserted
6859
+ return;
6860
+ }
6861
+ cacheData.global = true; // mark inserted
6862
+ doInsertStylesheet(content, document, cacheData);
6863
+ }
6864
+ function insertLocalStylesheet(content, target) {
6865
+ const cacheData = getCacheData(content);
6866
+ let { roots } = cacheData;
6867
+ if (isUndefined$1(roots)) {
6868
+ roots = cacheData.roots = new WeakSet(); // lazily initialize (not needed for global styles)
6869
+ }
6870
+ else if (roots.has(target)) {
6871
+ // already inserted
6872
+ return;
6873
+ }
6874
+ roots.add(target); // mark inserted
6875
+ doInsertStylesheet(content, target, cacheData);
6876
+ }
6877
+ function insertStylesheet(content, target) {
6878
+ if (isUndefined$1(target)) {
6879
+ // global
6880
+ insertGlobalStylesheet(content);
6881
+ }
6882
+ else {
6883
+ // local
6884
+ insertLocalStylesheet(content, target);
6885
+ }
6886
+ }
6887
+
6888
+ /*
6889
+ * Copyright (c) 2018, salesforce.com, inc.
6890
+ * All rights reserved.
6891
+ * SPDX-License-Identifier: MIT
6892
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6893
+ */
6628
6894
  let getCustomElement;
6629
6895
  let defineCustomElement;
6630
6896
  let HTMLElementConstructor;
@@ -6651,52 +6917,6 @@
6651
6917
  return false;
6652
6918
  }
6653
6919
  }
6654
- function insertConstructableStyleSheet(content, target) {
6655
- // It's important for CSSStyleSheets to be unique based on their content, so that
6656
- // `shadowRoot.adoptedStyleSheets.includes(sheet)` works.
6657
- let styleSheet = styleSheets[content];
6658
- if (isUndefined$1(styleSheet)) {
6659
- styleSheet = new CSSStyleSheet();
6660
- styleSheet.replaceSync(content);
6661
- styleSheets[content] = styleSheet;
6662
- }
6663
- const { adoptedStyleSheets } = target;
6664
- if (!adoptedStyleSheets.includes(styleSheet)) {
6665
- if (supportsMutableAdoptedStyleSheets) {
6666
- // This is only supported in later versions of Chromium:
6667
- // https://chromestatus.com/feature/5638996492288000
6668
- adoptedStyleSheets.push(styleSheet);
6669
- }
6670
- else {
6671
- target.adoptedStyleSheets = [...adoptedStyleSheets, styleSheet];
6672
- }
6673
- }
6674
- }
6675
- function insertStyleElement(content, target) {
6676
- // Avoid inserting duplicate `<style>`s
6677
- let sheets = shadowRootsToStyleSheets.get(target);
6678
- if (isUndefined$1(sheets)) {
6679
- sheets = create(null);
6680
- shadowRootsToStyleSheets.set(target, sheets);
6681
- }
6682
- if (sheets[content]) {
6683
- return;
6684
- }
6685
- sheets[content] = true;
6686
- // This `<style>` may be repeated multiple times in the DOM, so cache it. It's a bit
6687
- // faster to call `cloneNode()` on an existing node than to recreate it every time.
6688
- let elm = styleElements[content];
6689
- if (isUndefined$1(elm)) {
6690
- elm = document.createElement('style');
6691
- elm.type = 'text/css';
6692
- elm.textContent = content;
6693
- styleElements[content] = elm;
6694
- }
6695
- else {
6696
- elm = elm.cloneNode(true);
6697
- }
6698
- target.appendChild(elm);
6699
- }
6700
6920
  if (isCustomElementRegistryAvailable()) {
6701
6921
  getCustomElement = customElements.get.bind(customElements);
6702
6922
  defineCustomElement = customElements.define.bind(customElements);
@@ -6735,9 +6955,6 @@
6735
6955
  hydrating = value;
6736
6956
  }
6737
6957
  const ssr = false;
6738
- function isHydrating() {
6739
- return hydrating;
6740
- }
6741
6958
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
6742
6959
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
6743
6960
  function createElement$1(tagName, namespace) {
@@ -6852,25 +7069,6 @@
6852
7069
  function isConnected(node) {
6853
7070
  return node.isConnected;
6854
7071
  }
6855
- function insertGlobalStylesheet(content) {
6856
- if (!isUndefined$1(globalStylesheets[content])) {
6857
- return;
6858
- }
6859
- globalStylesheets[content] = true;
6860
- const elm = document.createElement('style');
6861
- elm.type = 'text/css';
6862
- elm.textContent = content;
6863
- globalStylesheetsParentElement.appendChild(elm);
6864
- }
6865
- function insertStylesheet(content, target) {
6866
- if (supportsConstructableStyleSheets) {
6867
- insertConstructableStyleSheet(content, target);
6868
- }
6869
- else {
6870
- // Fall back to <style> element
6871
- insertStyleElement(content, target);
6872
- }
6873
- }
6874
7072
  function assertInstanceOfHTMLElement(elm, msg) {
6875
7073
  assert.invariant(elm instanceof HTMLElement, msg);
6876
7074
  }
@@ -6904,10 +7102,7 @@
6904
7102
  setGetProperty(getProperty);
6905
7103
  setHTMLElement(HTMLElementExported);
6906
7104
  setInsert(insert);
6907
- setInsertGlobalStylesheet(insertGlobalStylesheet);
6908
- setInsertStylesheet(insertStylesheet);
6909
7105
  setIsConnected(isConnected);
6910
- setIsHydrating$1(isHydrating);
6911
7106
  setIsNativeShadowDefined(isNativeShadowDefined);
6912
7107
  setIsSyntheticShadowDefined(isSyntheticShadowDefined);
6913
7108
  setNextSibling(nextSibling);
@@ -6922,6 +7117,32 @@
6922
7117
  setSetText(setText);
6923
7118
  setSsr(ssr);
6924
7119
  setAddEventListener(addEventListener);
7120
+ setInsertStylesheet(insertStylesheet);
7121
+
7122
+ /*
7123
+ * Copyright (c) 2018, salesforce.com, inc.
7124
+ * All rights reserved.
7125
+ * SPDX-License-Identifier: MIT
7126
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7127
+ */
7128
+ // @ts-ignore
7129
+
7130
+ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
7131
+ window.addEventListener('test-dummy-flag', () => {
7132
+ let hasFlag = false;
7133
+
7134
+ if (runtimeFlags.DUMMY_TEST_FLAG) {
7135
+ hasFlag = true;
7136
+ }
7137
+
7138
+ window.dispatchEvent(new CustomEvent('has-dummy-flag', {
7139
+ detail: {
7140
+ package: '@lwc/engine-dom',
7141
+ hasFlag
7142
+ }
7143
+ }));
7144
+ });
7145
+ }
6925
7146
 
6926
7147
  /*
6927
7148
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6947,6 +7168,7 @@
6947
7168
  mode: 'open',
6948
7169
  owner: null,
6949
7170
  tagName: element.tagName.toLowerCase(),
7171
+ hydrated: true,
6950
7172
  });
6951
7173
  for (const [key, value] of Object.entries(props)) {
6952
7174
  element[key] = value;
@@ -7217,7 +7439,7 @@
7217
7439
  });
7218
7440
  freeze(LightningElement);
7219
7441
  seal(LightningElement.prototype);
7220
- /* version: 2.13.3 */
7442
+ /* version: 2.14.1 */
7221
7443
 
7222
7444
  exports.LightningElement = LightningElement;
7223
7445
  exports.__unstable__ProfilerControl = profilerControl;
@@ -7225,6 +7447,7 @@
7225
7447
  exports.buildCustomElementConstructor = deprecatedBuildCustomElementConstructor;
7226
7448
  exports.createContextProvider = createContextProvider;
7227
7449
  exports.createElement = createElement;
7450
+ exports.freezeTemplate = freezeTemplate;
7228
7451
  exports.getComponentConstructor = getComponentConstructor;
7229
7452
  exports.getComponentDef = getComponentDef;
7230
7453
  exports.hydrateComponent = hydrateComponent;