lwc 2.13.2 → 2.14.0

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 +339 -113
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +339 -112
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +185 -107
  5. package/dist/engine-dom/iife/es5/engine-dom.js +7560 -5747
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +5942 -4572
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +339 -112
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +185 -107
  11. package/dist/engine-dom/umd/es5/engine-dom.js +7560 -5747
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +5942 -4572
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +176 -36
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +176 -37
  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.2";
301
+ const LWC_VERSION = "2.14.0";
302
302
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
303
- /** version: 2.13.2 */
303
+ /** version: 2.14.0 */
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.2 */
457
+ /** version: 2.14.0 */
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;
@@ -5349,7 +5395,8 @@ function createVM(elm, ctor, options) {
5349
5395
  const {
5350
5396
  mode,
5351
5397
  owner,
5352
- tagName
5398
+ tagName,
5399
+ hydrated
5353
5400
  } = options;
5354
5401
  const def = getComponentInternalDef(ctor);
5355
5402
  const vm = {
@@ -5372,6 +5419,7 @@ function createVM(elm, ctor, options) {
5372
5419
  cmpSlots: create(null),
5373
5420
  oar: create(null),
5374
5421
  cmpTemplate: null,
5422
+ hydrated: Boolean(hydrated),
5375
5423
  renderMode: def.renderMode,
5376
5424
  shadowMode: computeShadowMode(def, owner),
5377
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,
@@ -6346,6 +6394,7 @@ function hydrateCustomElement(elm, vnode) {
6346
6394
  mode,
6347
6395
  owner,
6348
6396
  tagName: sel,
6397
+ hydrated: true,
6349
6398
  });
6350
6399
  vnode.elm = elm;
6351
6400
  vnode.vm = vm;
@@ -6540,6 +6589,105 @@ function setHooks(hooks) {
6540
6589
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6541
6590
  }
6542
6591
 
6592
+ /*
6593
+ * Copyright (c) 2018, salesforce.com, inc.
6594
+ * All rights reserved.
6595
+ * SPDX-License-Identifier: MIT
6596
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6597
+ */
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
+ });
6673
+ }
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
+ }
6689
+ }
6690
+
6543
6691
  /*
6544
6692
  * Copyright (c) 2018, salesforce.com, inc.
6545
6693
  * All rights reserved.
@@ -6562,7 +6710,7 @@ function getComponentConstructor(elm) {
6562
6710
  }
6563
6711
  return ctor;
6564
6712
  }
6565
- /* version: 2.13.2 */
6713
+ /* version: 2.14.0 */
6566
6714
 
6567
6715
  /*
6568
6716
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6570,25 +6718,147 @@ function getComponentConstructor(elm) {
6570
6718
  * SPDX-License-Identifier: MIT
6571
6719
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6572
6720
  */
6573
- const globalStylesheets = create(null);
6721
+ //
6722
+ // Feature detection
6723
+ //
6724
+ // This check for constructable style sheets is similar to Fast's:
6725
+ // https://github.com/microsoft/fast/blob/d49d1ec/packages/web-components/fast-element/src/dom.ts#L51-L53
6726
+ // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
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 &&
6733
+ getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
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
+ //
6574
6740
  if (process.env.NODE_ENV === 'development') {
6575
6741
  // @ts-ignore
6576
6742
  window.__lwcResetGlobalStylesheets = () => {
6577
- for (const key of Object.keys(globalStylesheets)) {
6578
- delete globalStylesheets[key];
6579
- }
6743
+ stylesheetCache.clear();
6580
6744
  };
6581
6745
  }
6582
- const globalStylesheetsParentElement = document.head || document.body || document;
6583
- // This check for constructable stylesheets is similar to Fast's:
6584
- // https://github.com/microsoft/fast/blob/d49d1ec/packages/web-components/fast-element/src/dom.ts#L51-L53
6585
- // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
6586
- const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
6587
- const supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets &&
6588
- getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
6589
- const styleElements = create(null);
6590
- const styleSheets = create(null);
6591
- const shadowRootsToStyleSheets = new WeakMap();
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
+ */
6592
6862
  let getCustomElement;
6593
6863
  let defineCustomElement;
6594
6864
  let HTMLElementConstructor;
@@ -6615,52 +6885,6 @@ function isCustomElementRegistryAvailable() {
6615
6885
  return false;
6616
6886
  }
6617
6887
  }
