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