lwc 2.14.0 → 2.15.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 (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +637 -554
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +639 -553
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +574 -497
  5. package/dist/engine-dom/iife/es5/engine-dom.js +807 -694
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +729 -634
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +639 -553
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +574 -497
  11. package/dist/engine-dom/umd/es5/engine-dom.js +807 -694
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +729 -634
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +494 -473
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +492 -474
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +24 -4
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +24 -4
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +24 -4
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +29 -3
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +29 -3
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +24 -4
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +24 -4
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +29 -3
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +29 -3
  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_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. package/package.json +7 -7
@@ -233,6 +233,7 @@ var LWC = (function (exports) {
233
233
  */
234
234
  const KEY__IS_NATIVE_SHADOW_ROOT_DEFINED = '$isNativeShadowRootDefined$';
235
235
  const KEY__SHADOW_RESOLVER = '$shadowResolver$';
236
+ const KEY__SHADOW_STATIC = '$shadowStaticNode$';
236
237
  const KEY__SHADOW_TOKEN = '$shadowToken$';
237
238
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
238
239
  const KEY__SCOPED_CSS = '$scoped$';
@@ -301,9 +302,9 @@ var LWC = (function (exports) {
301
302
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
302
303
  */
303
304
  // Increment whenever the LWC template compiler changes
304
- const LWC_VERSION = "2.14.0";
305
+ const LWC_VERSION = "2.15.0";
305
306
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
306
- /** version: 2.14.0 */
307
+ /** version: 2.15.0 */
307
308
 
308
309
  /*
309
310
  * Copyright (c) 2018, salesforce.com, inc.
@@ -457,7 +458,32 @@ var LWC = (function (exports) {
457
458
  setFeatureFlag(name, value);
458
459
  }
459
460
  }
460
- /** version: 2.14.0 */
461
+ /** version: 2.15.0 */
462
+
463
+ /*
464
+ * Copyright (c) 2018, salesforce.com, inc.
465
+ * All rights reserved.
466
+ * SPDX-License-Identifier: MIT
467
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
468
+ */
469
+ // @ts-ignore
470
+
471
+ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
472
+ window.addEventListener('test-dummy-flag', () => {
473
+ let hasFlag = false;
474
+
475
+ if (runtimeFlags.DUMMY_TEST_FLAG) {
476
+ hasFlag = true;
477
+ }
478
+
479
+ window.dispatchEvent(new CustomEvent('has-dummy-flag', {
480
+ detail: {
481
+ package: '@lwc/engine-dom',
482
+ hasFlag
483
+ }
484
+ }));
485
+ });
486
+ }
461
487
 
462
488
  /* proxy-compat-disable */
463
489
 
@@ -567,162 +593,6 @@ var LWC = (function (exports) {
567
593
  return list;
568
594
  }
569
595
 
570
- //
571
- // Primitives
572
- //
573
- let ssr$1;
574
- function setSsr(ssrImpl) {
575
- ssr$1 = ssrImpl;
576
- }
577
- let isNativeShadowDefined$1;
578
- function setIsNativeShadowDefined(isNativeShadowDefinedImpl) {
579
- isNativeShadowDefined$1 = isNativeShadowDefinedImpl;
580
- }
581
- let isSyntheticShadowDefined$1;
582
- function setIsSyntheticShadowDefined(isSyntheticShadowDefinedImpl) {
583
- isSyntheticShadowDefined$1 = isSyntheticShadowDefinedImpl;
584
- }
585
- let HTMLElementExported$1;
586
- function setHTMLElement(HTMLElementImpl) {
587
- HTMLElementExported$1 = HTMLElementImpl;
588
- }
589
- let insert$1;
590
- function setInsert(insertImpl) {
591
- insert$1 = insertImpl;
592
- }
593
- let remove$1;
594
- function setRemove(removeImpl) {
595
- remove$1 = removeImpl;
596
- }
597
- let createElement$2;
598
- function setCreateElement(createElementImpl) {
599
- createElement$2 = createElementImpl;
600
- }
601
- let createText$1;
602
- function setCreateText(createTextImpl) {
603
- createText$1 = createTextImpl;
604
- }
605
- let createComment$1;
606
- function setCreateComment(createCommentImpl) {
607
- createComment$1 = createCommentImpl;
608
- }
609
- let nextSibling$1;
610
- function setNextSibling(nextSiblingImpl) {
611
- nextSibling$1 = nextSiblingImpl;
612
- }
613
- let attachShadow$1;
614
- function setAttachShadow(attachShadowImpl) {
615
- attachShadow$1 = attachShadowImpl;
616
- }
617
- let getProperty$1;
618
- function setGetProperty(getPropertyImpl) {
619
- getProperty$1 = getPropertyImpl;
620
- }
621
- let setProperty$1;
622
- function setSetProperty(setPropertyImpl) {
623
- setProperty$1 = setPropertyImpl;
624
- }
625
- let setText$1;
626
- function setSetText(setTextImpl) {
627
- setText$1 = setTextImpl;
628
- }
629
- let getAttribute$1;
630
- function setGetAttribute(getAttributeImpl) {
631
- getAttribute$1 = getAttributeImpl;
632
- }
633
- let setAttribute$1;
634
- function setSetAttribute(setAttributeImpl) {
635
- setAttribute$1 = setAttributeImpl;
636
- }
637
- let removeAttribute$1;
638
- function setRemoveAttribute(removeAttributeImpl) {
639
- removeAttribute$1 = removeAttributeImpl;
640
- }
641
- let addEventListener$1;
642
- function setAddEventListener(addEventListenerImpl) {
643
- addEventListener$1 = addEventListenerImpl;
644
- }
645
- let removeEventListener$1;
646
- function setRemoveEventListener(removeEventListenerImpl) {
647
- removeEventListener$1 = removeEventListenerImpl;
648
- }
649
- let dispatchEvent$1;
650
- function setDispatchEvent(dispatchEventImpl) {
651
- dispatchEvent$1 = dispatchEventImpl;
652
- }
653
- let getClassList$1;
654
- function setGetClassList(getClassListImpl) {
655
- getClassList$1 = getClassListImpl;
656
- }
657
- let setCSSStyleProperty$1;
658
- function setSetCSSStyleProperty(setCSSStylePropertyImpl) {
659
- setCSSStyleProperty$1 = setCSSStylePropertyImpl;
660
- }
661
- let getBoundingClientRect$1;
662
- function setGetBoundingClientRect(getBoundingClientRectImpl) {
663
- getBoundingClientRect$1 = getBoundingClientRectImpl;
664
- }
665
- let querySelector$1;
666
- function setQuerySelector(querySelectorImpl) {
667
- querySelector$1 = querySelectorImpl;
668
- }
669
- let querySelectorAll$1;
670
- function setQuerySelectorAll(querySelectorAllImpl) {
671
- querySelectorAll$1 = querySelectorAllImpl;
672
- }
673
- let getElementsByTagName$1;
674
- function setGetElementsByTagName(getElementsByTagNameImpl) {
675
- getElementsByTagName$1 = getElementsByTagNameImpl;
676
- }
677
- let getElementsByClassName$1;
678
- function setGetElementsByClassName(getElementsByClassNameImpl) {
679
- getElementsByClassName$1 = getElementsByClassNameImpl;
680
- }
681
- let getChildren$1;
682
- function setGetChildren(getChildrenImpl) {
683
- getChildren$1 = getChildrenImpl;
684
- }
685
- let getChildNodes$1;
686
- function setGetChildNodes(getChildNodesImpl) {
687
- getChildNodes$1 = getChildNodesImpl;
688
- }
689
- let getFirstChild$1;
690
- function setGetFirstChild(getFirstChildImpl) {
691
- getFirstChild$1 = getFirstChildImpl;
692
- }
693
- let getFirstElementChild$1;
694
- function setGetFirstElementChild(getFirstElementChildImpl) {
695
- getFirstElementChild$1 = getFirstElementChildImpl;
696
- }
697
- let getLastChild$1;
698
- function setGetLastChild(getLastChildImpl) {
699
- getLastChild$1 = getLastChildImpl;
700
- }
701
- let getLastElementChild$1;
702
- function setGetLastElementChild(getLastElementChildImpl) {
703
- getLastElementChild$1 = getLastElementChildImpl;
704
- }
705
- let isConnected$1;
706
- function setIsConnected(isConnectedImpl) {
707
- isConnected$1 = isConnectedImpl;
708
- }
709
- let insertStylesheet$1;
710
- function setInsertStylesheet(insertStylesheetImpl) {
711
- insertStylesheet$1 = insertStylesheetImpl;
712
- }
713
- let assertInstanceOfHTMLElement$1;
714
- function setAssertInstanceOfHTMLElement(assertInstanceOfHTMLElementImpl) {
715
- assertInstanceOfHTMLElement$1 = assertInstanceOfHTMLElementImpl;
716
- }
717
- let defineCustomElement$1;
718
- function setDefineCustomElement(defineCustomElementImpl) {
719
- defineCustomElement$1 = defineCustomElementImpl;
720
- }
721
- let getCustomElement$1;
722
- function setGetCustomElement(getCustomElementImpl) {
723
- getCustomElement$1 = getCustomElementImpl;
724
- }
725
-
726
596
  /*
727
597
  * Copyright (c) 2019, salesforce.com, inc.
728
598
  * All rights reserved.
@@ -2027,7 +1897,8 @@ var LWC = (function (exports) {
2027
1897
  const { def, elm } = vm;
2028
1898
  const { bridge } = def;
2029
1899
  if (process.env.NODE_ENV !== 'production') {
2030
- assertInstanceOfHTMLElement$1(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
1900
+ const { assertInstanceOfHTMLElement } = vm.renderer;
1901
+ assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
2031
1902
  }
2032
1903
  const component = this;
2033
1904
  setPrototypeOf(elm, bridge.prototype);
@@ -2061,8 +1932,8 @@ var LWC = (function (exports) {
2061
1932
  return this;
2062
1933
  };
2063
1934
  function doAttachShadow(vm) {
2064
- const { elm, mode, shadowMode, def: { ctor }, } = vm;
2065
- const shadowRoot = attachShadow$1(elm, {
1935
+ const { elm, mode, shadowMode, def: { ctor }, renderer: { attachShadow }, } = vm;
1936
+ const shadowRoot = attachShadow(elm, {
2066
1937
  [KEY__SYNTHETIC_MODE]: shadowMode === 1 /* Synthetic */,
2067
1938
  delegatesFocus: Boolean(ctor.delegatesFocus),
2068
1939
  mode,
@@ -2083,12 +1954,13 @@ var LWC = (function (exports) {
2083
1954
  LightningElement.prototype = {
2084
1955
  constructor: LightningElement,
2085
1956
  dispatchEvent(event) {
2086
- const { elm } = getAssociatedVM(this);
2087
- return dispatchEvent$1(elm, event);
1957
+ const vm = getAssociatedVM(this);
1958
+ const { elm, renderer: { dispatchEvent }, } = vm;
1959
+ return dispatchEvent(elm, event);
2088
1960
  },
2089
1961
  addEventListener(type, listener, options) {
2090
1962
  const vm = getAssociatedVM(this);
2091
- const { elm } = vm;
1963
+ const { elm, renderer: { addEventListener }, } = vm;
2092
1964
  if (process.env.NODE_ENV !== 'production') {
2093
1965
  const vmBeingRendered = getVMBeingRendered();
2094
1966
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
@@ -2096,83 +1968,91 @@ var LWC = (function (exports) {
2096
1968
  assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
2097
1969
  }
2098
1970
  const wrappedListener = getWrappedComponentsListener(vm, listener);
2099
- addEventListener$1(elm, type, wrappedListener, options);
1971
+ addEventListener(elm, type, wrappedListener, options);
2100
1972
  },
2101
1973
  removeEventListener(type, listener, options) {
2102
1974
  const vm = getAssociatedVM(this);
2103
- const { elm } = vm;
1975
+ const { elm, renderer: { removeEventListener }, } = vm;
2104
1976
  const wrappedListener = getWrappedComponentsListener(vm, listener);
2105
- removeEventListener$1(elm, type, wrappedListener, options);
1977
+ removeEventListener(elm, type, wrappedListener, options);
2106
1978
  },
2107
1979
  hasAttribute(name) {
2108
- const { elm } = getAssociatedVM(this);
2109
- return !isNull(getAttribute$1(elm, name));
1980
+ const vm = getAssociatedVM(this);
1981
+ const { elm, renderer: { getAttribute }, } = vm;
1982
+ return !isNull(getAttribute(elm, name));
2110
1983
  },
2111
1984
  hasAttributeNS(namespace, name) {
2112
- const { elm } = getAssociatedVM(this);
2113
- return !isNull(getAttribute$1(elm, name, namespace));
1985
+ const vm = getAssociatedVM(this);
1986
+ const { elm, renderer: { getAttribute }, } = vm;
1987
+ return !isNull(getAttribute(elm, name, namespace));
2114
1988
  },
2115
1989
  removeAttribute(name) {
2116
- const { elm } = getAssociatedVM(this);
1990
+ const vm = getAssociatedVM(this);
1991
+ const { elm, renderer: { removeAttribute }, } = vm;
2117
1992
  unlockAttribute(elm, name);
2118
- removeAttribute$1(elm, name);
1993
+ removeAttribute(elm, name);
2119
1994
  lockAttribute();
2120
1995
  },
2121
1996
  removeAttributeNS(namespace, name) {
2122
- const { elm } = getAssociatedVM(this);
1997
+ const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
2123
1998
  unlockAttribute(elm, name);
2124
- removeAttribute$1(elm, name, namespace);
1999
+ removeAttribute(elm, name, namespace);
2125
2000
  lockAttribute();
2126
2001
  },
2127
2002
  getAttribute(name) {
2128
- const { elm } = getAssociatedVM(this);
2129
- return getAttribute$1(elm, name);
2003
+ const vm = getAssociatedVM(this);
2004
+ const { elm } = vm;
2005
+ const { getAttribute } = vm.renderer;
2006
+ return getAttribute(elm, name);
2130
2007
  },
2131
2008
  getAttributeNS(namespace, name) {
2132
- const { elm } = getAssociatedVM(this);
2133
- return getAttribute$1(elm, name, namespace);
2009
+ const vm = getAssociatedVM(this);
2010
+ const { elm } = vm;
2011
+ const { getAttribute } = vm.renderer;
2012
+ return getAttribute(elm, name, namespace);
2134
2013
  },
2135
2014
  setAttribute(name, value) {
2136
2015
  const vm = getAssociatedVM(this);
2137
- const { elm } = vm;
2016
+ const { elm, renderer: { setAttribute }, } = vm;
2138
2017
  if (process.env.NODE_ENV !== 'production') {
2139
2018
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2140
2019
  }
2141
2020
  unlockAttribute(elm, name);
2142
- setAttribute$1(elm, name, value);
2021
+ setAttribute(elm, name, value);
2143
2022
  lockAttribute();
2144
2023
  },
2145
2024
  setAttributeNS(namespace, name, value) {
2146
2025
  const vm = getAssociatedVM(this);
2147
- const { elm } = vm;
2026
+ const { elm, renderer: { setAttribute }, } = vm;
2148
2027
  if (process.env.NODE_ENV !== 'production') {
2149
2028
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2150
2029
  }
2151
2030
  unlockAttribute(elm, name);
2152
- setAttribute$1(elm, name, value, namespace);
2031
+ setAttribute(elm, name, value, namespace);
2153
2032
  lockAttribute();
2154
2033
  },
2155
2034
  getBoundingClientRect() {
2156
2035
  const vm = getAssociatedVM(this);
2157
- const { elm } = vm;
2036
+ const { elm, renderer: { getBoundingClientRect }, } = vm;
2158
2037
  if (process.env.NODE_ENV !== 'production') {
2159
2038
  warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
2160
2039
  }
2161
- return getBoundingClientRect$1(elm);
2040
+ return getBoundingClientRect(elm);
2162
2041
  },
2163
2042
  get isConnected() {
2164
- const { elm } = getAssociatedVM(this);
2165
- return isConnected$1(elm);
2043
+ const vm = getAssociatedVM(this);
2044
+ const { elm, renderer: { isConnected }, } = vm;
2045
+ return isConnected(elm);
2166
2046
  },
2167
2047
  get classList() {
2168
2048
  const vm = getAssociatedVM(this);
2169
- const { elm } = vm;
2049
+ const { elm, renderer: { getClassList }, } = vm;
2170
2050
  if (process.env.NODE_ENV !== 'production') {
2171
2051
  // TODO [#1290]: this still fails in dev but works in production, eventually, we should
2172
2052
  // just throw in all modes
2173
2053
  assert.isFalse(isBeingConstructed(vm), `Failed to construct ${vm}: The result must not have attributes. Adding or tampering with classname in constructor is not allowed in a web component, use connectedCallback() instead.`);
2174
2054
  }
2175
- return getClassList$1(elm);
2055
+ return getClassList(elm);
2176
2056
  },
2177
2057
  get template() {
2178
2058
  const vm = getAssociatedVM(this);
@@ -2188,6 +2068,54 @@ var LWC = (function (exports) {
2188
2068
  // Authors should rely on this.template instead.
2189
2069
  return null;
2190
2070
  },
2071
+ get children() {
2072
+ const vm = getAssociatedVM(this);
2073
+ const renderer = vm.renderer;
2074
+ if (process.env.NODE_ENV !== 'production') {
2075
+ warnIfInvokedDuringConstruction(vm, 'children');
2076
+ }
2077
+ return renderer.getChildren(vm.elm);
2078
+ },
2079
+ get childNodes() {
2080
+ const vm = getAssociatedVM(this);
2081
+ const renderer = vm.renderer;
2082
+ if (process.env.NODE_ENV !== 'production') {
2083
+ warnIfInvokedDuringConstruction(vm, 'childNodes');
2084
+ }
2085
+ return renderer.getChildNodes(vm.elm);
2086
+ },
2087
+ get firstChild() {
2088
+ const vm = getAssociatedVM(this);
2089
+ const renderer = vm.renderer;
2090
+ if (process.env.NODE_ENV !== 'production') {
2091
+ warnIfInvokedDuringConstruction(vm, 'firstChild');
2092
+ }
2093
+ return renderer.getFirstChild(vm.elm);
2094
+ },
2095
+ get firstElementChild() {
2096
+ const vm = getAssociatedVM(this);
2097
+ const renderer = vm.renderer;
2098
+ if (process.env.NODE_ENV !== 'production') {
2099
+ warnIfInvokedDuringConstruction(vm, 'firstElementChild');
2100
+ }
2101
+ return renderer.getFirstElementChild(vm.elm);
2102
+ },
2103
+ get lastChild() {
2104
+ const vm = getAssociatedVM(this);
2105
+ const renderer = vm.renderer;
2106
+ if (process.env.NODE_ENV !== 'production') {
2107
+ warnIfInvokedDuringConstruction(vm, 'lastChild');
2108
+ }
2109
+ return renderer.getLastChild(vm.elm);
2110
+ },
2111
+ get lastElementChild() {
2112
+ const vm = getAssociatedVM(this);
2113
+ const renderer = vm.renderer;
2114
+ if (process.env.NODE_ENV !== 'production') {
2115
+ warnIfInvokedDuringConstruction(vm, 'lastElementChild');
2116
+ }
2117
+ return renderer.getLastElementChild(vm.elm);
2118
+ },
2191
2119
  render() {
2192
2120
  const vm = getAssociatedVM(this);
2193
2121
  return vm.def.template;
@@ -2198,76 +2126,22 @@ var LWC = (function (exports) {
2198
2126
  },
2199
2127
  };
2200
2128
  const queryAndChildGetterDescriptors = create(null);
2201
- // The reason we don't just call `import * as renderer from '../renderer'` here is that the bundle size
2202
- // is smaller if we reference each function individually. Otherwise Rollup will create one big frozen
2203
- // object representing the renderer, with a lot of methods we don't actually need.
2204
- const childGetters = [
2205
- 'children',
2206
- 'childNodes',
2207
- 'firstChild',
2208
- 'firstElementChild',
2209
- 'lastChild',
2210
- 'lastElementChild',
2211
- ];
2212
- function getChildGetter(methodName) {
2213
- switch (methodName) {
2214
- case 'children':
2215
- return getChildren$1;
2216
- case 'childNodes':
2217
- return getChildNodes$1;
2218
- case 'firstChild':
2219
- return getFirstChild$1;
2220
- case 'firstElementChild':
2221
- return getFirstElementChild$1;
2222
- case 'lastChild':
2223
- return getLastChild$1;
2224
- case 'lastElementChild':
2225
- return getLastElementChild$1;
2226
- }
2227
- }
2228
- // Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
2229
- for (const childGetter of childGetters) {
2230
- queryAndChildGetterDescriptors[childGetter] = {
2231
- get() {
2232
- const vm = getAssociatedVM(this);
2233
- const { elm } = vm;
2234
- if (process.env.NODE_ENV !== 'production') {
2235
- warnIfInvokedDuringConstruction(vm, childGetter);
2236
- }
2237
- return getChildGetter(childGetter)(elm);
2238
- },
2239
- configurable: true,
2240
- enumerable: true,
2241
- };
2242
- }
2243
2129
  const queryMethods = [
2244
2130
  'getElementsByClassName',
2245
2131
  'getElementsByTagName',
2246
2132
  'querySelector',
2247
2133
  'querySelectorAll',
2248
2134
  ];
2249
- function getQueryMethod(methodName) {
2250
- switch (methodName) {
2251
- case 'getElementsByClassName':
2252
- return getElementsByClassName$1;
2253
- case 'getElementsByTagName':
2254
- return getElementsByTagName$1;
2255
- case 'querySelector':
2256
- return querySelector$1;
2257
- case 'querySelectorAll':
2258
- return querySelectorAll$1;
2259
- }
2260
- }
2261
2135
  // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
2262
2136
  for (const queryMethod of queryMethods) {
2263
2137
  queryAndChildGetterDescriptors[queryMethod] = {
2264
2138
  value(arg) {
2265
2139
  const vm = getAssociatedVM(this);
2266
- const { elm } = vm;
2140
+ const { elm, renderer } = vm;
2267
2141
  if (process.env.NODE_ENV !== 'production') {
2268
2142
  warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
2269
2143
  }
2270
- return getQueryMethod(queryMethod)(elm, arg);
2144
+ return renderer[queryMethod](elm, arg);
2271
2145
  },
2272
2146
  configurable: true,
2273
2147
  enumerable: true,
@@ -2772,7 +2646,8 @@ var LWC = (function (exports) {
2772
2646
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2773
2647
  */
2774
2648
  let warned = false;
2775
- if (process.env.NODE_ENV === 'development') {
2649
+ // @ts-ignore
2650
+ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
2776
2651
  // @ts-ignore
2777
2652
  window.__lwcResetWarnedOnVersionMismatch = () => {
2778
2653
  warned = false;
@@ -3490,12 +3365,13 @@ var LWC = (function (exports) {
3490
3365
  * SPDX-License-Identifier: MIT
3491
3366
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3492
3367
  */
3493
- function getUpgradableConstructor(tagName) {
3368
+ function getUpgradableConstructor(tagName, renderer) {
3369
+ const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
3494
3370
  // Should never get a tag with upper case letter at this point, the compiler should
3495
3371
  // produce only tags with lowercase letters
3496
3372
  // But, for backwards compatibility, we will lower case the tagName
3497
3373
  tagName = tagName.toLowerCase();
3498
- let CE = getCustomElement$1(tagName);
3374
+ let CE = getCustomElement(tagName);
3499
3375
  if (!isUndefined$1(CE)) {
3500
3376
  return CE;
3501
3377
  }
@@ -3503,7 +3379,7 @@ var LWC = (function (exports) {
3503
3379
  * LWC Upgradable Element reference to an element that was created
3504
3380
  * via the scoped registry mechanism, and that is ready to be upgraded.
3505
3381
  */
3506
- CE = class LWCUpgradableElement extends HTMLElementExported$1 {
3382
+ CE = class LWCUpgradableElement extends RendererHTMLElement {
3507
3383
  constructor(upgradeCallback) {
3508
3384
  super();
3509
3385
  if (isFunction$1(upgradeCallback)) {
@@ -3511,7 +3387,7 @@ var LWC = (function (exports) {
3511
3387
  }
3512
3388
  }
3513
3389
  };
3514
- defineCustomElement$1(tagName, CE);
3390
+ defineCustomElement(tagName, CE);
3515
3391
  return CE;
3516
3392
  }
3517
3393
 
@@ -3536,7 +3412,7 @@ var LWC = (function (exports) {
3536
3412
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3537
3413
  */
3538
3414
  const ColonCharCode = 58;
3539
- function patchAttributes(oldVnode, vnode) {
3415
+ function patchAttributes(oldVnode, vnode, renderer) {
3540
3416
  const { attrs } = vnode.data;
3541
3417
  if (isUndefined$1(attrs)) {
3542
3418
  return;
@@ -3546,6 +3422,7 @@ var LWC = (function (exports) {
3546
3422
  return;
3547
3423
  }
3548
3424
  const { elm } = vnode;
3425
+ const { setAttribute, removeAttribute } = renderer;
3549
3426
  for (const key in attrs) {
3550
3427
  const cur = attrs[key];
3551
3428
  const old = oldAttrs[key];
@@ -3553,17 +3430,17 @@ var LWC = (function (exports) {
3553
3430
  unlockAttribute(elm, key);
3554
3431
  if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
3555
3432
  // Assume xml namespace
3556
- setAttribute$1(elm, key, cur, XML_NAMESPACE);
3433
+ setAttribute(elm, key, cur, XML_NAMESPACE);
3557
3434
  }
3558
3435
  else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
3559
3436
  // Assume xlink namespace
3560
- setAttribute$1(elm, key, cur, XLINK_NAMESPACE);
3437
+ setAttribute(elm, key, cur, XLINK_NAMESPACE);
3561
3438
  }
3562
3439
  else if (isNull(cur) || isUndefined$1(cur)) {
3563
- removeAttribute$1(elm, key);
3440
+ removeAttribute(elm, key);
3564
3441
  }
3565
3442
  else {
3566
- setAttribute$1(elm, key, cur);
3443
+ setAttribute(elm, key, cur);
3567
3444
  }
3568
3445
  lockAttribute();
3569
3446
  }
@@ -3581,7 +3458,7 @@ var LWC = (function (exports) {
3581
3458
  // instead of relying on internally tracked values.
3582
3459
  return sel === 'input' && (key === 'value' || key === 'checked');
3583
3460
  }
3584
- function patchProps(oldVnode, vnode) {
3461
+ function patchProps(oldVnode, vnode, renderer) {
3585
3462
  const { props } = vnode.data;
3586
3463
  if (isUndefined$1(props)) {
3587
3464
  return;
@@ -3592,13 +3469,14 @@ var LWC = (function (exports) {
3592
3469
  }
3593
3470
  const isFirstPatch = isNull(oldVnode);
3594
3471
  const { elm, sel } = vnode;
3472
+ const { getProperty, setProperty } = renderer;
3595
3473
  for (const key in props) {
3596
3474
  const cur = props[key];
3597
3475
  // Set the property if it's the first time is is patched or if the previous property is
3598
3476
  // different than the one previously set.
3599
3477
  if (isFirstPatch ||
3600
- cur !== (isLiveBindingProp(sel, key) ? getProperty$1(elm, key) : oldProps[key])) {
3601
- setProperty$1(elm, key, cur);
3478
+ cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
3479
+ setProperty(elm, key, cur);
3602
3480
  }
3603
3481
  }
3604
3482
  }
@@ -3643,13 +3521,14 @@ var LWC = (function (exports) {
3643
3521
  }
3644
3522
  return map;
3645
3523
  }
3646
- function patchClassAttribute(oldVnode, vnode) {
3524
+ function patchClassAttribute(oldVnode, vnode, renderer) {
3647
3525
  const { elm, data: { className: newClass }, } = vnode;
3648
3526
  const oldClass = isNull(oldVnode) ? undefined : oldVnode.data.className;
3649
3527
  if (oldClass === newClass) {
3650
3528
  return;
3651
3529
  }
3652
- const classList = getClassList$1(elm);
3530
+ const { getClassList } = renderer;
3531
+ const classList = getClassList(elm);
3653
3532
  const newClassMap = getMapFromClassName(newClass);
3654
3533
  const oldClassMap = getMapFromClassName(oldClass);
3655
3534
  let name;
@@ -3673,17 +3552,18 @@ var LWC = (function (exports) {
3673
3552
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3674
3553
  */
3675
3554
  // The style property is a string when defined via an expression in the template.
3676
- function patchStyleAttribute(oldVnode, vnode) {
3555
+ function patchStyleAttribute(oldVnode, vnode, renderer) {
3677
3556
  const { elm, data: { style: newStyle }, } = vnode;
3678
3557
  const oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
3679
3558
  if (oldStyle === newStyle) {
3680
3559
  return;
3681
3560
  }
3561
+ const { setAttribute, removeAttribute } = renderer;
3682
3562
  if (!isString(newStyle) || newStyle === '') {
3683
- removeAttribute$1(elm, 'style');
3563
+ removeAttribute(elm, 'style');
3684
3564
  }
3685
3565
  else {
3686
- setAttribute$1(elm, 'style', newStyle);
3566
+ setAttribute(elm, 'style', newStyle);
3687
3567
  }
3688
3568
  }
3689
3569
 
@@ -3693,14 +3573,15 @@ var LWC = (function (exports) {
3693
3573
  * SPDX-License-Identifier: MIT
3694
3574
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3695
3575
  */
3696
- function applyEventListeners(vnode) {
3576
+ function applyEventListeners(vnode, renderer) {
3697
3577
  const { elm, data: { on }, } = vnode;
3698
3578
  if (isUndefined$1(on)) {
3699
3579
  return;
3700
3580
  }
3581
+ const { addEventListener } = renderer;
3701
3582
  for (const name in on) {
3702
3583
  const handler = on[name];
3703
- addEventListener$1(elm, name, handler);
3584
+ addEventListener(elm, name, handler);
3704
3585
  }
3705
3586
  }
3706
3587
 
@@ -3713,12 +3594,13 @@ var LWC = (function (exports) {
3713
3594
  // The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
3714
3595
  // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
3715
3596
  // different classnames properties individually instead of via a string.
3716
- function applyStaticClassAttribute(vnode) {
3597
+ function applyStaticClassAttribute(vnode, renderer) {
3717
3598
  const { elm, data: { classMap }, } = vnode;
3718
3599
  if (isUndefined$1(classMap)) {
3719
3600
  return;
3720
3601
  }
3721
- const classList = getClassList$1(elm);
3602
+ const { getClassList } = renderer;
3603
+ const classList = getClassList(elm);
3722
3604
  for (const name in classMap) {
3723
3605
  classList.add(name);
3724
3606
  }
@@ -3733,14 +3615,15 @@ var LWC = (function (exports) {
3733
3615
  // The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
3734
3616
  // The compiler takes care of transforming the inline style into an object. It's faster to set the
3735
3617
  // different style properties individually instead of via a string.
3736
- function applyStaticStyleAttribute(vnode) {
3618
+ function applyStaticStyleAttribute(vnode, renderer) {
3737
3619
  const { elm, data: { styleDecls }, } = vnode;
3738
3620
  if (isUndefined$1(styleDecls)) {
3739
3621
  return;
3740
3622
  }
3623
+ const { setCSSStyleProperty } = renderer;
3741
3624
  for (let i = 0; i < styleDecls.length; i++) {
3742
3625
  const [prop, value, important] = styleDecls[i];
3743
- setCSSStyleProperty$1(elm, prop, value, important);
3626
+ setCSSStyleProperty(elm, prop, value, important);
3744
3627
  }
3745
3628
  }
3746
3629
 
@@ -3750,15 +3633,16 @@ var LWC = (function (exports) {
3750
3633
  * SPDX-License-Identifier: MIT
3751
3634
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3752
3635
  */
3753
- function patchChildren(c1, c2, parent) {
3636
+ function patchChildren(c1, c2, parent, renderer) {
3754
3637
  if (hasDynamicChildren(c2)) {
3755
- updateDynamicChildren(c1, c2, parent);
3638
+ updateDynamicChildren(c1, c2, parent, renderer);
3756
3639
  }
3757
3640
  else {
3758
- updateStaticChildren(c1, c2, parent);
3641
+ updateStaticChildren(c1, c2, parent, renderer);
3759
3642
  }
3760
3643
  }
3761
- function patch(n1, n2) {
3644
+ function patch(n1, n2, renderer) {
3645
+ var _a, _b;
3762
3646
  if (n1 === n2) {
3763
3647
  return;
3764
3648
  }
@@ -3772,80 +3656,115 @@ var LWC = (function (exports) {
3772
3656
  }
3773
3657
  switch (n2.type) {
3774
3658
  case 0 /* Text */:
3775
- patchText(n1, n2);
3659
+ // VText has no special capability, fallback to the owner's renderer
3660
+ patchText(n1, n2, renderer);
3776
3661
  break;
3777
3662
  case 1 /* Comment */:
3778
- patchComment(n1, n2);
3663
+ // VComment has no special capability, fallback to the owner's renderer
3664
+ patchComment(n1, n2, renderer);
3665
+ break;
3666
+ case 4 /* Static */:
3667
+ n2.elm = n1.elm;
3779
3668
  break;
3780
3669
  case 2 /* Element */:
3781
- patchElement(n1, n2);
3670
+ patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3782
3671
  break;
3783
3672
  case 3 /* CustomElement */:
3784
- patchCustomElement(n1, n2);
3673
+ patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3785
3674
  break;
3786
3675
  }
3787
3676
  }
3788
- function mount(node, parent, anchor) {
3677
+ function mount(node, parent, renderer, anchor) {
3678
+ var _a, _b;
3789
3679
  switch (node.type) {
3790
3680
  case 0 /* Text */:
3791
- mountText(node, parent, anchor);
3681
+ // VText has no special capability, fallback to the owner's renderer
3682
+ mountText(node, parent, anchor, renderer);
3792
3683
  break;
3793
3684
  case 1 /* Comment */:
3794
- mountComment(node, parent, anchor);
3685
+ // VComment has no special capability, fallback to the owner's renderer
3686
+ mountComment(node, parent, anchor, renderer);
3687
+ break;
3688
+ case 4 /* Static */:
3689
+ // VStatic cannot have a custom renderer associated to them, using owner's renderer
3690
+ mountStatic(node, parent, anchor, renderer);
3795
3691
  break;
3796
3692
  case 2 /* Element */:
3797
- mountElement(node, parent, anchor);
3693
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3694
+ mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3798
3695
  break;
3799
3696
  case 3 /* CustomElement */:
3800
- mountCustomElement(node, parent, anchor);
3697
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3698
+ mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3801
3699
  break;
3802
3700
  }
3803
3701
  }
3804
- function patchText(n1, n2) {
3702
+ function patchText(n1, n2, renderer) {
3805
3703
  n2.elm = n1.elm;
3806
3704
  if (n2.text !== n1.text) {
3807
- updateTextContent(n2);
3705
+ updateTextContent(n2, renderer);
3808
3706
  }
3809
3707
  }
3810
- function mountText(node, parent, anchor) {
3811
- const { owner } = node;
3812
- const textNode = (node.elm = createText$1(node.text));
3813
- linkNodeToShadow(textNode, owner);
3814
- insertNode(textNode, parent, anchor);
3708
+ function mountText(vnode, parent, anchor, renderer) {
3709
+ const { owner } = vnode;
3710
+ const { createText } = renderer;
3711
+ const textNode = (vnode.elm = createText(vnode.text));
3712
+ linkNodeToShadow(textNode, owner, renderer);
3713
+ insertNode(textNode, parent, anchor, renderer);
3815
3714
  }
3816
- function patchComment(n1, n2) {
3715
+ function patchComment(n1, n2, renderer) {
3817
3716
  n2.elm = n1.elm;
3818
3717
  // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3819
3718
  // it is the case today.
3820
3719
  if (n2.text !== n1.text) {
3821
- updateTextContent(n2);
3720
+ updateTextContent(n2, renderer);
3822
3721
  }
3823
3722
  }
3824
- function mountComment(node, parent, anchor) {
3825
- const { owner } = node;
3826
- const commentNode = (node.elm = createComment$1(node.text));
3827
- linkNodeToShadow(commentNode, owner);
3828
- insertNode(commentNode, parent, anchor);
3723
+ function mountComment(vnode, parent, anchor, renderer) {
3724
+ const { owner } = vnode;
3725
+ const { createComment } = renderer;
3726
+ const commentNode = (vnode.elm = createComment(vnode.text));
3727
+ linkNodeToShadow(commentNode, owner, renderer);
3728
+ insertNode(commentNode, parent, anchor, renderer);
3829
3729
  }
3830
- function mountElement(vnode, parent, anchor) {
3730
+ function mountElement(vnode, parent, anchor, renderer) {
3831
3731
  const { sel, owner, data: { svg }, } = vnode;
3732
+ const { createElement } = renderer;
3832
3733
  const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3833
- const elm = createElement$2(sel, namespace);
3834
- linkNodeToShadow(elm, owner);
3835
- fallbackElmHook(elm, vnode);
3734
+ const elm = createElement(sel, namespace);
3735
+ linkNodeToShadow(elm, owner, renderer);
3736
+ fallbackElmHook(elm, vnode, renderer);
3836
3737
  vnode.elm = elm;
3837
- patchElementPropsAndAttrs$1(null, vnode);
3838
- insertNode(elm, parent, anchor);
3839
- mountVNodes(vnode.children, elm, null);
3738
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3739
+ insertNode(elm, parent, anchor, renderer);
3740
+ mountVNodes(vnode.children, elm, renderer, null);
3840
3741
  }
3841
- function patchElement(n1, n2) {
3742
+ function patchElement(n1, n2, renderer) {
3842
3743
  const elm = (n2.elm = n1.elm);
3843
- patchElementPropsAndAttrs$1(n1, n2);
3844
- patchChildren(n1.children, n2.children, elm);
3744
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3745
+ patchChildren(n1.children, n2.children, elm, renderer);
3746
+ }
3747
+ function mountStatic(vnode, parent, anchor, renderer) {
3748
+ const { owner } = vnode;
3749
+ const { cloneNode, isSyntheticShadowDefined } = renderer;
3750
+ const elm = (vnode.elm = cloneNode(vnode.fragment, true));
3751
+ linkNodeToShadow(elm, owner, renderer);
3752
+ // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3753
+ const { renderMode, shadowMode } = owner;
3754
+ if (isSyntheticShadowDefined) {
3755
+ if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
3756
+ elm[KEY__SHADOW_STATIC] = true;
3757
+ }
3758
+ }
3759
+ if (process.env.NODE_ENV !== 'production') {
3760
+ const isLight = renderMode === 0 /* Light */;
3761
+ patchElementWithRestrictions(elm, { isPortal: false, isLight });
3762
+ }
3763
+ insertNode(elm, parent, anchor, renderer);
3845
3764
  }
3846
- function mountCustomElement(vnode, parent, anchor) {
3765
+ function mountCustomElement(vnode, parent, anchor, renderer) {
3847
3766
  const { sel, owner } = vnode;
3848
- const UpgradableConstructor = getUpgradableConstructor(sel);
3767
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3849
3768
  /**
3850
3769
  * Note: if the upgradable constructor does not expect, or throw when we new it
3851
3770
  * with a callback as the first argument, we could implement a more advanced
@@ -3855,9 +3774,9 @@ var LWC = (function (exports) {
3855
3774
  let vm;
3856
3775
  const elm = new UpgradableConstructor((elm) => {
3857
3776
  // the custom element from the registry is expecting an upgrade callback
3858
- vm = createViewModelHook(elm, vnode);
3777
+ vm = createViewModelHook(elm, vnode, renderer);
3859
3778
  });
3860
- linkNodeToShadow(elm, owner);
3779
+ linkNodeToShadow(elm, owner, renderer);
3861
3780
  vnode.elm = elm;
3862
3781
  vnode.vm = vm;
3863
3782
  if (vm) {
@@ -3866,23 +3785,23 @@ var LWC = (function (exports) {
3866
3785
  else if (vnode.ctor !== UpgradableConstructor) {
3867
3786
  throw new TypeError(`Incorrect Component Constructor`);
3868
3787
  }
3869
- patchElementPropsAndAttrs$1(null, vnode);
3870
- insertNode(elm, parent, anchor);
3788
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3789
+ insertNode(elm, parent, anchor, renderer);
3871
3790
  if (vm) {
3872
3791
  if (process.env.NODE_ENV !== 'production') {
3873
3792
  assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
3874
3793
  }
3875
3794
  runConnectedCallback(vm);
3876
3795
  }
3877
- mountVNodes(vnode.children, elm, null);
3796
+ mountVNodes(vnode.children, elm, renderer, null);
3878
3797
  if (vm) {
3879
3798
  appendVM(vm);
3880
3799
  }
3881
3800
  }
3882
- function patchCustomElement(n1, n2) {
3801
+ function patchCustomElement(n1, n2, renderer) {
3883
3802
  const elm = (n2.elm = n1.elm);
3884
3803
  const vm = (n2.vm = n1.vm);
3885
- patchElementPropsAndAttrs$1(n1, n2);
3804
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3886
3805
  if (!isUndefined$1(vm)) {
3887
3806
  // in fallback mode, the allocation will always set children to
3888
3807
  // empty and delegate the real allocation to the slot elements
@@ -3890,33 +3809,38 @@ var LWC = (function (exports) {
3890
3809
  }
3891
3810
  // in fallback mode, the children will be always empty, so, nothing
3892
3811
  // will happen, but in native, it does allocate the light dom
3893
- patchChildren(n1.children, n2.children, elm);
3812
+ patchChildren(n1.children, n2.children, elm, renderer);
3894
3813
  if (!isUndefined$1(vm)) {
3895
3814
  // this will probably update the shadowRoot, but only if the vm is in a dirty state
3896
3815
  // this is important to preserve the top to bottom synchronous rendering phase.
3897
3816
  rerenderVM(vm);
3898
3817
  }
3899
3818
  }
3900
- function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
3819
+ function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
3901
3820
  for (; start < end; ++start) {
3902
3821
  const vnode = vnodes[start];
3903
3822
  if (isVNode(vnode)) {
3904
- mount(vnode, parent, anchor);
3823
+ mount(vnode, parent, renderer, anchor);
3905
3824
  }
3906
3825
  }
3907
3826
  }
3908
- function unmount(vnode, parent, doRemove = false) {
3827
+ function unmount(vnode, parent, renderer, doRemove = false) {
3909
3828
  const { type, elm, sel } = vnode;
3910
3829
  // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3911
3830
  // subtree root, is the only element worth unmounting from the subtree.
3912
3831
  if (doRemove) {
3913
- removeNode(elm, parent);
3832
+ // The vnode might or might not have a data.renderer associated to it
3833
+ // but the removal used here is from the owner instead.
3834
+ removeNode(elm, parent, renderer);
3914
3835
  }
3915
- const removeChildren = sel === 'slot'; // slot content is removed to trigger slotchange event when removing slot
3916
3836
  switch (type) {
3917
- case 2 /* Element */:
3918
- unmountVNodes(vnode.children, elm, removeChildren);
3837
+ case 2 /* Element */: {
3838
+ // Slot content is removed to trigger slotchange event when removing slot.
3839
+ // Only required for synthetic shadow.
3840
+ const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
3841
+ unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
3919
3842
  break;
3843
+ }
3920
3844
  case 3 /* CustomElement */: {
3921
3845
  const { vm } = vnode;
3922
3846
  // No need to unmount the children here, `removeVM` will take care of removing the
@@ -3927,11 +3851,11 @@ var LWC = (function (exports) {
3927
3851
  }
3928
3852
  }
3929
3853
  }
3930
- function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
3854
+ function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
3931
3855
  for (; start < end; ++start) {
3932
3856
  const ch = vnodes[start];
3933
3857
  if (isVNode(ch)) {
3934
- unmount(ch, parent, doRemove);
3858
+ unmount(ch, parent, renderer, doRemove);
3935
3859
  }
3936
3860
  }
3937
3861
  }
@@ -3945,66 +3869,71 @@ var LWC = (function (exports) {
3945
3869
  elm.$shadowToken$ = token;
3946
3870
  }
3947
3871
  // Set the scope token class for *.scoped.css styles
3948
- function setScopeTokenClassIfNecessary(elm, owner) {
3872
+ function setScopeTokenClassIfNecessary(elm, owner, renderer) {
3949
3873
  const { cmpTemplate, context } = owner;
3874
+ const { getClassList } = renderer;
3950
3875
  const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
3951
3876
  if (!isUndefined$1(token) && context.hasScopedStyles) {
3952
- getClassList$1(elm).add(token);
3877
+ // TODO [#2762]: this dot notation with add is probably problematic
3878
+ // probably we should have a renderer api for just the add operation
3879
+ getClassList(elm).add(token);
3953
3880
  }
3954
3881
  }
3955
- function linkNodeToShadow(elm, owner) {
3882
+ function linkNodeToShadow(elm, owner, renderer) {
3956
3883
  const { renderRoot, renderMode, shadowMode } = owner;
3884
+ const { isSyntheticShadowDefined } = renderer;
3957
3885
  // TODO [#1164]: this should eventually be done by the polyfill directly
3958
- if (isSyntheticShadowDefined$1) {
3886
+ if (isSyntheticShadowDefined) {
3959
3887
  if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
3960
3888
  elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
3961
3889
  }
3962
3890
  }
3963
3891
  }
3964
- function updateTextContent(vnode) {
3892
+ function updateTextContent(vnode, renderer) {
3965
3893
  const { elm, text } = vnode;
3894
+ const { setText } = renderer;
3966
3895
  if (process.env.NODE_ENV !== 'production') {
3967
3896
  unlockDomMutation();
3968
3897
  }
3969
- setText$1(elm, text);
3898
+ setText(elm, text);
3970
3899
  if (process.env.NODE_ENV !== 'production') {
3971
3900
  lockDomMutation();
3972
3901
  }
3973
3902
  }
3974
- function insertNode(node, parent, anchor) {
3903
+ function insertNode(node, parent, anchor, renderer) {
3975
3904
  if (process.env.NODE_ENV !== 'production') {
3976
3905
  unlockDomMutation();
3977
3906
  }
3978
- insert$1(node, parent, anchor);
3907
+ renderer.insert(node, parent, anchor);
3979
3908
  if (process.env.NODE_ENV !== 'production') {
3980
3909
  lockDomMutation();
3981
3910
  }
3982
3911
  }
3983
- function removeNode(node, parent) {
3912
+ function removeNode(node, parent, renderer) {
3984
3913
  if (process.env.NODE_ENV !== 'production') {
3985
3914
  unlockDomMutation();
3986
3915
  }
3987
- remove$1(node, parent);
3916
+ renderer.remove(node, parent);
3988
3917
  if (process.env.NODE_ENV !== 'production') {
3989
3918
  lockDomMutation();
3990
3919
  }
3991
3920
  }
3992
- function patchElementPropsAndAttrs$1(oldVnode, vnode) {
3921
+ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
3993
3922
  if (isNull(oldVnode)) {
3994
- applyEventListeners(vnode);
3995
- applyStaticClassAttribute(vnode);
3996
- applyStaticStyleAttribute(vnode);
3923
+ applyEventListeners(vnode, renderer);
3924
+ applyStaticClassAttribute(vnode, renderer);
3925
+ applyStaticStyleAttribute(vnode, renderer);
3997
3926
  }
3998
3927
  // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
3999
3928
  // value is set before type=radio.
4000
- patchClassAttribute(oldVnode, vnode);
4001
- patchStyleAttribute(oldVnode, vnode);
4002
- patchAttributes(oldVnode, vnode);
4003
- patchProps(oldVnode, vnode);
3929
+ patchClassAttribute(oldVnode, vnode, renderer);
3930
+ patchStyleAttribute(oldVnode, vnode, renderer);
3931
+ patchAttributes(oldVnode, vnode, renderer);
3932
+ patchProps(oldVnode, vnode, renderer);
4004
3933
  }
4005
- function fallbackElmHook(elm, vnode) {
3934
+ function fallbackElmHook(elm, vnode, renderer) {
4006
3935
  const { owner } = vnode;
4007
- setScopeTokenClassIfNecessary(elm, owner);
3936
+ setScopeTokenClassIfNecessary(elm, owner, renderer);
4008
3937
  if (owner.shadowMode === 1 /* Synthetic */) {
4009
3938
  const { data: { context }, } = vnode;
4010
3939
  const { stylesheetToken } = owner.context;
@@ -4052,7 +3981,7 @@ var LWC = (function (exports) {
4052
3981
  vnode.children = EmptyArray;
4053
3982
  }
4054
3983
  }
4055
- function createViewModelHook(elm, vnode) {
3984
+ function createViewModelHook(elm, vnode, renderer) {
4056
3985
  let vm = getAssociatedVMIfPresent(elm);
4057
3986
  // There is a possibility that a custom element is registered under tagName, in which case, the
4058
3987
  // initialization is already carry on, and there is nothing else to do here since this hook is
@@ -4061,7 +3990,7 @@ var LWC = (function (exports) {
4061
3990
  return vm;
4062
3991
  }
4063
3992
  const { sel, mode, ctor, owner } = vnode;
4064
- setScopeTokenClassIfNecessary(elm, owner);
3993
+ setScopeTokenClassIfNecessary(elm, owner, renderer);
4065
3994
  if (owner.shadowMode === 1 /* Synthetic */) {
4066
3995
  const { stylesheetToken } = owner.context;
4067
3996
  // when running in synthetic shadow mode, we need to set the shadowToken value
@@ -4070,7 +3999,7 @@ var LWC = (function (exports) {
4070
3999
  setElementShadowToken(elm, stylesheetToken);
4071
4000
  }
4072
4001
  }
4073
- vm = createVM(elm, ctor, {
4002
+ vm = createVM(elm, ctor, renderer, {
4074
4003
  mode,
4075
4004
  owner,
4076
4005
  tagName: sel,
@@ -4145,7 +4074,7 @@ var LWC = (function (exports) {
4145
4074
  }
4146
4075
  return map;
4147
4076
  }
4148
- function updateDynamicChildren(oldCh, newCh, parent) {
4077
+ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4149
4078
  let oldStartIdx = 0;
4150
4079
  let newStartIdx = 0;
4151
4080
  let oldEndIdx = oldCh.length - 1;
@@ -4174,26 +4103,26 @@ var LWC = (function (exports) {
4174
4103
  newEndVnode = newCh[--newEndIdx];
4175
4104
  }
4176
4105
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4177
- patch(oldStartVnode, newStartVnode);
4106
+ patch(oldStartVnode, newStartVnode, renderer);
4178
4107
  oldStartVnode = oldCh[++oldStartIdx];
4179
4108
  newStartVnode = newCh[++newStartIdx];
4180
4109
  }
4181
4110
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4182
- patch(oldEndVnode, newEndVnode);
4111
+ patch(oldEndVnode, newEndVnode, renderer);
4183
4112
  oldEndVnode = oldCh[--oldEndIdx];
4184
4113
  newEndVnode = newCh[--newEndIdx];
4185
4114
  }
4186
4115
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4187
4116
  // Vnode moved right
4188
- patch(oldStartVnode, newEndVnode);
4189
- insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
4117
+ patch(oldStartVnode, newEndVnode, renderer);
4118
+ insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4190
4119
  oldStartVnode = oldCh[++oldStartIdx];
4191
4120
  newEndVnode = newCh[--newEndIdx];
4192
4121
  }
4193
4122
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4194
4123
  // Vnode moved left
4195
- patch(oldEndVnode, newStartVnode);
4196
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
4124
+ patch(oldEndVnode, newStartVnode, renderer);
4125
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4197
4126
  oldEndVnode = oldCh[--oldEndIdx];
4198
4127
  newStartVnode = newCh[++newStartIdx];
4199
4128
  }
@@ -4204,7 +4133,7 @@ var LWC = (function (exports) {
4204
4133
  idxInOld = oldKeyToIdx[newStartVnode.key];
4205
4134
  if (isUndefined$1(idxInOld)) {
4206
4135
  // New element
4207
- mount(newStartVnode, parent, oldStartVnode.elm);
4136
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4208
4137
  newStartVnode = newCh[++newStartIdx];
4209
4138
  }
4210
4139
  else {
@@ -4212,10 +4141,10 @@ var LWC = (function (exports) {
4212
4141
  if (isVNode(elmToMove)) {
4213
4142
  if (elmToMove.sel !== newStartVnode.sel) {
4214
4143
  // New element
4215
- mount(newStartVnode, parent, oldStartVnode.elm);
4144
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4216
4145
  }
4217
4146
  else {
4218
- patch(elmToMove, newStartVnode);
4147
+ patch(elmToMove, newStartVnode, renderer);
4219
4148
  // Delete the old child, but copy the array since it is read-only.
4220
4149
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4221
4150
  // so we only care about the `oldCh` object inside this function.
@@ -4227,7 +4156,7 @@ var LWC = (function (exports) {
4227
4156
  }
4228
4157
  // We've already cloned at least once, so it's no longer read-only
4229
4158
  oldCh[idxInOld] = undefined;
4230
- insertNode(elmToMove.elm, parent, oldStartVnode.elm);
4159
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4231
4160
  }
4232
4161
  }
4233
4162
  newStartVnode = newCh[++newStartIdx];
@@ -4244,25 +4173,25 @@ var LWC = (function (exports) {
4244
4173
  n = newCh[++i];
4245
4174
  } while (!isVNode(n) && i < newChEnd);
4246
4175
  before = isVNode(n) ? n.elm : null;
4247
- mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
4176
+ mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
4248
4177
  }
4249
4178
  else {
4250
- unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
4179
+ unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
4251
4180
  }
4252
4181
  }
4253
4182
  }
4254
- function updateStaticChildren(c1, c2, parent) {
4183
+ function updateStaticChildren(c1, c2, parent, renderer) {
4255
4184
  const c1Length = c1.length;
4256
4185
  const c2Length = c2.length;
4257
4186
  if (c1Length === 0) {
4258
4187
  // the old list is empty, we can directly insert anything new
4259
- mountVNodes(c2, parent, null);
4188
+ mountVNodes(c2, parent, renderer, null);
4260
4189
  return;
4261
4190
  }
4262
4191
  if (c2Length === 0) {
4263
4192
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4264
4193
  // this is the case in which the dynamic children of an if-directive should be removed
4265
- unmountVNodes(c1, parent, true);
4194
+ unmountVNodes(c1, parent, renderer, true);
4266
4195
  return;
4267
4196
  }
4268
4197
  // if the old list is not empty, the new list MUST have the same
@@ -4275,16 +4204,16 @@ var LWC = (function (exports) {
4275
4204
  if (isVNode(n1)) {
4276
4205
  if (isVNode(n2)) {
4277
4206
  // both vnodes are equivalent, and we just need to patch them
4278
- patch(n1, n2);
4207
+ patch(n1, n2, renderer);
4279
4208
  anchor = n2.elm;
4280
4209
  }
4281
4210
  else {
4282
4211
  // removing the old vnode since the new one is null
4283
- unmount(n1, parent, true);
4212
+ unmount(n1, parent, renderer, true);
4284
4213
  }
4285
4214
  }
4286
4215
  else if (isVNode(n2)) {
4287
- mount(n2, parent, anchor);
4216
+ mount(n2, parent, renderer, anchor);
4288
4217
  anchor = n2.elm;
4289
4218
  }
4290
4219
  }
@@ -4301,6 +4230,17 @@ var LWC = (function (exports) {
4301
4230
  function addVNodeToChildLWC(vnode) {
4302
4231
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
4303
4232
  }
4233
+ // [st]atic node
4234
+ function st(fragment, key) {
4235
+ return {
4236
+ type: 4 /* Static */,
4237
+ sel: undefined,
4238
+ key,
4239
+ elm: undefined,
4240
+ fragment,
4241
+ owner: getVMBeingRendered(),
4242
+ };
4243
+ }
4304
4244
  // [h]tml node
4305
4245
  function h(sel, data, children = EmptyArray) {
4306
4246
  const vmBeingRendered = getVMBeingRendered();
@@ -4690,6 +4630,7 @@ var LWC = (function (exports) {
4690
4630
  co,
4691
4631
  dc,
4692
4632
  ti,
4633
+ st,
4693
4634
  gid,
4694
4635
  fid,
4695
4636
  shc,
@@ -4713,7 +4654,7 @@ var LWC = (function (exports) {
4713
4654
  }, [api.t(content)]);
4714
4655
  }
4715
4656
  function updateStylesheetToken(vm, template) {
4716
- const { elm, context, renderMode, shadowMode } = vm;
4657
+ const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
4717
4658
  const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
4718
4659
  const isSyntheticShadow = renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */;
4719
4660
  const { hasScopedStyles } = context;
@@ -4724,10 +4665,10 @@ var LWC = (function (exports) {
4724
4665
  const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
4725
4666
  if (!isUndefined$1(oldToken)) {
4726
4667
  if (oldHasTokenInClass) {
4727
- getClassList$1(elm).remove(makeHostToken(oldToken));
4668
+ getClassList(elm).remove(makeHostToken(oldToken));
4728
4669
  }
4729
4670
  if (oldHasTokenInAttribute) {
4730
- removeAttribute$1(elm, makeHostToken(oldToken));
4671
+ removeAttribute(elm, makeHostToken(oldToken));
4731
4672
  }
4732
4673
  }
4733
4674
  // Apply the new template styling token to the host element, if the new template has any
@@ -4738,11 +4679,11 @@ var LWC = (function (exports) {
4738
4679
  // Set the new styling token on the host element
4739
4680
  if (!isUndefined$1(newToken)) {
4740
4681
  if (hasScopedStyles) {
4741
- getClassList$1(elm).add(makeHostToken(newToken));
4682
+ getClassList(elm).add(makeHostToken(newToken));
4742
4683
  newHasTokenInClass = true;
4743
4684
  }
4744
4685
  if (isSyntheticShadow) {
4745
- setAttribute$1(elm, makeHostToken(newToken), '');
4686
+ setAttribute(elm, makeHostToken(newToken), '');
4746
4687
  newHasTokenInAttribute = true;
4747
4688
  }
4748
4689
  }
@@ -4830,19 +4771,18 @@ var LWC = (function (exports) {
4830
4771
  return owner;
4831
4772
  }
4832
4773
  function createStylesheet(vm, stylesheets) {
4833
- const { renderMode, shadowMode } = vm;
4774
+ const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
4834
4775
  if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
4835
4776
  for (let i = 0; i < stylesheets.length; i++) {
4836
- insertStylesheet$1(stylesheets[i]);
4777
+ insertStylesheet(stylesheets[i]);
4837
4778
  }
4838
4779
  }
4839
- else if (ssr$1 || vm.hydrated) {
4780
+ else if (ssr || vm.hydrated) {
4840
4781
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4841
4782
  // This works in the client, because the stylesheets are created, and cached in the VM
4842
4783
  // the first time the VM renders.
4843
4784
  // native shadow or light DOM, SSR
4844
- const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4845
- return createInlineStyleVNode(combinedStylesheetContent);
4785
+ return ArrayMap.call(stylesheets, createInlineStyleVNode);
4846
4786
  }
4847
4787
  else {
4848
4788
  // native shadow or light DOM, DOM renderer
@@ -4850,7 +4790,7 @@ var LWC = (function (exports) {
4850
4790
  // null root means a global style
4851
4791
  const target = isNull(root) ? undefined : root.shadowRoot;
4852
4792
  for (let i = 0; i < stylesheets.length; i++) {
4853
- insertStylesheet$1(stylesheets[i], target);
4793
+ insertStylesheet(stylesheets[i], target);
4854
4794
  }
4855
4795
  }
4856
4796
  return null;
@@ -5010,6 +4950,59 @@ var LWC = (function (exports) {
5010
4950
  assert.isTrue(isUndefined$1(template.renderMode), `Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${getComponentTag(vm)} or set it to 'lwc:render-mode="shadow"`);
5011
4951
  }
5012
4952
  }
4953
+ function buildParseFragmentFn(createFragmentFn) {
4954
+ return (strings, ...keys) => {
4955
+ const cache = create(null);
4956
+ return function () {
4957
+ const { context: { hasScopedStyles, stylesheetToken }, shadowMode, renderer, } = getVMBeingRendered();
4958
+ const hasStyleToken = !isUndefined$1(stylesheetToken);
4959
+ const isSyntheticShadow = shadowMode === 1 /* Synthetic */;
4960
+ let cacheKey = 0;
4961
+ if (hasStyleToken && hasScopedStyles) {
4962
+ cacheKey |= 1 /* HAS_SCOPED_STYLE */;
4963
+ }
4964
+ if (hasStyleToken && isSyntheticShadow) {
4965
+ cacheKey |= 2 /* SHADOW_MODE_SYNTHETIC */;
4966
+ }
4967
+ if (!isUndefined$1(cache[cacheKey])) {
4968
+ return cache[cacheKey];
4969
+ }
4970
+ const classToken = hasScopedStyles && hasStyleToken ? ' ' + stylesheetToken : '';
4971
+ const classAttrToken = hasScopedStyles && hasStyleToken ? ` class="${stylesheetToken}"` : '';
4972
+ const attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetToken : '';
4973
+ let htmlFragment = '';
4974
+ for (let i = 0, n = keys.length; i < n; i++) {
4975
+ switch (keys[i]) {
4976
+ case 0: // styleToken in existing class attr
4977
+ htmlFragment += strings[i] + classToken;
4978
+ break;
4979
+ case 1: // styleToken for added class attr
4980
+ htmlFragment += strings[i] + classAttrToken;
4981
+ break;
4982
+ case 2: // styleToken as attr
4983
+ htmlFragment += strings[i] + attrToken;
4984
+ break;
4985
+ case 3: // ${1}${2}
4986
+ htmlFragment += strings[i] + classAttrToken + attrToken;
4987
+ break;
4988
+ }
4989
+ }
4990
+ htmlFragment += strings[strings.length - 1];
4991
+ cache[cacheKey] = createFragmentFn(htmlFragment, renderer);
4992
+ return cache[cacheKey];
4993
+ };
4994
+ };
4995
+ }
4996
+ // Note: at the moment this code executes, we don't have a renderer yet.
4997
+ const parseFragment = buildParseFragmentFn((html, renderer) => {
4998
+ const { createFragment } = renderer;
4999
+ return createFragment(html);
5000
+ });
5001
+ const parseSVGFragment = buildParseFragmentFn((html, renderer) => {
5002
+ const { createFragment, getFirstChild } = renderer;
5003
+ const fragment = createFragment('<svg>' + html + '</svg>');
5004
+ return getFirstChild(fragment);
5005
+ });
5013
5006
  function evaluateTemplate(vm, html) {
5014
5007
  if (process.env.NODE_ENV !== 'production') {
5015
5008
  assert.isTrue(isFunction$1(html), `evaluateTemplate() second argument must be an imported template instead of ${toString$1(html)}`);
@@ -5056,7 +5049,7 @@ var LWC = (function (exports) {
5056
5049
  // Evaluate, create stylesheet and cache the produced VNode for future
5057
5050
  // re-rendering.
5058
5051
  const stylesheetsContent = getStylesheetsContent(vm, html);
5059
- context.styleVNode =
5052
+ context.styleVNodes =
5060
5053
  stylesheetsContent.length === 0
5061
5054
  ? null
5062
5055
  : createStylesheet(vm, stylesheetsContent);
@@ -5073,9 +5066,9 @@ var LWC = (function (exports) {
5073
5066
  // Set the global flag that template is being updated
5074
5067
  isUpdatingTemplate = true;
5075
5068
  vnodes = html.call(undefined, api, component, cmpSlots, context.tplCache);
5076
- const { styleVNode } = context;
5077
- if (!isNull(styleVNode)) {
5078
- ArrayUnshift.call(vnodes, styleVNode);
5069
+ const { styleVNodes } = context;
5070
+ if (!isNull(styleVNodes)) {
5071
+ ArrayUnshift.apply(vnodes, styleVNodes);
5079
5072
  }
5080
5073
  });
5081
5074
  }, () => {
@@ -5392,9 +5385,20 @@ var LWC = (function (exports) {
5392
5385
 
5393
5386
  resetComponentStateWhenRemoved(vm);
5394
5387
  }
5395
- function createVM(elm, ctor, options) {
5396
- var _a;
5397
5388
 
5389
+ function getNearestShadowAncestor(vm) {
5390
+ let ancestor = vm.owner;
5391
+
5392
+ while (!isNull(ancestor) && ancestor.renderMode === 0
5393
+ /* Light */
5394
+ ) {
5395
+ ancestor = ancestor.owner;
5396
+ }
5397
+
5398
+ return ancestor;
5399
+ }
5400
+
5401
+ function createVM(elm, ctor, renderer, options) {
5398
5402
  const {
5399
5403
  mode,
5400
5404
  owner,
@@ -5424,28 +5428,29 @@ var LWC = (function (exports) {
5424
5428
  cmpTemplate: null,
5425
5429
  hydrated: Boolean(hydrated),
5426
5430
  renderMode: def.renderMode,
5427
- shadowMode: computeShadowMode(def, owner),
5428
- 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,
5429
5431
  context: {
5430
5432
  stylesheetToken: undefined,
5431
5433
  hasTokenInClass: undefined,
5432
5434
  hasTokenInAttribute: undefined,
5433
5435
  hasScopedStyles: undefined,
5434
- styleVNode: null,
5436
+ styleVNodes: null,
5435
5437
  tplCache: EmptyObject,
5436
5438
  wiredConnecting: EmptyArray,
5437
5439
  wiredDisconnecting: EmptyArray
5438
5440
  },
5439
5441
  // Properties set right after VM creation.
5440
5442
  tro: null,
5443
+ shadowMode: null,
5441
5444
  // Properties set by the LightningElement constructor.
5442
5445
  component: null,
5443
5446
  shadowRoot: null,
5444
5447
  renderRoot: null,
5445
5448
  callHook,
5446
5449
  setHook,
5447
- getHook
5450
+ getHook,
5451
+ renderer
5448
5452
  };
5453
+ vm.shadowMode = computeShadowMode(vm, renderer);
5449
5454
  vm.tro = getTemplateReactiveObserver(vm);
5450
5455
 
5451
5456
  if (process.env.NODE_ENV !== 'production') {
@@ -5470,12 +5475,17 @@ var LWC = (function (exports) {
5470
5475
  return vm;
5471
5476
  }
5472
5477
 
5473
- function computeShadowMode(def, owner) {
5474
- var _a;
5475
-
5478
+ function computeShadowMode(vm, renderer) {
5479
+ const {
5480
+ def
5481
+ } = vm;
5482
+ const {
5483
+ isSyntheticShadowDefined,
5484
+ isNativeShadowDefined
5485
+ } = renderer;
5476
5486
  let shadowMode;
5477
5487
 
5478
- if (isSyntheticShadowDefined$1) {
5488
+ if (isSyntheticShadowDefined) {
5479
5489
  if (def.renderMode === 0
5480
5490
  /* Light */
5481
5491
  ) {
@@ -5484,7 +5494,7 @@ var LWC = (function (exports) {
5484
5494
  shadowMode = 0
5485
5495
  /* Native */
5486
5496
  ;
5487
- } else if (isNativeShadowDefined$1) {
5497
+ } else if (isNativeShadowDefined) {
5488
5498
  // Not combined with above condition because @lwc/features only supports identifiers in
5489
5499
  // the if-condition.
5490
5500
  if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
@@ -5495,13 +5505,23 @@ var LWC = (function (exports) {
5495
5505
  /* Native */
5496
5506
  ;
5497
5507
  } else {
5498
- // Transitive support for native Shadow DOM. A component in native mode
5499
- // transitively opts all of its descendants into native.
5500
- // Synthetic if neither this component nor any of its ancestors are configured
5501
- // to be native.
5502
- shadowMode = (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : 1
5503
- /* Synthetic */
5504
- ;
5508
+ const shadowAncestor = getNearestShadowAncestor(vm);
5509
+
5510
+ if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
5511
+ /* Native */
5512
+ ) {
5513
+ // Transitive support for native Shadow DOM. A component in native mode
5514
+ // transitively opts all of its descendants into native.
5515
+ shadowMode = 0
5516
+ /* Native */
5517
+ ;
5518
+ } else {
5519
+ // Synthetic if neither this component nor any of its ancestors are configured
5520
+ // to be native.
5521
+ shadowMode = 1
5522
+ /* Synthetic */
5523
+ ;
5524
+ }
5505
5525
  }
5506
5526
  } else {
5507
5527
  shadowMode = 1
@@ -5564,7 +5584,8 @@ var LWC = (function (exports) {
5564
5584
  function patchShadowRoot(vm, newCh) {
5565
5585
  const {
5566
5586
  renderRoot,
5567
- children: oldCh
5587
+ children: oldCh,
5588
+ renderer
5568
5589
  } = vm; // caching the new children collection
5569
5590
 
5570
5591
  vm.children = newCh;
@@ -5580,7 +5601,7 @@ var LWC = (function (exports) {
5580
5601
  , vm);
5581
5602
  }, () => {
5582
5603
  // job
5583
- patchChildren(oldCh, newCh, renderRoot);
5604
+ patchChildren(oldCh, newCh, renderRoot, renderer);
5584
5605
  }, () => {
5585
5606
  // post
5586
5607
  logOperationEnd(2
@@ -5605,10 +5626,13 @@ var LWC = (function (exports) {
5605
5626
  const {
5606
5627
  def: {
5607
5628
  renderedCallback
5629
+ },
5630
+ renderer: {
5631
+ ssr
5608
5632
  }
5609
5633
  } = vm;
5610
5634
 
5611
- if (isTrue(ssr$1)) {
5635
+ if (isTrue(ssr)) {
5612
5636
  return;
5613
5637
  }
5614
5638
 
@@ -5842,14 +5866,17 @@ var LWC = (function (exports) {
5842
5866
  function resetComponentRoot(vm) {
5843
5867
  const {
5844
5868
  children,
5845
- renderRoot
5869
+ renderRoot,
5870
+ renderer: {
5871
+ remove
5872
+ }
5846
5873
  } = vm;
5847
5874
 
5848
5875
  for (let i = 0, len = children.length; i < len; i++) {
5849
5876
  const child = children[i];
5850
5877
 
5851
5878
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5852
- remove$1(child.elm, renderRoot);
5879
+ remove(child.elm, renderRoot);
5853
5880
  }
5854
5881
  }
5855
5882
 
@@ -5858,7 +5885,13 @@ var LWC = (function (exports) {
5858
5885
  vm.velements = EmptyArray;
5859
5886
  }
5860
5887
  function scheduleRehydration(vm) {
5861
- if (isTrue(ssr$1) || isTrue(vm.isScheduled)) {
5888
+ const {
5889
+ renderer: {
5890
+ ssr
5891
+ }
5892
+ } = vm;
5893
+
5894
+ if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5862
5895
  return;
5863
5896
  }
5864
5897
 
@@ -6034,6 +6067,9 @@ var LWC = (function (exports) {
6034
6067
  context: {
6035
6068
  wiredConnecting,
6036
6069
  wiredDisconnecting
6070
+ },
6071
+ renderer: {
6072
+ dispatchEvent
6037
6073
  }
6038
6074
  } = vm; // waiting for the component to be connected to formally request the context via the token
6039
6075
 
@@ -6057,7 +6093,7 @@ var LWC = (function (exports) {
6057
6093
  }
6058
6094
 
6059
6095
  });
6060
- dispatchEvent$1(elm, contextRegistrationEvent);
6096
+ dispatchEvent(elm, contextRegistrationEvent);
6061
6097
  });
6062
6098
  }
6063
6099
 
@@ -6305,95 +6341,116 @@ var LWC = (function (exports) {
6305
6341
  function hydrateVM(vm) {
6306
6342
  const children = renderComponent(vm);
6307
6343
  vm.children = children;
6308
- const parentNode = vm.renderRoot;
6309
- hydrateChildren(getFirstChild$1(parentNode), children, parentNode, vm);
6344
+ const { renderRoot: parentNode, renderer: { getFirstChild }, } = vm;
6345
+ hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
6310
6346
  runRenderedCallback(vm);
6311
6347
  }
6312
- function hydrateNode(node, vnode) {
6348
+ function hydrateNode(node, vnode, renderer) {
6349
+ var _a, _b;
6313
6350
  let hydratedNode;
6314
6351
  switch (vnode.type) {
6315
6352
  case 0 /* Text */:
6316
- hydratedNode = hydrateText(node, vnode);
6353
+ // VText has no special capability, fallback to the owner's renderer
6354
+ hydratedNode = hydrateText(node, vnode, renderer);
6317
6355
  break;
6318
6356
  case 1 /* Comment */:
6319
- hydratedNode = hydrateComment(node, vnode);
6357
+ // VComment has no special capability, fallback to the owner's renderer
6358
+ hydratedNode = hydrateComment(node, vnode, renderer);
6359
+ break;
6360
+ case 4 /* Static */:
6361
+ // VStatic are cacheable and cannot have custom renderer associated to them
6362
+ hydratedNode = hydrateStaticElement(node, vnode, renderer);
6320
6363
  break;
6321
6364
  case 2 /* Element */:
6322
- hydratedNode = hydrateElement(node, vnode);
6365
+ hydratedNode = hydrateElement(node, vnode, (_a = vnode.data.renderer) !== null && _a !== void 0 ? _a : renderer);
6323
6366
  break;
6324
6367
  case 3 /* CustomElement */:
6325
- hydratedNode = hydrateCustomElement(node, vnode);
6368
+ hydratedNode = hydrateCustomElement(node, vnode, (_b = vnode.data.renderer) !== null && _b !== void 0 ? _b : renderer);
6326
6369
  break;
6327
6370
  }
6328
- return nextSibling$1(hydratedNode);
6371
+ return renderer.nextSibling(hydratedNode);
6329
6372
  }
6330
- function hydrateText(node, vnode) {
6373
+ function hydrateText(node, vnode, renderer) {
6331
6374
  var _a;
6332
- if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */)) {
6333
- return handleMismatch(node, vnode);
6375
+ if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */, renderer)) {
6376
+ return handleMismatch(node, vnode, renderer);
6334
6377
  }
6335
6378
  if (process.env.NODE_ENV !== 'production') {
6336
- const nodeValue = getProperty$1(node, 'nodeValue');
6379
+ const { getProperty } = renderer;
6380
+ const nodeValue = getProperty(node, 'nodeValue');
6337
6381
  if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
6338
6382
  logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
6339
6383
  }
6340
6384
  }
6341
- setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6385
+ const { setText } = renderer;
6386
+ setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6342
6387
  vnode.elm = node;
6343
6388
  return node;
6344
6389
  }
6345
- function hydrateComment(node, vnode) {
6390
+ function hydrateComment(node, vnode, renderer) {
6346
6391
  var _a;
6347
- if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */)) {
6348
- return handleMismatch(node, vnode);
6392
+ if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */, renderer)) {
6393
+ return handleMismatch(node, vnode, renderer);
6349
6394
  }
6350
6395
  if (process.env.NODE_ENV !== 'production') {
6351
- const nodeValue = getProperty$1(node, 'nodeValue');
6396
+ const { getProperty } = renderer;
6397
+ const nodeValue = getProperty(node, 'nodeValue');
6352
6398
  if (nodeValue !== vnode.text) {
6353
6399
  logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
6354
6400
  }
6355
6401
  }
6356
- setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6402
+ const { setProperty } = renderer;
6403
+ setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6357
6404
  vnode.elm = node;
6358
6405
  return node;
6359
6406
  }
6360
- function hydrateElement(elm, vnode) {
6361
- if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
6362
- !isMatchingElement(vnode, elm)) {
6363
- return handleMismatch(elm, vnode);
6407
+ function hydrateStaticElement(elm, vnode, renderer) {
6408
+ if (!areCompatibleNodes(vnode.fragment, elm, vnode, renderer)) {
6409
+ return handleMismatch(elm, vnode, renderer);
6364
6410
  }
6365
6411
  vnode.elm = elm;
6412
+ return elm;
6413
+ }
6414
+ function hydrateElement(elm, vnode, renderer) {
6415
+ if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
6416
+ !isMatchingElement(vnode, elm, renderer)) {
6417
+ return handleMismatch(elm, vnode, renderer);
6418
+ }
6419
+ vnode.elm = elm;
6420
+ const { owner } = vnode;
6366
6421
  const { context } = vnode.data;
6367
6422
  const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual" /* Manual */);
6368
6423
  if (isDomManual) {
6369
6424
  // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
6370
6425
  // remove the innerHTML from props so it reuses the existing dom elements.
6371
- const { props } = vnode.data;
6426
+ const { data: { props }, } = vnode;
6427
+ const { getProperty } = renderer;
6372
6428
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
6373
- if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
6429
+ if (getProperty(elm, 'innerHTML') === props.innerHTML) {
6374
6430
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
6375
6431
  vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
6376
6432
  }
6377
6433
  else {
6378
6434
  if (process.env.NODE_ENV !== 'production') {
6379
- logWarn(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
6435
+ logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, owner);
6380
6436
  }
6381
6437
  }
6382
6438
  }
6383
6439
  }
6384
- patchElementPropsAndAttrs(vnode);
6440
+ patchElementPropsAndAttrs(vnode, renderer);
6385
6441
  if (!isDomManual) {
6386
- hydrateChildren(getFirstChild$1(elm), vnode.children, elm, vnode.owner);
6442
+ const { getFirstChild } = renderer;
6443
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, owner);
6387
6444
  }
6388
6445
  return elm;
6389
6446
  }
6390
- function hydrateCustomElement(elm, vnode) {
6391
- if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
6392
- !isMatchingElement(vnode, elm)) {
6393
- return handleMismatch(elm, vnode);
6447
+ function hydrateCustomElement(elm, vnode, renderer) {
6448
+ if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
6449
+ !isMatchingElement(vnode, elm, renderer)) {
6450
+ return handleMismatch(elm, vnode, renderer);
6394
6451
  }
6395
6452
  const { sel, mode, ctor, owner } = vnode;
6396
- const vm = createVM(elm, ctor, {
6453
+ const vm = createVM(elm, ctor, renderer, {
6397
6454
  mode,
6398
6455
  owner,
6399
6456
  tagName: sel,
@@ -6402,16 +6459,17 @@ var LWC = (function (exports) {
6402
6459
  vnode.elm = elm;
6403
6460
  vnode.vm = vm;
6404
6461
  allocateChildren(vnode, vm);
6405
- patchElementPropsAndAttrs(vnode);
6462
+ patchElementPropsAndAttrs(vnode, renderer);
6406
6463
  // Insert hook section:
6407
6464
  if (process.env.NODE_ENV !== 'production') {
6408
6465
  assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
6409
6466
  }
6410
6467
  runConnectedCallback(vm);
6411
6468
  if (vm.renderMode !== 0 /* Light */) {
6469
+ const { getFirstChild } = renderer;
6412
6470
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
6413
6471
  // Note: for Light DOM, this is handled while hydrating the VM
6414
- hydrateChildren(getFirstChild$1(elm), vnode.children, elm, vm);
6472
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
6415
6473
  }
6416
6474
  hydrateVM(vm);
6417
6475
  return elm;
@@ -6420,11 +6478,12 @@ var LWC = (function (exports) {
6420
6478
  let hasWarned = false;
6421
6479
  let nextNode = node;
6422
6480
  let anchor = null;
6481
+ const { renderer } = owner;
6423
6482
  for (let i = 0; i < children.length; i++) {
6424
6483
  const childVnode = children[i];
6425
6484
  if (!isNull(childVnode)) {
6426
6485
  if (nextNode) {
6427
- nextNode = hydrateNode(nextNode, childVnode);
6486
+ nextNode = hydrateNode(nextNode, childVnode, renderer);
6428
6487
  anchor = childVnode.elm;
6429
6488
  }
6430
6489
  else {
@@ -6435,7 +6494,7 @@ var LWC = (function (exports) {
6435
6494
  logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
6436
6495
  }
6437
6496
  }
6438
- mount(childVnode, parentNode, anchor);
6497
+ mount(childVnode, parentNode, renderer, anchor);
6439
6498
  anchor = childVnode.elm;
6440
6499
  }
6441
6500
  }
@@ -6447,31 +6506,33 @@ var LWC = (function (exports) {
6447
6506
  logError(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
6448
6507
  }
6449
6508
  }
6509
+ // nextSibling is mostly harmless, and since we don't have
6510
+ // a good reference to what element to act upon, we instead
6511
+ // rely on the vm's associated renderer for navigating to the
6512
+ // next node in the list to be hydrated.
6513
+ const { nextSibling } = renderer;
6450
6514
  do {
6451
6515
  const current = nextNode;
6452
- nextNode = nextSibling$1(nextNode);
6453
- removeNode(current, parentNode);
6516
+ nextNode = nextSibling(nextNode);
6517
+ removeNode(current, parentNode, renderer);
6454
6518
  } while (nextNode);
6455
6519
  }
6456
6520
  }
6457
- function handleMismatch(node, vnode, msg) {
6521
+ function handleMismatch(node, vnode, renderer) {
6458
6522
  hasMismatch = true;
6459
- if (!isUndefined$1(msg)) {
6460
- if (process.env.NODE_ENV !== 'production') {
6461
- logError(msg, vnode.owner);
6462
- }
6463
- }
6464
- const parentNode = getProperty$1(node, 'parentNode');
6465
- mount(vnode, parentNode, node);
6466
- removeNode(node, parentNode);
6523
+ const { getProperty } = renderer;
6524
+ const parentNode = getProperty(node, 'parentNode');
6525
+ mount(vnode, parentNode, renderer, node);
6526
+ removeNode(node, parentNode, renderer);
6467
6527
  return vnode.elm;
6468
6528
  }
6469
- function patchElementPropsAndAttrs(vnode) {
6470
- applyEventListeners(vnode);
6471
- patchProps(null, vnode);
6529
+ function patchElementPropsAndAttrs(vnode, renderer) {
6530
+ applyEventListeners(vnode, renderer);
6531
+ patchProps(null, vnode, renderer);
6472
6532
  }
6473
- function hasCorrectNodeType(vnode, node, nodeType) {
6474
- if (getProperty$1(node, 'nodeType') !== nodeType) {
6533
+ function hasCorrectNodeType(vnode, node, nodeType, renderer) {
6534
+ const { getProperty } = renderer;
6535
+ if (getProperty(node, 'nodeType') !== nodeType) {
6475
6536
  if (process.env.NODE_ENV !== 'production') {
6476
6537
  logError('Hydration mismatch: incorrect node type received', vnode.owner);
6477
6538
  }
@@ -6479,46 +6540,51 @@ var LWC = (function (exports) {
6479
6540
  }
6480
6541
  return true;
6481
6542
  }
6482
- function isMatchingElement(vnode, elm) {
6483
- if (vnode.sel.toLowerCase() !== getProperty$1(elm, 'tagName').toLowerCase()) {
6543
+ function isMatchingElement(vnode, elm, renderer) {
6544
+ const { getProperty } = renderer;
6545
+ if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
6484
6546
  if (process.env.NODE_ENV !== 'production') {
6485
- logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty$1(elm, 'tagName').toLowerCase()}".`, vnode.owner);
6547
+ logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
6486
6548
  }
6487
6549
  return false;
6488
6550
  }
6489
- const hasIncompatibleAttrs = validateAttrs(vnode, elm);
6490
- const hasIncompatibleClass = validateClassAttr(vnode, elm);
6491
- const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
6551
+ const hasIncompatibleAttrs = validateAttrs(vnode, elm, renderer);
6552
+ const hasIncompatibleClass = validateClassAttr(vnode, elm, renderer);
6553
+ const hasIncompatibleStyle = validateStyleAttr(vnode, elm, renderer);
6492
6554
  return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
6493
6555
  }
6494
- function validateAttrs(vnode, elm) {
6556
+ function validateAttrs(vnode, elm, renderer) {
6495
6557
  const { data: { attrs = {} }, } = vnode;
6496
6558
  let nodesAreCompatible = true;
6497
6559
  // Validate attributes, though we could always recovery from those by running the update mods.
6498
6560
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6499
6561
  for (const [attrName, attrValue] of Object.entries(attrs)) {
6500
- const elmAttrValue = getAttribute$1(elm, attrName);
6562
+ const { owner } = vnode;
6563
+ const { getAttribute } = renderer;
6564
+ const elmAttrValue = getAttribute(elm, attrName);
6501
6565
  if (String(attrValue) !== elmAttrValue) {
6502
6566
  if (process.env.NODE_ENV !== 'production') {
6503
- logError(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
6567
+ const { getProperty } = renderer;
6568
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, owner);
6504
6569
  }
6505
6570
  nodesAreCompatible = false;
6506
6571
  }
6507
6572
  }
6508
6573
  return nodesAreCompatible;
6509
6574
  }
6510
- function validateClassAttr(vnode, elm) {
6575
+ function validateClassAttr(vnode, elm, renderer) {
6511
6576
  const { data: { className, classMap }, } = vnode;
6577
+ const { getProperty, getClassList } = renderer;
6512
6578
  let nodesAreCompatible = true;
6513
6579
  let vnodeClassName;
6514
- if (!isUndefined$1(className) && String(className) !== getProperty$1(elm, 'className')) {
6580
+ if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
6515
6581
  // className is used when class is bound to an expr.
6516
6582
  nodesAreCompatible = false;
6517
6583
  vnodeClassName = className;
6518
6584
  }
6519
6585
  else if (!isUndefined$1(classMap)) {
6520
6586
  // classMap is used when class is set to static value.
6521
- const classList = getClassList$1(elm);
6587
+ const classList = getClassList(elm);
6522
6588
  let computedClassName = '';
6523
6589
  // all classes from the vnode should be in the element.classList
6524
6590
  for (const name in classMap) {
@@ -6534,14 +6600,15 @@ var LWC = (function (exports) {
6534
6600
  }
6535
6601
  if (!nodesAreCompatible) {
6536
6602
  if (process.env.NODE_ENV !== 'production') {
6537
- logError(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty$1(elm, 'className')}"`, vnode.owner);
6603
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
6538
6604
  }
6539
6605
  }
6540
6606
  return nodesAreCompatible;
6541
6607
  }
6542
- function validateStyleAttr(vnode, elm) {
6608
+ function validateStyleAttr(vnode, elm, renderer) {
6543
6609
  const { data: { style, styleDecls }, } = vnode;
6544
- const elmStyle = getAttribute$1(elm, 'style') || '';
6610
+ const { getAttribute } = renderer;
6611
+ const elmStyle = getAttribute(elm, 'style') || '';
6545
6612
  let vnodeStyle;
6546
6613
  let nodesAreCompatible = true;
6547
6614
  if (!isUndefined$1(style) && style !== elmStyle) {
@@ -6573,11 +6640,45 @@ var LWC = (function (exports) {
6573
6640
  }
6574
6641
  if (!nodesAreCompatible) {
6575
6642
  if (process.env.NODE_ENV !== 'production') {
6576
- logError(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
6643
+ const { getProperty } = renderer;
6644
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
6577
6645
  }
6578
6646
  }
6579
6647
  return nodesAreCompatible;
6580
6648
  }
6649
+ function areCompatibleNodes(client, ssr, vnode, renderer) {
6650
+ const { getProperty, getAttribute } = renderer;
6651
+ if (getProperty(client, 'nodeType') === 3 /* TEXT */) {
6652
+ if (!hasCorrectNodeType(vnode, ssr, 3 /* TEXT */, renderer)) {
6653
+ return false;
6654
+ }
6655
+ return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
6656
+ }
6657
+ if (getProperty(client, 'nodeType') === 8 /* COMMENT */) {
6658
+ if (!hasCorrectNodeType(vnode, ssr, 8 /* COMMENT */, renderer)) {
6659
+ return false;
6660
+ }
6661
+ return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
6662
+ }
6663
+ if (!hasCorrectNodeType(vnode, ssr, 1 /* ELEMENT */, renderer)) {
6664
+ return false;
6665
+ }
6666
+ let isCompatibleElements = true;
6667
+ if (getProperty(client, 'tagName') !== getProperty(ssr, 'tagName')) {
6668
+ if (process.env.NODE_ENV !== 'production') {
6669
+ logError(`Hydration mismatch: expecting element with tag "${getProperty(client, 'tagName').toLowerCase()}" but found "${getProperty(ssr, 'tagName').toLowerCase()}".`, vnode.owner);
6670
+ }
6671
+ return false;
6672
+ }
6673
+ const clientAttrsNames = getProperty(client, 'getAttributeNames').call(client);
6674
+ clientAttrsNames.forEach((attrName) => {
6675
+ if (getAttribute(client, attrName) !== getAttribute(ssr, attrName)) {
6676
+ logError(`Mismatch hydrating element <${getProperty(client, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${getAttribute(client, attrName)}" but found "${getAttribute(ssr, attrName)}"`, vnode.owner);
6677
+ isCompatibleElements = false;
6678
+ }
6679
+ });
6680
+ return isCompatibleElements;
6681
+ }
6581
6682
 
6582
6683
  /*
6583
6684
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6713,7 +6814,7 @@ var LWC = (function (exports) {
6713
6814
  }
6714
6815
  return ctor;
6715
6816
  }
6716
- /* version: 2.14.0 */
6817
+ /* version: 2.15.0 */
6717
6818
 
6718
6819
  /*
6719
6820
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6872,7 +6973,7 @@ var LWC = (function (exports) {
6872
6973
  try {
6873
6974
  // dereference HTMLElement global because babel wraps globals in compat mode with a
6874
6975
  // _wrapNativeSuper()
6875
- // This is a problem because LWCUpgradableElement extends renderer.HTMLElement which does not
6976
+ // This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
6876
6977
  // get wrapped by babel.
6877
6978
  const HTMLElementAlias = HTMLElement;
6878
6979
  // In case we use compat mode with a modern browser, the compat mode transformation
@@ -6926,8 +7027,17 @@ var LWC = (function (exports) {
6926
7027
  hydrating = value;
6927
7028
  }
6928
7029
  const ssr = false;
7030
+ function isHydrating() {
7031
+ return hydrating;
7032
+ }
6929
7033
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
6930
7034
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
7035
+ function cloneNode(node, deep) {
7036
+ return node.cloneNode(deep);
7037
+ }
7038
+ function createFragment(html) {
7039
+ return document.createRange().createContextualFragment(html).firstChild;
7040
+ }
6931
7041
  function createElement$1(tagName, namespace) {
6932
7042
  return isUndefined$1(namespace)
6933
7043
  ? document.createElement(tagName)
@@ -7044,76 +7154,49 @@ var LWC = (function (exports) {
7044
7154
  assert.invariant(elm instanceof HTMLElement, msg);
7045
7155
  }
7046
7156
  const HTMLElementExported = HTMLElementConstructor;
7047
-
7048
- /*
7049
- * Copyright (c) 2020, salesforce.com, inc.
7050
- * All rights reserved.
7051
- * SPDX-License-Identifier: MIT
7052
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7053
- */
7054
- setAssertInstanceOfHTMLElement(assertInstanceOfHTMLElement);
7055
- setAttachShadow(attachShadow);
7056
- setCreateComment(createComment);
7057
- setCreateElement(createElement$1);
7058
- setCreateText(createText);
7059
- setDefineCustomElement(defineCustomElement);
7060
- setDispatchEvent(dispatchEvent);
7061
- setGetAttribute(getAttribute);
7062
- setGetBoundingClientRect(getBoundingClientRect);
7063
- setGetChildNodes(getChildNodes);
7064
- setGetChildren(getChildren);
7065
- setGetClassList(getClassList);
7066
- setGetCustomElement(getCustomElement);
7067
- setGetElementsByClassName(getElementsByClassName);
7068
- setGetElementsByTagName(getElementsByTagName);
7069
- setGetFirstChild(getFirstChild);
7070
- setGetFirstElementChild(getFirstElementChild);
7071
- setGetLastChild(getLastChild);
7072
- setGetLastElementChild(getLastElementChild);
7073
- setGetProperty(getProperty);
7074
- setHTMLElement(HTMLElementExported);
7075
- setInsert(insert);
7076
- setIsConnected(isConnected);
7077
- setIsNativeShadowDefined(isNativeShadowDefined);
7078
- setIsSyntheticShadowDefined(isSyntheticShadowDefined);
7079
- setNextSibling(nextSibling);
7080
- setQuerySelector(querySelector);
7081
- setQuerySelectorAll(querySelectorAll);
7082
- setRemove(remove);
7083
- setRemoveAttribute(removeAttribute);
7084
- setRemoveEventListener(removeEventListener);
7085
- setSetAttribute(setAttribute);
7086
- setSetCSSStyleProperty(setCSSStyleProperty);
7087
- setSetProperty(setProperty);
7088
- setSetText(setText);
7089
- setSsr(ssr);
7090
- setAddEventListener(addEventListener);
7091
- setInsertStylesheet(insertStylesheet);
7092
-
7093
- /*
7094
- * Copyright (c) 2018, salesforce.com, inc.
7095
- * All rights reserved.
7096
- * SPDX-License-Identifier: MIT
7097
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7098
- */
7099
- // @ts-ignore
7100
-
7101
- if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
7102
- window.addEventListener('test-dummy-flag', () => {
7103
- let hasFlag = false;
7104
-
7105
- if (runtimeFlags.DUMMY_TEST_FLAG) {
7106
- hasFlag = true;
7107
- }
7108
-
7109
- window.dispatchEvent(new CustomEvent('has-dummy-flag', {
7110
- detail: {
7111
- package: '@lwc/engine-dom',
7112
- hasFlag
7113
- }
7114
- }));
7115
- });
7116
- }
7157
+ const renderer = {
7158
+ ssr,
7159
+ isNativeShadowDefined,
7160
+ isSyntheticShadowDefined,
7161
+ HTMLElementExported,
7162
+ isHydrating,
7163
+ insert,
7164
+ remove,
7165
+ cloneNode,
7166
+ createFragment,
7167
+ createElement: createElement$1,
7168
+ createText,
7169
+ createComment,
7170
+ nextSibling,
7171
+ attachShadow,
7172
+ getProperty,
7173
+ setProperty,
7174
+ setText,
7175
+ getAttribute,
7176
+ setAttribute,
7177
+ removeAttribute,
7178
+ addEventListener,
7179
+ removeEventListener,
7180
+ dispatchEvent,
7181
+ getClassList,
7182
+ setCSSStyleProperty,
7183
+ getBoundingClientRect,
7184
+ querySelector,
7185
+ querySelectorAll,
7186
+ getElementsByTagName,
7187
+ getElementsByClassName,
7188
+ getChildren,
7189
+ getChildNodes,
7190
+ getFirstChild,
7191
+ getFirstElementChild,
7192
+ getLastChild,
7193
+ getLastElementChild,
7194
+ isConnected,
7195
+ insertStylesheet,
7196
+ assertInstanceOfHTMLElement,
7197
+ defineCustomElement,
7198
+ getCustomElement,
7199
+ };
7117
7200
 
7118
7201
  /*
7119
7202
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7135,7 +7218,7 @@ var LWC = (function (exports) {
7135
7218
  }
7136
7219
  }
7137
7220
  function createVMWithProps(element, Ctor, props) {
7138
- const vm = createVM(element, Ctor, {
7221
+ const vm = createVM(element, Ctor, renderer, {
7139
7222
  mode: 'open',
7140
7223
  owner: null,
7141
7224
  tagName: element.tagName.toLowerCase(),
@@ -7231,7 +7314,7 @@ var LWC = (function (exports) {
7231
7314
  hydratedCustomElements.add(this);
7232
7315
  }
7233
7316
  else {
7234
- createVM(this, Ctor, {
7317
+ createVM(this, Ctor, renderer, {
7235
7318
  mode: 'open',
7236
7319
  owner: null,
7237
7320
  tagName: this.tagName,
@@ -7316,7 +7399,7 @@ var LWC = (function (exports) {
7316
7399
  if (!isFunction$1(Ctor)) {
7317
7400
  throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
7318
7401
  }
7319
- const UpgradableConstructor = getUpgradableConstructor(sel);
7402
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
7320
7403
  let wasComponentUpgraded = false;
7321
7404
  // the custom element from the registry is expecting an upgrade callback
7322
7405
  /**
@@ -7326,7 +7409,7 @@ var LWC = (function (exports) {
7326
7409
  * an upgradable custom element.
7327
7410
  */
7328
7411
  const element = new UpgradableConstructor((elm) => {
7329
- createVM(elm, Ctor, {
7412
+ createVM(elm, Ctor, renderer, {
7330
7413
  tagName: sel,
7331
7414
  mode: options.mode !== 'closed' ? 'open' : 'closed',
7332
7415
  owner: null,
@@ -7410,7 +7493,7 @@ var LWC = (function (exports) {
7410
7493
  });
7411
7494
  freeze(LightningElement);
7412
7495
  seal(LightningElement.prototype);
7413
- /* version: 2.14.0 */
7496
+ /* version: 2.15.0 */
7414
7497
 
7415
7498
  exports.LightningElement = LightningElement;
7416
7499
  exports.__unstable__ProfilerControl = profilerControl;
@@ -7424,11 +7507,14 @@ var LWC = (function (exports) {
7424
7507
  exports.hydrateComponent = hydrateComponent;
7425
7508
  exports.isComponentConstructor = isComponentConstructor;
7426
7509
  exports.isNodeFromTemplate = isNodeShadowed;
7510
+ exports.parseFragment = parseFragment;
7511
+ exports.parseSVGFragment = parseSVGFragment;
7427
7512
  exports.readonly = readonly;
7428
7513
  exports.register = register;
7429
7514
  exports.registerComponent = registerComponent;
7430
7515
  exports.registerDecorators = registerDecorators;
7431
7516
  exports.registerTemplate = registerTemplate;
7517
+ exports.renderer = renderer;
7432
7518
  exports.sanitizeAttribute = sanitizeAttribute;
7433
7519
  exports.setFeatureFlag = setFeatureFlag;
7434
7520
  exports.setFeatureFlagForTest = setFeatureFlagForTest;