6618
- function insertConstructableStyleSheet(content, target) {
6619
- // It's important for CSSStyleSheets to be unique based on their content, so that
6620
- // `shadowRoot.adoptedStyleSheets.includes(sheet)` works.
6621
- let styleSheet = styleSheets[content];
6622
- if (isUndefined$1(styleSheet)) {
6623
- styleSheet = new CSSStyleSheet();
6624
- styleSheet.replaceSync(content);
6625
- styleSheets[content] = styleSheet;
6626
- }
6627
- const { adoptedStyleSheets } = target;
6628
- if (!adoptedStyleSheets.includes(styleSheet)) {
6629
- if (supportsMutableAdoptedStyleSheets) {
6630
- // This is only supported in later versions of Chromium:
6631
- // https://chromestatus.com/feature/5638996492288000
6632
- adoptedStyleSheets.push(styleSheet);
6633
- }
6634
- else {
6635
- target.adoptedStyleSheets = [...adoptedStyleSheets, styleSheet];
6636
- }
6637
- }
6638
- }
6639
- function insertStyleElement(content, target) {
6640
- // Avoid inserting duplicate `<style>`s
6641
- let sheets = shadowRootsToStyleSheets.get(target);
6642
- if (isUndefined$1(sheets)) {
6643
- sheets = create(null);
6644
- shadowRootsToStyleSheets.set(target, sheets);
6645
- }
6646
- if (sheets[content]) {
6647
- return;
6648
- }
6649
- sheets[content] = true;
6650
- // This `<style>` may be repeated multiple times in the DOM, so cache it. It's a bit
6651
- // faster to call `cloneNode()` on an existing node than to recreate it every time.
6652
- let elm = styleElements[content];
6653
- if (isUndefined$1(elm)) {
6654
- elm = document.createElement('style');
6655
- elm.type = 'text/css';
6656
- elm.textContent = content;
6657
- styleElements[content] = elm;
6658
- }
6659
- else {
6660
- elm = elm.cloneNode(true);
6661
- }
6662
- target.appendChild(elm);
6663
- }
6664
6888
  if (isCustomElementRegistryAvailable()) {
6665
6889
  getCustomElement = customElements.get.bind(customElements);
6666
6890
  defineCustomElement = customElements.define.bind(customElements);
@@ -6699,9 +6923,6 @@ function setIsHydrating(value) {
6699
6923
  hydrating = value;
6700
6924
  }
6701
6925
  const ssr = false;
6702
- function isHydrating() {
6703
- return hydrating;
6704
- }
6705
6926
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
6706
6927
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
6707
6928
  function createElement$1(tagName, namespace) {
@@ -6816,25 +7037,6 @@ function getLastElementChild(element) {
6816
7037
  function isConnected(node) {
6817
7038
  return node.isConnected;
6818
7039
  }
6819
- function insertGlobalStylesheet(content) {
6820
- if (!isUndefined$1(globalStylesheets[content])) {
6821
- return;
6822
- }
6823
- globalStylesheets[content] = true;
6824
- const elm = document.createElement('style');
6825
- elm.type = 'text/css';
6826
- elm.textContent = content;
6827
- globalStylesheetsParentElement.appendChild(elm);
6828
- }
6829
- function insertStylesheet(content, target) {
6830
- if (supportsConstructableStyleSheets) {
6831
- insertConstructableStyleSheet(content, target);
6832
- }
6833
- else {
6834
- // Fall back to <style> element
6835
- insertStyleElement(content, target);
6836
- }
6837
- }
6838
7040
  function assertInstanceOfHTMLElement(elm, msg) {
6839
7041
  assert.invariant(elm instanceof HTMLElement, msg);
6840
7042
  }
@@ -6868,10 +7070,7 @@ setGetLastElementChild(getLastElementChild);
6868
7070
  setGetProperty(getProperty);
6869
7071
  setHTMLElement(HTMLElementExported);
6870
7072
  setInsert(insert);
6871
- setInsertGlobalStylesheet(insertGlobalStylesheet);
6872
- setInsertStylesheet(insertStylesheet);
6873
7073
  setIsConnected(isConnected);
6874
- setIsHydrating$1(isHydrating);
6875
7074
  setIsNativeShadowDefined(isNativeShadowDefined);
6876
7075
  setIsSyntheticShadowDefined(isSyntheticShadowDefined);
6877
7076
  setNextSibling(nextSibling);
@@ -6886,6 +7085,32 @@ setSetProperty(setProperty);
6886
7085
  setSetText(setText);
6887
7086
  setSsr(ssr);
6888
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
+ }
6889
7114
 
6890
7115
  /*
6891
7116
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6911,6 +7136,7 @@ function createVMWithProps(element, Ctor, props) {
6911
7136
  mode: 'open',
6912
7137
  owner: null,
6913
7138
  tagName: element.tagName.toLowerCase(),
7139
+ hydrated: true,
6914
7140
  });
6915
7141
  for (const [key, value] of Object.entries(props)) {
6916
7142
  element[key] = value;
@@ -7181,6 +7407,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
7181
7407
  });
7182
7408
  freeze(LightningElement);
7183
7409
  seal(LightningElement.prototype);
7184
- /* version: 2.13.2 */
7410
+ /* version: 2.14.0 */
7185
7411
 
7186
- 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 };