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