lwc 2.13.1 → 2.13.4

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 +376 -170
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +376 -169
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +222 -164
  5. package/dist/engine-dom/iife/es5/engine-dom.js +7562 -5758
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +5947 -4586
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +376 -169
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +222 -164
  11. package/dist/engine-dom/umd/es5/engine-dom.js +7562 -5758
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +5947 -4586
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +190 -72
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +190 -73
  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
@@ -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 { 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;
46
+ 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;
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) {
@@ -298,9 +298,9 @@ const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
298
298
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
299
299
  */
300
300
  // Increment whenever the LWC template compiler changes
301
- const LWC_VERSION = "2.13.1";
301
+ const LWC_VERSION = "2.13.4";
302
302
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
303
- /** version: 2.13.1 */
303
+ /** version: 2.13.4 */
304
304
 
305
305
  /*
306
306
  * Copyright (c) 2018, salesforce.com, inc.
@@ -390,6 +390,7 @@ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1)
390
390
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
391
391
  */
392
392
  const features = {
393
+ DUMMY_TEST_FLAG: null,
393
394
  ENABLE_ELEMENT_PATCH: null,
394
395
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
395
396
  ENABLE_HMR: null,
@@ -453,10 +454,35 @@ function setFeatureFlagForTest(name, value) {
453
454
  setFeatureFlag(name, value);
454
455
  }
455
456
  }
456
- /** version: 2.13.1 */
457
+ /** version: 2.13.4 */
457
458
 
458
459
  /* proxy-compat-disable */
459
460
 
461
+ /*
462
+ * Copyright (c) 2018, salesforce.com, inc.
463
+ * All rights reserved.
464
+ * SPDX-License-Identifier: MIT
465
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
466
+ */
467
+ // @ts-ignore
468
+
469
+ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
470
+ window.addEventListener('test-dummy-flag', () => {
471
+ let hasFlag = false;
472
+
473
+ if (runtimeFlags.DUMMY_TEST_FLAG) {
474
+ hasFlag = true;
475
+ }
476
+
477
+ window.dispatchEvent(new CustomEvent('has-dummy-flag', {
478
+ detail: {
479
+ package: '@lwc/engine-core',
480
+ hasFlag
481
+ }
482
+ }));
483
+ });
484
+ }
485
+
460
486
  /*
461
487
  * Copyright (c) 2018, salesforce.com, inc.
462
488
  * All rights reserved.
@@ -557,10 +583,6 @@ let HTMLElementExported$1;
557
583
  function setHTMLElement(HTMLElementImpl) {
558
584
  HTMLElementExported$1 = HTMLElementImpl;
559
585
  }
560
- let isHydrating$1;
561
- function setIsHydrating$1(isHydratingImpl) {
562
- isHydrating$1 = isHydratingImpl;
563
- }
564
586
  let insert$1;
565
587
  function setInsert(insertImpl) {
566
588
  insert$1 = insertImpl;
@@ -681,10 +703,6 @@ let isConnected$1;
681
703
  function setIsConnected(isConnectedImpl) {
682
704
  isConnected$1 = isConnectedImpl;
683
705
  }
684
- let insertGlobalStylesheet$1;
685
- function setInsertGlobalStylesheet(insertGlobalStylesheetImpl) {
686
- insertGlobalStylesheet$1 = insertGlobalStylesheetImpl;
687
- }
688
706
  let insertStylesheet$1;
689
707
  function setInsertStylesheet(insertStylesheetImpl) {
690
708
  insertStylesheet$1 = insertStylesheetImpl;
@@ -2772,6 +2790,12 @@ function checkVersionMismatch(func, type) {
2772
2790
  }
2773
2791
  }
2774
2792
 
2793
+ /*
2794
+ * Copyright (c) 2018, salesforce.com, inc.
2795
+ * All rights reserved.
2796
+ * SPDX-License-Identifier: MIT
2797
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2798
+ */
2775
2799
  const signedTemplateSet = new Set();
2776
2800
  function defaultEmptyTemplate() {
2777
2801
  return [];
@@ -2789,6 +2813,32 @@ function registerTemplate(tpl) {
2789
2813
  checkVersionMismatch(tpl, 'template');
2790
2814
  }
2791
2815
  signedTemplateSet.add(tpl);
2816
+ // FIXME[@W-10950976]: the template object should be frozen, and it should not be possible to set
2817
+ // the stylesheets or stylesheetToken(s). For backwards compat, though, we shim stylesheetTokens
2818
+ // on top of stylesheetToken for anyone who is accessing the old internal API.
2819
+ // Details: https://salesforce.quip.com/v1rmAFu2cKAr
2820
+ defineProperty(tpl, 'stylesheetTokens', {
2821
+ enumerable: true,
2822
+ configurable: true,
2823
+ get() {
2824
+ const { stylesheetToken } = this;
2825
+ if (isUndefined$1(stylesheetToken)) {
2826
+ return stylesheetToken;
2827
+ }
2828
+ // Shim for the old `stylesheetTokens` property
2829
+ // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
2830
+ return {
2831
+ hostAttribute: `${stylesheetToken}-host`,
2832
+ shadowAttribute: stylesheetToken,
2833
+ };
2834
+ },
2835
+ set(value) {
2836
+ // If the value is null or some other exotic object, you would be broken anyway in the past
2837
+ // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
2838
+ // However it may be undefined in newer versions of LWC, so we need to guard against that case.
2839
+ this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
2840
+ },
2841
+ });
2792
2842
  // chaining this method as a way to wrap existing
2793
2843
  // assignment of templates easily, without too much transformation
2794
2844
  return tpl;
@@ -3853,15 +3903,16 @@ function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
3853
3903
  }
3854
3904
  }
3855
3905
  function unmount(vnode, parent, doRemove = false) {
3856
- const { type, elm } = vnode;
3906
+ const { type, elm, sel } = vnode;
3857
3907
  // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3858
3908
  // subtree root, is the only element worth unmounting from the subtree.
3859
3909
  if (doRemove) {
3860
3910
  removeNode(elm, parent);
3861
3911
  }
3912
+ const removeChildren = sel === 'slot'; // slot content is removed to trigger slotchange event when removing slot
3862
3913
  switch (type) {
3863
3914
  case 2 /* Element */:
3864
- unmountVNodes(vnode.children, elm);
3915
+ unmountVNodes(vnode.children, elm, removeChildren);
3865
3916
  break;
3866
3917
  case 3 /* CustomElement */: {
3867
3918
  const { vm } = vnode;
@@ -4779,10 +4830,10 @@ function createStylesheet(vm, stylesheets) {
4779
4830
  const { renderMode, shadowMode } = vm;
4780
4831
  if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
4781
4832
  for (let i = 0; i < stylesheets.length; i++) {
4782
- insertGlobalStylesheet$1(stylesheets[i]);
4833
+ insertStylesheet$1(stylesheets[i]);
4783
4834
  }
4784
4835
  }
4785
- else if (ssr$1 || isHydrating$1()) {
4836
+ else if (ssr$1 || vm.hydrated) {
4786
4837
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4787
4838
  // This works in the client, because the stylesheets are created, and cached in the VM
4788
4839
  // the first time the VM renders.
@@ -4793,15 +4844,10 @@ function createStylesheet(vm, stylesheets) {
4793
4844
  else {
4794
4845
  // native shadow or light DOM, DOM renderer
4795
4846
  const root = getNearestNativeShadowComponent(vm);
4796
- const isGlobal = isNull(root);
4847
+ // null root means a global style
4848
+ const target = isNull(root) ? undefined : root.shadowRoot;
4797
4849
  for (let i = 0; i < stylesheets.length; i++) {
4798
- if (isGlobal) {
4799
- insertGlobalStylesheet$1(stylesheets[i]);
4800
- }
4801
- else {
4802
- // local level
4803
- insertStylesheet$1(stylesheets[i], root.shadowRoot);
4804
- }
4850
+ insertStylesheet$1(stylesheets[i], target);
4805
4851
  }
4806
4852
  }
4807
4853
  return null;
@@ -5343,24 +5389,14 @@ function removeVM(vm) {
5343
5389
 
5344
5390
  resetComponentStateWhenRemoved(vm);
5345
5391
  }
5346
-
5347
- function getNearestShadowAncestor(vm) {
5348
- let ancestor = vm.owner;
5349
-
5350
- while (!isNull(ancestor) && ancestor.renderMode === 0
5351
- /* Light */
5352
- ) {
5353
- ancestor = ancestor.owner;
5354
- }
5355
-
5356
- return ancestor;
5357
- }
5358
-
5359
5392
  function createVM(elm, ctor, options) {
5393
+ var _a;
5394
+
5360
5395
  const {
5361
5396
  mode,
5362
5397
  owner,
5363
- tagName
5398
+ tagName,
5399
+ hydrated
5364
5400
  } = options;
5365
5401
  const def = getComponentInternalDef(ctor);
5366
5402
  const vm = {
@@ -5383,7 +5419,10 @@ function createVM(elm, ctor, options) {
5383
5419
  cmpSlots: create(null),
5384
5420
  oar: create(null),
5385
5421
  cmpTemplate: null,
5422
+ hydrated: Boolean(hydrated),
5386
5423
  renderMode: def.renderMode,
5424
+ shadowMode: computeShadowMode(def, owner),
5425
+ 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,
5387
5426
  context: {
5388
5427
  stylesheetToken: undefined,
5389
5428
  hasTokenInClass: undefined,
@@ -5396,7 +5435,6 @@ function createVM(elm, ctor, options) {
5396
5435
  },
5397
5436
  // Properties set right after VM creation.
5398
5437
  tro: null,
5399
- shadowMode: null,
5400
5438
  // Properties set by the LightningElement constructor.
5401
5439
  component: null,
5402
5440
  shadowRoot: null,
@@ -5405,7 +5443,6 @@ function createVM(elm, ctor, options) {
5405
5443
  setHook,
5406
5444
  getHook
5407
5445
  };
5408
- vm.shadowMode = computeShadowMode(vm);
5409
5446
  vm.tro = getTemplateReactiveObserver(vm);
5410
5447
 
5411
5448
  if (process.env.NODE_ENV !== 'production') {
@@ -5430,10 +5467,9 @@ function createVM(elm, ctor, options) {
5430
5467
  return vm;
5431
5468
  }
5432
5469
 
5433
- function computeShadowMode(vm) {
5434
- const {
5435
- def
5436
- } = vm;
5470
+ function computeShadowMode(def, owner) {
5471
+ var _a;
5472
+
5437
5473
  let shadowMode;
5438
5474
 
5439
5475
  if (isSyntheticShadowDefined$1) {
@@ -5456,23 +5492,13 @@ function computeShadowMode(vm) {
5456
5492
  /* Native */
5457
5493
  ;
5458
5494
  } else {
5459
- const shadowAncestor = getNearestShadowAncestor(vm);
5460
-
5461
- if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
5462
- /* Native */
5463
- ) {
5464
- // Transitive support for native Shadow DOM. A component in native mode
5465
- // transitively opts all of its descendants into native.
5466
- shadowMode = 0
5467
- /* Native */
5468
- ;
5469
- } else {
5470
- // Synthetic if neither this component nor any of its ancestors are configured
5471
- // to be native.
5472
- shadowMode = 1
5473
- /* Synthetic */
5474
- ;
5475
- }
5495
+ // Transitive support for native Shadow DOM. A component in native mode
5496
+ // transitively opts all of its descendants into native.
5497
+ // Synthetic if neither this component nor any of its ancestors are configured
5498
+ // to be native.
5499
+ shadowMode = (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : 1
5500
+ /* Synthetic */
5501
+ ;
5476
5502
  }
5477
5503
  } else {
5478
5504
  shadowMode = 1
@@ -6368,6 +6394,7 @@ function hydrateCustomElement(elm, vnode) {
6368
6394
  mode,
6369
6395
  owner,
6370
6396
  tagName: sel,
6397
+ hydrated: true,
6371
6398
  });
6372
6399
  vnode.elm = elm;
6373
6400
  vnode.vm = vm;
@@ -6561,7 +6588,6 @@ function setHooks(hooks) {
6561
6588
  hooksAreSet = true;
6562
6589
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6563
6590
  }
6564
- /* version: 2.13.1 */
6565
6591
 
6566
6592
  /*
6567
6593
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6569,25 +6595,270 @@ function setHooks(hooks) {
6569
6595
  * SPDX-License-Identifier: MIT
6570
6596
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6571
6597
  */
6572
- const globalStylesheets = create(null);
6573
- if (process.env.NODE_ENV === 'development') {
6574
- // @ts-ignore
6575
- window.__lwcResetGlobalStylesheets = () => {
6576
- for (const key of Object.keys(globalStylesheets)) {
6577
- delete globalStylesheets[key];
6598
+ // See @lwc/engine-core/src/framework/template.ts
6599
+ const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
6600
+ // Via https://www.npmjs.com/package/object-observer
6601
+ const ARRAY_MUTATION_METHODS = [
6602
+ 'pop',
6603
+ 'push',
6604
+ 'shift',
6605
+ 'unshift',
6606
+ 'reverse',
6607
+ 'sort',
6608
+ 'fill',
6609
+ 'splice',
6610
+ 'copyWithin',
6611
+ ];
6612
+ function getOriginalArrayMethod(prop) {
6613
+ switch (prop) {
6614
+ case 'pop':
6615
+ return ArrayPop;
6616
+ case 'push':
6617
+ return ArrayPush$1;
6618
+ case 'shift':
6619
+ return ArrayShift;
6620
+ case 'unshift':
6621
+ return ArrayUnshift;
6622
+ case 'reverse':
6623
+ return ArrayReverse;
6624
+ case 'sort':
6625
+ return ArraySort;
6626
+ case 'fill':
6627
+ return ArrayFill;
6628
+ case 'splice':
6629
+ return ArraySplice;
6630
+ case 'copyWithin':
6631
+ return ArrayCopyWithin;
6632
+ }
6633
+ }
6634
+ let mutationWarningsSilenced = false;
6635
+ // Warn if the user tries to mutate tmpl.stylesheets, e.g.:
6636
+ // `tmpl.stylesheets.push(someStylesheetFunction)`
6637
+ function warnOnArrayMutation(stylesheets) {
6638
+ // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
6639
+ // we can at least warn when they use the most common mutation methods.
6640
+ for (const prop of ARRAY_MUTATION_METHODS) {
6641
+ const originalArrayMethod = getOriginalArrayMethod(prop);
6642
+ stylesheets[prop] = function arrayMutationWarningWrapper() {
6643
+ logError(`Mutating the "stylesheets" array on a template function ` +
6644
+ `is deprecated and may be removed in a future version of LWC.`);
6645
+ // @ts-ignore
6646
+ return originalArrayMethod.apply(this, arguments);
6647
+ };
6648
+ }
6649
+ }
6650
+ // TODO [#2782]: eventually freezeTemplate() will _actually_ freeze the tmpl object. Today it
6651
+ // just warns on mutation.
6652
+ function freezeTemplate(tmpl) {
6653
+ if (process.env.NODE_ENV !== 'production') {
6654
+ if (!isUndefined$1(tmpl.stylesheets)) {
6655
+ warnOnArrayMutation(tmpl.stylesheets);
6656
+ }
6657
+ for (const prop of TEMPLATE_PROPS) {
6658
+ let value = tmpl[prop];
6659
+ defineProperty(tmpl, prop, {
6660
+ enumerable: true,
6661
+ configurable: true,
6662
+ get() {
6663
+ return value;
6664
+ },
6665
+ set(newValue) {
6666
+ if (!mutationWarningsSilenced) {
6667
+ logError(`Dynamically setting the "${prop}" property on a template function ` +
6668
+ `is deprecated and may be removed in a future version of LWC.`);
6669
+ }
6670
+ value = newValue;
6671
+ },
6672
+ });
6578
6673
  }
6579
- };
6674
+ const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
6675
+ defineProperty(tmpl, 'stylesheetTokens', {
6676
+ enumerable: true,
6677
+ configurable: true,
6678
+ get: originalDescriptor.get,
6679
+ set(value) {
6680
+ logError(`Dynamically setting the "stylesheetTokens" property on a template function ` +
6681
+ `is deprecated and may be removed in a future version of LWC.`);
6682
+ // Avoid logging twice (for both stylesheetToken and stylesheetTokens)
6683
+ mutationWarningsSilenced = true;
6684
+ originalDescriptor.set.call(this, value);
6685
+ mutationWarningsSilenced = false;
6686
+ },
6687
+ });
6688
+ }
6580
6689
  }
6581
- const globalStylesheetsParentElement = document.head || document.body || document;
6582
- // This check for constructable stylesheets is similar to Fast's:
6690
+
6691
+ /*
6692
+ * Copyright (c) 2018, salesforce.com, inc.
6693
+ * All rights reserved.
6694
+ * SPDX-License-Identifier: MIT
6695
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6696
+ */
6697
+ /**
6698
+ * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6699
+ * This API is subject to change or being removed.
6700
+ */
6701
+ function getComponentConstructor(elm) {
6702
+ let ctor = null;
6703
+ // intentionally checking for undefined due to some funky libraries patching weakmap.get
6704
+ // to throw when undefined.
6705
+ if (!isUndefined$1(elm)) {
6706
+ const vm = getAssociatedVMIfPresent(elm);
6707
+ if (!isUndefined$1(vm)) {
6708
+ ctor = vm.def.ctor;
6709
+ }
6710
+ }
6711
+ return ctor;
6712
+ }
6713
+ /* version: 2.13.4 */
6714
+
6715
+ /*
6716
+ * Copyright (c) 2018, salesforce.com, inc.
6717
+ * All rights reserved.
6718
+ * SPDX-License-Identifier: MIT
6719
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6720
+ */
6721
+ //
6722
+ // Feature detection
6723
+ //
6724
+ // This check for constructable style sheets is similar to Fast's:
6583
6725
  // https://github.com/microsoft/fast/blob/d49d1ec/packages/web-components/fast-element/src/dom.ts#L51-L53
6584
6726
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
6585
- const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
6586
- const supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets &&
6727
+ const supportsConstructableStylesheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
6728
+ // The original adoptedStylesheet proposal used a frozen array. A follow-up proposal made the array mutable.
6729
+ // Chromium 99+ and Firefox 101+ support mutable arrays. We check if the array is mutable, to ensure backward compat.
6730
+ // (If the length is writable, then the array is mutable.) See: https://chromestatus.com/feature/5638996492288000
6731
+ // TODO [#2828]: Re-evaluate this in the future once we drop support for older browser versions.
6732
+ const supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets &&
6587
6733
  getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
6588
- const styleElements = create(null);
6589
- const styleSheets = create(null);
6590
- const shadowRootsToStyleSheets = new WeakMap();
6734
+ // Detect IE, via https://stackoverflow.com/a/9851769
6735
+ const isIE11 = !isUndefined$1(document.documentMode);
6736
+ const stylesheetCache = new Map();
6737
+ //
6738
+ // Test utilities
6739
+ //
6740
+ if (process.env.NODE_ENV === 'development') {
6741
+ // @ts-ignore
6742
+ window.__lwcResetGlobalStylesheets = () => {
6743
+ stylesheetCache.clear();
6744
+ };
6745
+ }
6746
+ function isDocument(target) {
6747
+ return !isUndefined$1(target.head);
6748
+ }
6749
+ function createFreshStyleElement(content) {
6750
+ const elm = document.createElement('style');
6751
+ elm.type = 'text/css';
6752
+ elm.textContent = content;
6753
+ return elm;
6754
+ }
6755
+ function createStyleElement(content, cacheData) {
6756
+ const { stylesheet, used } = cacheData;
6757
+ // If the <style> was already used, then we should clone it. We cannot insert
6758
+ // the same <style> in two places in the DOM.
6759
+ if (used) {
6760
+ // For a mysterious reason, IE11 doesn't like the way we clone <style> nodes
6761
+ // and will render the incorrect styles if we do things that way. It's just
6762
+ // a perf optimization, so we can skip it for IE11.
6763
+ if (isIE11) {
6764
+ return createFreshStyleElement(content);
6765
+ }
6766
+ // This `<style>` may be repeated multiple times in the DOM, so cache it. It's a bit
6767
+ // faster to call `cloneNode()` on an existing node than to recreate it every time.
6768
+ return stylesheet.cloneNode(true);
6769
+ }
6770
+ // We don't clone every time, because that would be a perf tax on the first time
6771
+ cacheData.used = true;
6772
+ return stylesheet;
6773
+ }
6774
+ function createConstructableStylesheet(content) {
6775
+ const stylesheet = new CSSStyleSheet();
6776
+ stylesheet.replaceSync(content);
6777
+ return stylesheet;
6778
+ }
6779
+ function insertConstructableStylesheet(content, target, cacheData) {
6780
+ const { adoptedStyleSheets } = target;
6781
+ const { stylesheet } = cacheData;
6782
+ // Mutable adopted stylesheets are only supported in certain browsers.
6783
+ // The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2683
6784
+ if (supportsMutableAdoptedStyleSheets) {
6785
+ adoptedStyleSheets.push(stylesheet);
6786
+ }
6787
+ else {
6788
+ target.adoptedStyleSheets = [...adoptedStyleSheets, stylesheet];
6789
+ }
6790
+ }
6791
+ function insertStyleElement(content, target, cacheData) {
6792
+ const elm = createStyleElement(content, cacheData);
6793
+ const targetAnchorPoint = isDocument(target) ? target.head : target;
6794
+ targetAnchorPoint.appendChild(elm);
6795
+ }
6796
+ function doInsertStylesheet(content, target, cacheData) {
6797
+ // Constructable stylesheets are only supported in certain browsers:
6798
+ // https://caniuse.com/mdn-api_document_adoptedstylesheets
6799
+ // The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2460
6800
+ if (supportsConstructableStylesheets) {
6801
+ insertConstructableStylesheet(content, target, cacheData);
6802
+ }
6803
+ else {
6804
+ // Fall back to <style> element
6805
+ insertStyleElement(content, target, cacheData);
6806
+ }
6807
+ }
6808
+ function getCacheData(content) {
6809
+ let cacheData = stylesheetCache.get(content);
6810
+ if (isUndefined$1(cacheData)) {
6811
+ cacheData = {
6812
+ stylesheet: supportsConstructableStylesheets
6813
+ ? createConstructableStylesheet(content)
6814
+ : createFreshStyleElement(content),
6815
+ roots: undefined,
6816
+ global: false,
6817
+ used: false,
6818
+ };
6819
+ stylesheetCache.set(content, cacheData);
6820
+ }
6821
+ return cacheData;
6822
+ }
6823
+ function insertGlobalStylesheet(content) {
6824
+ const cacheData = getCacheData(content);
6825
+ if (cacheData.global) {
6826
+ // already inserted
6827
+ return;
6828
+ }
6829
+ cacheData.global = true; // mark inserted
6830
+ doInsertStylesheet(content, document, cacheData);
6831
+ }
6832
+ function insertLocalStylesheet(content, target) {
6833
+ const cacheData = getCacheData(content);
6834
+ let { roots } = cacheData;
6835
+ if (isUndefined$1(roots)) {
6836
+ roots = cacheData.roots = new WeakSet(); // lazily initialize (not needed for global styles)
6837
+ }
6838
+ else if (roots.has(target)) {
6839
+ // already inserted
6840
+ return;
6841
+ }
6842
+ roots.add(target); // mark inserted
6843
+ doInsertStylesheet(content, target, cacheData);
6844
+ }
6845
+ function insertStylesheet(content, target) {
6846
+ if (isUndefined$1(target)) {
6847
+ // global
6848
+ insertGlobalStylesheet(content);
6849
+ }
6850
+ else {
6851
+ // local
6852
+ insertLocalStylesheet(content, target);
6853
+ }
6854
+ }
6855
+
6856
+ /*
6857
+ * Copyright (c) 2018, salesforce.com, inc.
6858
+ * All rights reserved.
6859
+ * SPDX-License-Identifier: MIT
6860
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6861
+ */
6591
6862
  let getCustomElement;
6592
6863
  let defineCustomElement;
6593
6864
  let HTMLElementConstructor;
@@ -6614,52 +6885,6 @@ function isCustomElementRegistryAvailable() {
6614
6885
  return false;
6615
6886
  }
6616
6887
  }
6617
- function insertConstructableStyleSheet(content, target) {
6618
- // It's important for CSSStyleSheets to be unique based on their content, so that
6619
- // `shadowRoot.adoptedStyleSheets.includes(sheet)` works.
6620
- let styleSheet = styleSheets[content];
6621
- if (isUndefined$1(styleSheet)) {
6622
- styleSheet = new CSSStyleSheet();
6623
- styleSheet.replaceSync(content);
6624
- styleSheets[content] = styleSheet;
6625
- }
6626
- const { adoptedStyleSheets } = target;
6627
- if (!adoptedStyleSheets.includes(styleSheet)) {
6628
- if (supportsMutableAdoptedStyleSheets) {
6629
- // This is only supported in later versions of Chromium:
6630
- // https://chromestatus.com/feature/5638996492288000
6631
- adoptedStyleSheets.push(styleSheet);
6632
- }
6633
- else {
6634
- target.adoptedStyleSheets = [...adoptedStyleSheets, styleSheet];
6635
- }
6636
- }
6637
- }
6638
- function insertStyleElement(content, target) {
6639
- // Avoid inserting duplicate `<style>`s
6640
- let sheets = shadowRootsToStyleSheets.get(target);
6641
- if (isUndefined$1(sheets)) {
6642
- sheets = create(null);
6643
- shadowRootsToStyleSheets.set(target, sheets);
6644
- }
6645
- if (sheets[content]) {
6646
- return;
6647
- }
6648
- sheets[content] = true;
6649
- // This `<style>` may be repeated multiple times in the DOM, so cache it. It's a bit
6650
- // faster to call `cloneNode()` on an existing node than to recreate it every time.
6651
- let elm = styleElements[content];
6652
- if (isUndefined$1(elm)) {
6653
- elm = document.createElement('style');
6654
- elm.type = 'text/css';
6655
- elm.textContent = content;
6656
- styleElements[content] = elm;
6657
- }
6658
- else {
6659
- elm = elm.cloneNode(true);
6660
- }
6661
- target.appendChild(elm);
6662
- }
6663
6888
  if (isCustomElementRegistryAvailable()) {
6664
6889
  getCustomElement = customElements.get.bind(customElements);
6665
6890
  defineCustomElement = customElements.define.bind(customElements);
@@ -6698,9 +6923,6 @@ function setIsHydrating(value) {
6698
6923
  hydrating = value;
6699
6924
  }
6700
6925
  const ssr = false;
6701
- function isHydrating() {
6702
- return hydrating;
6703
- }
6704
6926
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
6705
6927
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
6706
6928
  function createElement$1(tagName, namespace) {
@@ -6815,25 +7037,6 @@ function getLastElementChild(element) {
6815
7037
  function isConnected(node) {
6816
7038
  return node.isConnected;
6817
7039
  }
6818
- function insertGlobalStylesheet(content) {
6819
- if (!isUndefined$1(globalStylesheets[content])) {
6820
- return;
6821
- }
6822
- globalStylesheets[content] = true;
6823
- const elm = document.createElement('style');
6824
- elm.type = 'text/css';
6825
- elm.textContent = content;
6826
- globalStylesheetsParentElement.appendChild(elm);
6827
- }
6828
- function insertStylesheet(content, target) {
6829
- if (supportsConstructableStyleSheets) {
6830
- insertConstructableStyleSheet(content, target);
6831
- }
6832
- else {
6833
- // Fall back to <style> element
6834
- insertStyleElement(content, target);
6835
- }
6836
- }
6837
7040
  function assertInstanceOfHTMLElement(elm, msg) {
6838
7041
  assert.invariant(elm instanceof HTMLElement, msg);
6839
7042
  }
@@ -6867,10 +7070,7 @@ setGetLastElementChild(getLastElementChild);
6867
7070
  setGetProperty(getProperty);
6868
7071
  setHTMLElement(HTMLElementExported);
6869
7072
  setInsert(insert);
6870
- setInsertGlobalStylesheet(insertGlobalStylesheet);
6871
- setInsertStylesheet(insertStylesheet);
6872
7073
  setIsConnected(isConnected);
6873
- setIsHydrating$1(isHydrating);
6874
7074
  setIsNativeShadowDefined(isNativeShadowDefined);
6875
7075
  setIsSyntheticShadowDefined(isSyntheticShadowDefined);
6876
7076
  setNextSibling(nextSibling);
@@ -6885,6 +7085,32 @@ setSetProperty(setProperty);
6885
7085
  setSetText(setText);
6886
7086
  setSsr(ssr);
6887
7087
  setAddEventListener(addEventListener);
7088
+ setInsertStylesheet(insertStylesheet);
7089
+
7090
+ /*
7091
+ * Copyright (c) 2018, salesforce.com, inc.
7092
+ * All rights reserved.
7093
+ * SPDX-License-Identifier: MIT
7094
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7095
+ */
7096
+ // @ts-ignore
7097
+
7098
+ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
7099
+ window.addEventListener('test-dummy-flag', () => {
7100
+ let hasFlag = false;
7101
+
7102
+ if (runtimeFlags.DUMMY_TEST_FLAG) {
7103
+ hasFlag = true;
7104
+ }
7105
+
7106
+ window.dispatchEvent(new CustomEvent('has-dummy-flag', {
7107
+ detail: {
7108
+ package: '@lwc/engine-dom',
7109
+ hasFlag
7110
+ }
7111
+ }));
7112
+ });
7113
+ }
6888
7114
 
6889
7115
  /*
6890
7116
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6910,6 +7136,7 @@ function createVMWithProps(element, Ctor, props) {
6910
7136
  mode: 'open',
6911
7137
  owner: null,
6912
7138
  tagName: element.tagName.toLowerCase(),
7139
+ hydrated: true,
6913
7140
  });
6914
7141
  for (const [key, value] of Object.entries(props)) {
6915
7142
  element[key] = value;
@@ -7112,27 +7339,6 @@ function createElement(sel, options) {
7112
7339
  return element;
7113
7340
  }
7114
7341
 
7115
- /*
7116
- * Copyright (c) 2018, salesforce.com, inc.
7117
- * All rights reserved.
7118
- * SPDX-License-Identifier: MIT
7119
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7120
- */
7121
- /**
7122
- * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
7123
- * This API is subject to change or being removed.
7124
- */
7125
- function getComponentConstructor(elm) {
7126
- let ctor = null;
7127
- if (elm instanceof HTMLElement) {
7128
- const vm = getAssociatedVMIfPresent(elm);
7129
- if (!isUndefined$1(vm)) {
7130
- ctor = vm.def.ctor;
7131
- }
7132
- }
7133
- return ctor;
7134
- }
7135
-
7136
7342
  /*
7137
7343
  * Copyright (c) 2018, salesforce.com, inc.
7138
7344
  * All rights reserved.
@@ -7201,6 +7407,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
7201
7407
  });
7202
7408
  freeze(LightningElement);
7203
7409
  seal(LightningElement.prototype);
7204
- /* version: 2.13.1 */
7410
+ /* version: 2.13.4 */
7205
7411
 
7206
- export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
7412
+ export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };