lwc 2.14.1 → 2.16.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 +598 -541
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +600 -540
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +537 -485
  5. package/dist/engine-dom/iife/es5/engine-dom.js +768 -679
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +692 -621
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +600 -540
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +537 -485
  11. package/dist/engine-dom/umd/es5/engine-dom.js +768 -679
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +692 -621
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +455 -460
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +453 -461
  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.1";
302
+ const LWC_VERSION = "2.16.0";
302
303
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
303
- /** version: 2.14.1 */
304
+ /** version: 2.16.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.1 */
458
+ /** version: 2.16.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,
@@ -3488,12 +3362,13 @@ function getComponentDef(Ctor) {
3488
3362
  * SPDX-License-Identifier: MIT
3489
3363
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3490
3364
  */
3491
- function getUpgradableConstructor(tagName) {
3365
+ function getUpgradableConstructor(tagName, renderer) {
3366
+ const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
3492
3367
  // Should never get a tag with upper case letter at this point, the compiler should
3493
3368
  // produce only tags with lowercase letters
3494
3369
  // But, for backwards compatibility, we will lower case the tagName
3495
3370
  tagName = tagName.toLowerCase();
3496
- let CE = getCustomElement$1(tagName);
3371
+ let CE = getCustomElement(tagName);
3497
3372
  if (!isUndefined$1(CE)) {
3498
3373
  return CE;
3499
3374
  }
@@ -3501,7 +3376,7 @@ function getUpgradableConstructor(tagName) {
3501
3376
  * LWC Upgradable Element reference to an element that was created
3502
3377
  * via the scoped registry mechanism, and that is ready to be upgraded.
3503
3378
  */
3504
- CE = class LWCUpgradableElement extends HTMLElementExported$1 {
3379
+ CE = class LWCUpgradableElement extends RendererHTMLElement {
3505
3380
  constructor(upgradeCallback) {
3506
3381
  super();
3507
3382
  if (isFunction$1(upgradeCallback)) {
@@ -3509,7 +3384,7 @@ function getUpgradableConstructor(tagName) {
3509
3384
  }
3510
3385
  }
3511
3386
  };
3512
- defineCustomElement$1(tagName, CE);
3387
+ defineCustomElement(tagName, CE);
3513
3388
  return CE;
3514
3389
  }
3515
3390
 
@@ -3534,7 +3409,7 @@ function isSameVnode(vnode1, vnode2) {
3534
3409
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3535
3410
  */
3536
3411
  const ColonCharCode = 58;
3537
- function patchAttributes(oldVnode, vnode) {
3412
+ function patchAttributes(oldVnode, vnode, renderer) {
3538
3413
  const { attrs } = vnode.data;
3539
3414
  if (isUndefined$1(attrs)) {
3540
3415
  return;
@@ -3544,6 +3419,7 @@ function patchAttributes(oldVnode, vnode) {
3544
3419
  return;
3545
3420
  }
3546
3421
  const { elm } = vnode;
3422
+ const { setAttribute, removeAttribute } = renderer;
3547
3423
  for (const key in attrs) {
3548
3424
  const cur = attrs[key];
3549
3425
  const old = oldAttrs[key];
@@ -3551,17 +3427,17 @@ function patchAttributes(oldVnode, vnode) {
3551
3427
  unlockAttribute(elm, key);
3552
3428
  if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
3553
3429
  // Assume xml namespace
3554
- setAttribute$1(elm, key, cur, XML_NAMESPACE);
3430
+ setAttribute(elm, key, cur, XML_NAMESPACE);
3555
3431
  }
3556
3432
  else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
3557
3433
  // Assume xlink namespace
3558
- setAttribute$1(elm, key, cur, XLINK_NAMESPACE);
3434
+ setAttribute(elm, key, cur, XLINK_NAMESPACE);
3559
3435
  }
3560
3436
  else if (isNull(cur) || isUndefined$1(cur)) {
3561
- removeAttribute$1(elm, key);
3437
+ removeAttribute(elm, key);
3562
3438
  }
3563
3439
  else {
3564
- setAttribute$1(elm, key, cur);
3440
+ setAttribute(elm, key, cur);
3565
3441
  }
3566
3442
  lockAttribute();
3567
3443
  }
@@ -3579,7 +3455,7 @@ function isLiveBindingProp(sel, key) {
3579
3455
  // instead of relying on internally tracked values.
3580
3456
  return sel === 'input' && (key === 'value' || key === 'checked');
3581
3457
  }
3582
- function patchProps(oldVnode, vnode) {
3458
+ function patchProps(oldVnode, vnode, renderer) {
3583
3459
  const { props } = vnode.data;
3584
3460
  if (isUndefined$1(props)) {
3585
3461
  return;
@@ -3590,13 +3466,14 @@ function patchProps(oldVnode, vnode) {
3590
3466
  }
3591
3467
  const isFirstPatch = isNull(oldVnode);
3592
3468
  const { elm, sel } = vnode;
3469
+ const { getProperty, setProperty } = renderer;
3593
3470
  for (const key in props) {
3594
3471
  const cur = props[key];
3595
3472
  // Set the property if it's the first time is is patched or if the previous property is
3596
3473
  // different than the one previously set.
3597
3474
  if (isFirstPatch ||
3598
- cur !== (isLiveBindingProp(sel, key) ? getProperty$1(elm, key) : oldProps[key])) {
3599
- setProperty$1(elm, key, cur);
3475
+ cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
3476
+ setProperty(elm, key, cur);
3600
3477
  }
3601
3478
  }
3602
3479
  }
@@ -3641,13 +3518,14 @@ function getMapFromClassName(className) {
3641
3518
  }
3642
3519
  return map;
3643
3520
  }
3644
- function patchClassAttribute(oldVnode, vnode) {
3521
+ function patchClassAttribute(oldVnode, vnode, renderer) {
3645
3522
  const { elm, data: { className: newClass }, } = vnode;
3646
3523
  const oldClass = isNull(oldVnode) ? undefined : oldVnode.data.className;
3647
3524
  if (oldClass === newClass) {
3648
3525
  return;
3649
3526
  }
3650
- const classList = getClassList$1(elm);
3527
+ const { getClassList } = renderer;
3528
+ const classList = getClassList(elm);
3651
3529
  const newClassMap = getMapFromClassName(newClass);
3652
3530
  const oldClassMap = getMapFromClassName(oldClass);
3653
3531
  let name;
@@ -3671,17 +3549,18 @@ function patchClassAttribute(oldVnode, vnode) {
3671
3549
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3672
3550
  */
3673
3551
  // The style property is a string when defined via an expression in the template.
3674
- function patchStyleAttribute(oldVnode, vnode) {
3552
+ function patchStyleAttribute(oldVnode, vnode, renderer) {
3675
3553
  const { elm, data: { style: newStyle }, } = vnode;
3676
3554
  const oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
3677
3555
  if (oldStyle === newStyle) {
3678
3556
  return;
3679
3557
  }
3558
+ const { setAttribute, removeAttribute } = renderer;
3680
3559
  if (!isString(newStyle) || newStyle === '') {
3681
- removeAttribute$1(elm, 'style');
3560
+ removeAttribute(elm, 'style');
3682
3561
  }
3683
3562
  else {
3684
- setAttribute$1(elm, 'style', newStyle);
3563
+ setAttribute(elm, 'style', newStyle);
3685
3564
  }
3686
3565
  }
3687
3566
 
@@ -3691,14 +3570,15 @@ function patchStyleAttribute(oldVnode, vnode) {
3691
3570
  * SPDX-License-Identifier: MIT
3692
3571
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3693
3572
  */
3694
- function applyEventListeners(vnode) {
3573
+ function applyEventListeners(vnode, renderer) {
3695
3574
  const { elm, data: { on }, } = vnode;
3696
3575
  if (isUndefined$1(on)) {
3697
3576
  return;
3698
3577
  }
3578
+ const { addEventListener } = renderer;
3699
3579
  for (const name in on) {
3700
3580
  const handler = on[name];
3701
- addEventListener$1(elm, name, handler);
3581
+ addEventListener(elm, name, handler);
3702
3582
  }
3703
3583
  }
3704
3584
 
@@ -3711,12 +3591,13 @@ function applyEventListeners(vnode) {
3711
3591
  // The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
3712
3592
  // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
3713
3593
  // different classnames properties individually instead of via a string.
3714
- function applyStaticClassAttribute(vnode) {
3594
+ function applyStaticClassAttribute(vnode, renderer) {
3715
3595
  const { elm, data: { classMap }, } = vnode;
3716
3596
  if (isUndefined$1(classMap)) {
3717
3597
  return;
3718
3598
  }
3719
- const classList = getClassList$1(elm);
3599
+ const { getClassList } = renderer;
3600
+ const classList = getClassList(elm);
3720
3601
  for (const name in classMap) {
3721
3602
  classList.add(name);
3722
3603
  }
@@ -3731,14 +3612,15 @@ function applyStaticClassAttribute(vnode) {
3731
3612
  // The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
3732
3613
  // The compiler takes care of transforming the inline style into an object. It's faster to set the
3733
3614
  // different style properties individually instead of via a string.
3734
- function applyStaticStyleAttribute(vnode) {
3615
+ function applyStaticStyleAttribute(vnode, renderer) {
3735
3616
  const { elm, data: { styleDecls }, } = vnode;
3736
3617
  if (isUndefined$1(styleDecls)) {
3737
3618
  return;
3738
3619
  }
3620
+ const { setCSSStyleProperty } = renderer;
3739
3621
  for (let i = 0; i < styleDecls.length; i++) {
3740
3622
  const [prop, value, important] = styleDecls[i];
3741
- setCSSStyleProperty$1(elm, prop, value, important);
3623
+ setCSSStyleProperty(elm, prop, value, important);
3742
3624
  }
3743
3625
  }
3744
3626
 
@@ -3748,15 +3630,16 @@ function applyStaticStyleAttribute(vnode) {
3748
3630
  * SPDX-License-Identifier: MIT
3749
3631
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3750
3632
  */
3751
- function patchChildren(c1, c2, parent) {
3633
+ function patchChildren(c1, c2, parent, renderer) {
3752
3634
  if (hasDynamicChildren(c2)) {
3753
- updateDynamicChildren(c1, c2, parent);
3635
+ updateDynamicChildren(c1, c2, parent, renderer);
3754
3636
  }
3755
3637
  else {
3756
- updateStaticChildren(c1, c2, parent);
3638
+ updateStaticChildren(c1, c2, parent, renderer);
3757
3639
  }
3758
3640
  }
3759
- function patch(n1, n2) {
3641
+ function patch(n1, n2, renderer) {
3642
+ var _a, _b;
3760
3643
  if (n1 === n2) {
3761
3644
  return;
3762
3645
  }
@@ -3770,80 +3653,115 @@ function patch(n1, n2) {
3770
3653
  }
3771
3654
  switch (n2.type) {
3772
3655
  case 0 /* Text */:
3773
- patchText(n1, n2);
3656
+ // VText has no special capability, fallback to the owner's renderer
3657
+ patchText(n1, n2, renderer);
3774
3658
  break;
3775
3659
  case 1 /* Comment */:
3776
- 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;
3777
3665
  break;
3778
3666
  case 2 /* Element */:
3779
- patchElement(n1, n2);
3667
+ patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3780
3668
  break;
3781
3669
  case 3 /* CustomElement */:
3782
- patchCustomElement(n1, n2);
3670
+ patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3783
3671
  break;
3784
3672
  }
3785
3673
  }
3786
- function mount(node, parent, anchor) {
3674
+ function mount(node, parent, renderer, anchor) {
3675
+ var _a, _b;
3787
3676
  switch (node.type) {
3788
3677
  case 0 /* Text */:
3789
- mountText(node, parent, anchor);
3678
+ // VText has no special capability, fallback to the owner's renderer
3679
+ mountText(node, parent, anchor, renderer);
3790
3680
  break;
3791
3681
  case 1 /* Comment */:
3792
- 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);
3793
3688
  break;
3794
3689
  case 2 /* Element */:
3795
- 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);
3796
3692
  break;
3797
3693
  case 3 /* CustomElement */:
3798
- 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);
3799
3696
  break;
3800
3697
  }
3801
3698
  }
3802
- function patchText(n1, n2) {
3699
+ function patchText(n1, n2, renderer) {
3803
3700
  n2.elm = n1.elm;
3804
3701
  if (n2.text !== n1.text) {
3805
- updateTextContent(n2);
3702
+ updateTextContent(n2, renderer);
3806
3703
  }
3807
3704
  }
3808
- function mountText(node, parent, anchor) {
3809
- const { owner } = node;
3810
- const textNode = (node.elm = createText$1(node.text));
3811
- linkNodeToShadow(textNode, owner);
3812
- 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);
3813
3711
  }
3814
- function patchComment(n1, n2) {
3712
+ function patchComment(n1, n2, renderer) {
3815
3713
  n2.elm = n1.elm;
3816
3714
  // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3817
3715
  // it is the case today.
3818
3716
  if (n2.text !== n1.text) {
3819
- updateTextContent(n2);
3717
+ updateTextContent(n2, renderer);
3820
3718
  }
3821
3719
  }
3822
- function mountComment(node, parent, anchor) {
3823
- const { owner } = node;
3824
- const commentNode = (node.elm = createComment$1(node.text));
3825
- linkNodeToShadow(commentNode, owner);
3826
- 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);
3827
3726
  }
3828
- function mountElement(vnode, parent, anchor) {
3727
+ function mountElement(vnode, parent, anchor, renderer) {
3829
3728
  const { sel, owner, data: { svg }, } = vnode;
3729
+ const { createElement } = renderer;
3830
3730
  const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3831
- const elm = createElement$2(sel, namespace);
3832
- linkNodeToShadow(elm, owner);
3833
- fallbackElmHook(elm, vnode);
3731
+ const elm = createElement(sel, namespace);
3732
+ linkNodeToShadow(elm, owner, renderer);
3733
+ fallbackElmHook(elm, vnode, renderer);
3834
3734
  vnode.elm = elm;
3835
- patchElementPropsAndAttrs$1(null, vnode);
3836
- insertNode(elm, parent, anchor);
3837
- mountVNodes(vnode.children, elm, null);
3735
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3736
+ insertNode(elm, parent, anchor, renderer);
3737
+ mountVNodes(vnode.children, elm, renderer, null);
3838
3738
  }
3839
- function patchElement(n1, n2) {
3739
+ function patchElement(n1, n2, renderer) {
3840
3740
  const elm = (n2.elm = n1.elm);
3841
- patchElementPropsAndAttrs$1(n1, n2);
3842
- patchChildren(n1.children, n2.children, elm);
3741
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3742
+ patchChildren(n1.children, n2.children, elm, renderer);
3843
3743
  }
3844
- function mountCustomElement(vnode, parent, anchor) {
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);
3761
+ }
3762
+ function mountCustomElement(vnode, parent, anchor, renderer) {
3845
3763
  const { sel, owner } = vnode;
3846
- const UpgradableConstructor = getUpgradableConstructor(sel);
3764
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3847
3765
  /**
3848
3766
  * Note: if the upgradable constructor does not expect, or throw when we new it
3849
3767
  * with a callback as the first argument, we could implement a more advanced
@@ -3853,9 +3771,9 @@ function mountCustomElement(vnode, parent, anchor) {
3853
3771
  let vm;
3854
3772
  const elm = new UpgradableConstructor((elm) => {
3855
3773
  // the custom element from the registry is expecting an upgrade callback
3856
- vm = createViewModelHook(elm, vnode);
3774
+ vm = createViewModelHook(elm, vnode, renderer);
3857
3775
  });
3858
- linkNodeToShadow(elm, owner);
3776
+ linkNodeToShadow(elm, owner, renderer);
3859
3777
  vnode.elm = elm;
3860
3778
  vnode.vm = vm;
3861
3779
  if (vm) {
@@ -3864,23 +3782,23 @@ function mountCustomElement(vnode, parent, anchor) {
3864
3782
  else if (vnode.ctor !== UpgradableConstructor) {
3865
3783
  throw new TypeError(`Incorrect Component Constructor`);
3866
3784
  }
3867
- patchElementPropsAndAttrs$1(null, vnode);
3868
- insertNode(elm, parent, anchor);
3785
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3786
+ insertNode(elm, parent, anchor, renderer);
3869
3787
  if (vm) {
3870
3788
  if (process.env.NODE_ENV !== 'production') {
3871
3789
  assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
3872
3790
  }
3873
3791
  runConnectedCallback(vm);
3874
3792
  }
3875
- mountVNodes(vnode.children, elm, null);
3793
+ mountVNodes(vnode.children, elm, renderer, null);
3876
3794
  if (vm) {
3877
3795
  appendVM(vm);
3878
3796
  }
3879
3797
  }
3880
- function patchCustomElement(n1, n2) {
3798
+ function patchCustomElement(n1, n2, renderer) {
3881
3799
  const elm = (n2.elm = n1.elm);
3882
3800
  const vm = (n2.vm = n1.vm);
3883
- patchElementPropsAndAttrs$1(n1, n2);
3801
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3884
3802
  if (!isUndefined$1(vm)) {
3885
3803
  // in fallback mode, the allocation will always set children to
3886
3804
  // empty and delegate the real allocation to the slot elements
@@ -3888,34 +3806,36 @@ function patchCustomElement(n1, n2) {
3888
3806
  }
3889
3807
  // in fallback mode, the children will be always empty, so, nothing
3890
3808
  // will happen, but in native, it does allocate the light dom
3891
- patchChildren(n1.children, n2.children, elm);
3809
+ patchChildren(n1.children, n2.children, elm, renderer);
3892
3810
  if (!isUndefined$1(vm)) {
3893
3811
  // this will probably update the shadowRoot, but only if the vm is in a dirty state
3894
3812
  // this is important to preserve the top to bottom synchronous rendering phase.
3895
3813
  rerenderVM(vm);
3896
3814
  }
3897
3815
  }
3898
- function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
3816
+ function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
3899
3817
  for (; start < end; ++start) {
3900
3818
  const vnode = vnodes[start];
3901
3819
  if (isVNode(vnode)) {
3902
- mount(vnode, parent, anchor);
3820
+ mount(vnode, parent, renderer, anchor);
3903
3821
  }
3904
3822
  }
3905
3823
  }
3906
- function unmount(vnode, parent, doRemove = false) {
3824
+ function unmount(vnode, parent, renderer, doRemove = false) {
3907
3825
  const { type, elm, sel } = vnode;
3908
3826
  // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3909
3827
  // subtree root, is the only element worth unmounting from the subtree.
3910
3828
  if (doRemove) {
3911
- 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);
3912
3832
  }
3913
3833
  switch (type) {
3914
3834
  case 2 /* Element */: {
3915
3835
  // Slot content is removed to trigger slotchange event when removing slot.
3916
3836
  // Only required for synthetic shadow.
3917
- const removeChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
3918
- unmountVNodes(vnode.children, elm, removeChildren);
3837
+ const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
3838
+ unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
3919
3839
  break;
3920
3840
  }
3921
3841
  case 3 /* CustomElement */: {
@@ -3928,11 +3848,11 @@ function unmount(vnode, parent, doRemove = false) {
3928
3848
  }
3929
3849
  }
3930
3850
  }
3931
- function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
3851
+ function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
3932
3852
  for (; start < end; ++start) {
3933
3853
  const ch = vnodes[start];
3934
3854
  if (isVNode(ch)) {
3935
- unmount(ch, parent, doRemove);
3855
+ unmount(ch, parent, renderer, doRemove);
3936
3856
  }
3937
3857
  }
3938
3858
  }
@@ -3946,66 +3866,71 @@ function setElementShadowToken(elm, token) {
3946
3866
  elm.$shadowToken$ = token;
3947
3867
  }
3948
3868
  // Set the scope token class for *.scoped.css styles
3949
- function setScopeTokenClassIfNecessary(elm, owner) {
3869
+ function setScopeTokenClassIfNecessary(elm, owner, renderer) {
3950
3870
  const { cmpTemplate, context } = owner;
3871
+ const { getClassList } = renderer;
3951
3872
  const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
3952
3873
  if (!isUndefined$1(token) && context.hasScopedStyles) {
3953
- 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);
3954
3877
  }
3955
3878
  }
3956
- function linkNodeToShadow(elm, owner) {
3879
+ function linkNodeToShadow(elm, owner, renderer) {
3957
3880
  const { renderRoot, renderMode, shadowMode } = owner;
3881
+ const { isSyntheticShadowDefined } = renderer;
3958
3882
  // TODO [#1164]: this should eventually be done by the polyfill directly
3959
- if (isSyntheticShadowDefined$1) {
3883
+ if (isSyntheticShadowDefined) {
3960
3884
  if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
3961
3885
  elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
3962
3886
  }
3963
3887
  }
3964
3888
  }
3965
- function updateTextContent(vnode) {
3889
+ function updateTextContent(vnode, renderer) {
3966
3890
  const { elm, text } = vnode;
3891
+ const { setText } = renderer;
3967
3892
  if (process.env.NODE_ENV !== 'production') {
3968
3893
  unlockDomMutation();
3969
3894
  }
3970
- setText$1(elm, text);
3895
+ setText(elm, text);
3971
3896
  if (process.env.NODE_ENV !== 'production') {
3972
3897
  lockDomMutation();
3973
3898
  }
3974
3899
  }
3975
- function insertNode(node, parent, anchor) {
3900
+ function insertNode(node, parent, anchor, renderer) {
3976
3901
  if (process.env.NODE_ENV !== 'production') {
3977
3902
  unlockDomMutation();
3978
3903
  }
3979
- insert$1(node, parent, anchor);
3904
+ renderer.insert(node, parent, anchor);
3980
3905
  if (process.env.NODE_ENV !== 'production') {
3981
3906
  lockDomMutation();
3982
3907
  }
3983
3908
  }
3984
- function removeNode(node, parent) {
3909
+ function removeNode(node, parent, renderer) {
3985
3910
  if (process.env.NODE_ENV !== 'production') {
3986
3911
  unlockDomMutation();
3987
3912
  }
3988
- remove$1(node, parent);
3913
+ renderer.remove(node, parent);
3989
3914
  if (process.env.NODE_ENV !== 'production') {
3990
3915
  lockDomMutation();
3991
3916
  }
3992
3917
  }
3993
- function patchElementPropsAndAttrs$1(oldVnode, vnode) {
3918
+ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
3994
3919
  if (isNull(oldVnode)) {
3995
- applyEventListeners(vnode);
3996
- applyStaticClassAttribute(vnode);
3997
- applyStaticStyleAttribute(vnode);
3920
+ applyEventListeners(vnode, renderer);
3921
+ applyStaticClassAttribute(vnode, renderer);
3922
+ applyStaticStyleAttribute(vnode, renderer);
3998
3923
  }
3999
3924
  // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
4000
3925
  // value is set before type=radio.
4001
- patchClassAttribute(oldVnode, vnode);
4002
- patchStyleAttribute(oldVnode, vnode);
4003
- patchAttributes(oldVnode, vnode);
4004
- patchProps(oldVnode, vnode);
3926
+ patchClassAttribute(oldVnode, vnode, renderer);
3927
+ patchStyleAttribute(oldVnode, vnode, renderer);
3928
+ patchAttributes(oldVnode, vnode, renderer);
3929
+ patchProps(oldVnode, vnode, renderer);
4005
3930
  }
4006
- function fallbackElmHook(elm, vnode) {
3931
+ function fallbackElmHook(elm, vnode, renderer) {
4007
3932
  const { owner } = vnode;
4008
- setScopeTokenClassIfNecessary(elm, owner);
3933
+ setScopeTokenClassIfNecessary(elm, owner, renderer);
4009
3934
  if (owner.shadowMode === 1 /* Synthetic */) {
4010
3935
  const { data: { context }, } = vnode;
4011
3936
  const { stylesheetToken } = owner.context;
@@ -4053,7 +3978,7 @@ function allocateChildren(vnode, vm) {
4053
3978
  vnode.children = EmptyArray;
4054
3979
  }
4055
3980
  }
4056
- function createViewModelHook(elm, vnode) {
3981
+ function createViewModelHook(elm, vnode, renderer) {
4057
3982
  let vm = getAssociatedVMIfPresent(elm);
4058
3983
  // There is a possibility that a custom element is registered under tagName, in which case, the
4059
3984
  // initialization is already carry on, and there is nothing else to do here since this hook is
@@ -4062,7 +3987,7 @@ function createViewModelHook(elm, vnode) {
4062
3987
  return vm;
4063
3988
  }
4064
3989
  const { sel, mode, ctor, owner } = vnode;
4065
- setScopeTokenClassIfNecessary(elm, owner);
3990
+ setScopeTokenClassIfNecessary(elm, owner, renderer);
4066
3991
  if (owner.shadowMode === 1 /* Synthetic */) {
4067
3992
  const { stylesheetToken } = owner.context;
4068
3993
  // when running in synthetic shadow mode, we need to set the shadowToken value
@@ -4071,7 +3996,7 @@ function createViewModelHook(elm, vnode) {
4071
3996
  setElementShadowToken(elm, stylesheetToken);
4072
3997
  }
4073
3998
  }
4074
- vm = createVM(elm, ctor, {
3999
+ vm = createVM(elm, ctor, renderer, {
4075
4000
  mode,
4076
4001
  owner,
4077
4002
  tagName: sel,
@@ -4146,7 +4071,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
4146
4071
  }
4147
4072
  return map;
4148
4073
  }
4149
- function updateDynamicChildren(oldCh, newCh, parent) {
4074
+ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4150
4075
  let oldStartIdx = 0;
4151
4076
  let newStartIdx = 0;
4152
4077
  let oldEndIdx = oldCh.length - 1;
@@ -4175,26 +4100,26 @@ function updateDynamicChildren(oldCh, newCh, parent) {
4175
4100
  newEndVnode = newCh[--newEndIdx];
4176
4101
  }
4177
4102
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4178
- patch(oldStartVnode, newStartVnode);
4103
+ patch(oldStartVnode, newStartVnode, renderer);
4179
4104
  oldStartVnode = oldCh[++oldStartIdx];
4180
4105
  newStartVnode = newCh[++newStartIdx];
4181
4106
  }
4182
4107
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4183
- patch(oldEndVnode, newEndVnode);
4108
+ patch(oldEndVnode, newEndVnode, renderer);
4184
4109
  oldEndVnode = oldCh[--oldEndIdx];
4185
4110
  newEndVnode = newCh[--newEndIdx];
4186
4111
  }
4187
4112
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4188
4113
  // Vnode moved right
4189
- patch(oldStartVnode, newEndVnode);
4190
- insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
4114
+ patch(oldStartVnode, newEndVnode, renderer);
4115
+ insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4191
4116
  oldStartVnode = oldCh[++oldStartIdx];
4192
4117
  newEndVnode = newCh[--newEndIdx];
4193
4118
  }
4194
4119
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4195
4120
  // Vnode moved left
4196
- patch(oldEndVnode, newStartVnode);
4197
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
4121
+ patch(oldEndVnode, newStartVnode, renderer);
4122
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4198
4123
  oldEndVnode = oldCh[--oldEndIdx];
4199
4124
  newStartVnode = newCh[++newStartIdx];
4200
4125
  }
@@ -4205,7 +4130,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
4205
4130
  idxInOld = oldKeyToIdx[newStartVnode.key];
4206
4131
  if (isUndefined$1(idxInOld)) {
4207
4132
  // New element
4208
- mount(newStartVnode, parent, oldStartVnode.elm);
4133
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4209
4134
  newStartVnode = newCh[++newStartIdx];
4210
4135
  }
4211
4136
  else {
@@ -4213,10 +4138,10 @@ function updateDynamicChildren(oldCh, newCh, parent) {
4213
4138
  if (isVNode(elmToMove)) {
4214
4139
  if (elmToMove.sel !== newStartVnode.sel) {
4215
4140
  // New element
4216
- mount(newStartVnode, parent, oldStartVnode.elm);
4141
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4217
4142
  }
4218
4143
  else {
4219
- patch(elmToMove, newStartVnode);
4144
+ patch(elmToMove, newStartVnode, renderer);
4220
4145
  // Delete the old child, but copy the array since it is read-only.
4221
4146
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4222
4147
  // so we only care about the `oldCh` object inside this function.
@@ -4228,7 +4153,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
4228
4153
  }
4229
4154
  // We've already cloned at least once, so it's no longer read-only
4230
4155
  oldCh[idxInOld] = undefined;
4231
- insertNode(elmToMove.elm, parent, oldStartVnode.elm);
4156
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4232
4157
  }
4233
4158
  }
4234
4159
  newStartVnode = newCh[++newStartIdx];
@@ -4245,25 +4170,25 @@ function updateDynamicChildren(oldCh, newCh, parent) {
4245
4170
  n = newCh[++i];
4246
4171
  } while (!isVNode(n) && i < newChEnd);
4247
4172
  before = isVNode(n) ? n.elm : null;
4248
- mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
4173
+ mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
4249
4174
  }
4250
4175
  else {
4251
- unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
4176
+ unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
4252
4177
  }
4253
4178
  }
4254
4179
  }
4255
- function updateStaticChildren(c1, c2, parent) {
4180
+ function updateStaticChildren(c1, c2, parent, renderer) {
4256
4181
  const c1Length = c1.length;
4257
4182
  const c2Length = c2.length;
4258
4183
  if (c1Length === 0) {
4259
4184
  // the old list is empty, we can directly insert anything new
4260
- mountVNodes(c2, parent, null);
4185
+ mountVNodes(c2, parent, renderer, null);
4261
4186
  return;
4262
4187
  }
4263
4188
  if (c2Length === 0) {
4264
4189
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4265
4190
  // this is the case in which the dynamic children of an if-directive should be removed
4266
- unmountVNodes(c1, parent, true);
4191
+ unmountVNodes(c1, parent, renderer, true);
4267
4192
  return;
4268
4193
  }
4269
4194
  // if the old list is not empty, the new list MUST have the same
@@ -4276,16 +4201,16 @@ function updateStaticChildren(c1, c2, parent) {
4276
4201
  if (isVNode(n1)) {
4277
4202
  if (isVNode(n2)) {
4278
4203
  // both vnodes are equivalent, and we just need to patch them
4279
- patch(n1, n2);
4204
+ patch(n1, n2, renderer);
4280
4205
  anchor = n2.elm;
4281
4206
  }
4282
4207
  else {
4283
4208
  // removing the old vnode since the new one is null
4284
- unmount(n1, parent, true);
4209
+ unmount(n1, parent, renderer, true);
4285
4210
  }
4286
4211
  }
4287
4212
  else if (isVNode(n2)) {
4288
- mount(n2, parent, anchor);
4213
+ mount(n2, parent, renderer, anchor);
4289
4214
  anchor = n2.elm;
4290
4215
  }
4291
4216
  }
@@ -4302,6 +4227,17 @@ const SymbolIterator = Symbol.iterator;
4302
4227
  function addVNodeToChildLWC(vnode) {
4303
4228
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
4304
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
+ }
4305
4241
  // [h]tml node
4306
4242
  function h(sel, data, children = EmptyArray) {
4307
4243
  const vmBeingRendered = getVMBeingRendered();
@@ -4691,6 +4627,7 @@ const api = freeze({
4691
4627
  co,
4692
4628
  dc,
4693
4629
  ti,
4630
+ st,
4694
4631
  gid,
4695
4632
  fid,
4696
4633
  shc,
@@ -4714,7 +4651,7 @@ function createInlineStyleVNode(content) {
4714
4651
  }, [api.t(content)]);
4715
4652
  }
4716
4653
  function updateStylesheetToken(vm, template) {
4717
- const { elm, context, renderMode, shadowMode } = vm;
4654
+ const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
4718
4655
  const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
4719
4656
  const isSyntheticShadow = renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */;
4720
4657
  const { hasScopedStyles } = context;
@@ -4725,10 +4662,10 @@ function updateStylesheetToken(vm, template) {
4725
4662
  const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
4726
4663
  if (!isUndefined$1(oldToken)) {
4727
4664
  if (oldHasTokenInClass) {
4728
- getClassList$1(elm).remove(makeHostToken(oldToken));
4665
+ getClassList(elm).remove(makeHostToken(oldToken));
4729
4666
  }
4730
4667
  if (oldHasTokenInAttribute) {
4731
- removeAttribute$1(elm, makeHostToken(oldToken));
4668
+ removeAttribute(elm, makeHostToken(oldToken));
4732
4669
  }
4733
4670
  }
4734
4671
  // Apply the new template styling token to the host element, if the new template has any
@@ -4739,11 +4676,11 @@ function updateStylesheetToken(vm, template) {
4739
4676
  // Set the new styling token on the host element
4740
4677
  if (!isUndefined$1(newToken)) {
4741
4678
  if (hasScopedStyles) {
4742
- getClassList$1(elm).add(makeHostToken(newToken));
4679
+ getClassList(elm).add(makeHostToken(newToken));
4743
4680
  newHasTokenInClass = true;
4744
4681
  }
4745
4682
  if (isSyntheticShadow) {
4746
- setAttribute$1(elm, makeHostToken(newToken), '');
4683
+ setAttribute(elm, makeHostToken(newToken), '');
4747
4684
  newHasTokenInAttribute = true;
4748
4685
  }
4749
4686
  }
@@ -4831,19 +4768,18 @@ function getNearestNativeShadowComponent(vm) {
4831
4768
  return owner;
4832
4769
  }
4833
4770
  function createStylesheet(vm, stylesheets) {
4834
- const { renderMode, shadowMode } = vm;
4771
+ const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
4835
4772
  if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
4836
4773
  for (let i = 0; i < stylesheets.length; i++) {
4837
- insertStylesheet$1(stylesheets[i]);
4774
+ insertStylesheet(stylesheets[i]);
4838
4775
  }
4839
4776
  }
4840
- else if (ssr$1 || vm.hydrated) {
4777
+ else if (ssr || vm.hydrated) {
4841
4778
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4842
4779
  // This works in the client, because the stylesheets are created, and cached in the VM
4843
4780
  // the first time the VM renders.
4844
4781
  // native shadow or light DOM, SSR
4845
- const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4846
- return createInlineStyleVNode(combinedStylesheetContent);
4782
+ return ArrayMap.call(stylesheets, createInlineStyleVNode);
4847
4783
  }
4848
4784
  else {
4849
4785
  // native shadow or light DOM, DOM renderer
@@ -4851,7 +4787,7 @@ function createStylesheet(vm, stylesheets) {
4851
4787
  // null root means a global style
4852
4788
  const target = isNull(root) ? undefined : root.shadowRoot;
4853
4789
  for (let i = 0; i < stylesheets.length; i++) {
4854
- insertStylesheet$1(stylesheets[i], target);
4790
+ insertStylesheet(stylesheets[i], target);
4855
4791
  }
4856
4792
  }
4857
4793
  return null;
@@ -5011,6 +4947,59 @@ function validateLightDomTemplate(template, vm) {
5011
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"`);
5012
4948
  }
5013
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
+ });
5014
5003
  function evaluateTemplate(vm, html) {
5015
5004
  if (process.env.NODE_ENV !== 'production') {
5016
5005
  assert.isTrue(isFunction$1(html), `evaluateTemplate() second argument must be an imported template instead of ${toString$1(html)}`);
@@ -5057,7 +5046,7 @@ function evaluateTemplate(vm, html) {
5057
5046
  // Evaluate, create stylesheet and cache the produced VNode for future
5058
5047
  // re-rendering.
5059
5048
  const stylesheetsContent = getStylesheetsContent(vm, html);
5060
- context.styleVNode =
5049
+ context.styleVNodes =
5061
5050
  stylesheetsContent.length === 0
5062
5051
  ? null
5063
5052
  : createStylesheet(vm, stylesheetsContent);
@@ -5074,9 +5063,9 @@ function evaluateTemplate(vm, html) {
5074
5063
  // Set the global flag that template is being updated
5075
5064
  isUpdatingTemplate = true;
5076
5065
  vnodes = html.call(undefined, api, component, cmpSlots, context.tplCache);
5077
- const { styleVNode } = context;
5078
- if (!isNull(styleVNode)) {
5079
- ArrayUnshift.call(vnodes, styleVNode);
5066
+ const { styleVNodes } = context;
5067
+ if (!isNull(styleVNodes)) {
5068
+ ArrayUnshift.apply(vnodes, styleVNodes);
5080
5069
  }
5081
5070
  });
5082
5071
  }, () => {
@@ -5406,7 +5395,7 @@ function getNearestShadowAncestor(vm) {
5406
5395
  return ancestor;
5407
5396
  }
5408
5397
 
5409
- function createVM(elm, ctor, options) {
5398
+ function createVM(elm, ctor, renderer, options) {
5410
5399
  const {
5411
5400
  mode,
5412
5401
  owner,
@@ -5441,7 +5430,7 @@ function createVM(elm, ctor, options) {
5441
5430
  hasTokenInClass: undefined,
5442
5431
  hasTokenInAttribute: undefined,
5443
5432
  hasScopedStyles: undefined,
5444
- styleVNode: null,
5433
+ styleVNodes: null,
5445
5434
  tplCache: EmptyObject,
5446
5435
  wiredConnecting: EmptyArray,
5447
5436
  wiredDisconnecting: EmptyArray
@@ -5455,9 +5444,10 @@ function createVM(elm, ctor, options) {
5455
5444
  renderRoot: null,
5456
5445
  callHook,
5457
5446
  setHook,
5458
- getHook
5447
+ getHook,
5448
+ renderer
5459
5449
  };
5460
- vm.shadowMode = computeShadowMode(vm);
5450
+ vm.shadowMode = computeShadowMode(vm, renderer);
5461
5451
  vm.tro = getTemplateReactiveObserver(vm);
5462
5452
 
5463
5453
  if (process.env.NODE_ENV !== 'production') {
@@ -5482,13 +5472,17 @@ function createVM(elm, ctor, options) {
5482
5472
  return vm;
5483
5473
  }
5484
5474
 
5485
- function computeShadowMode(vm) {
5475
+ function computeShadowMode(vm, renderer) {
5486
5476
  const {
5487
5477
  def
5488
5478
  } = vm;
5479
+ const {
5480
+ isSyntheticShadowDefined,
5481
+ isNativeShadowDefined
5482
+ } = renderer;
5489
5483
  let shadowMode;
5490
5484
 
5491
- if (isSyntheticShadowDefined$1) {
5485
+ if (isSyntheticShadowDefined) {
5492
5486
  if (def.renderMode === 0
5493
5487
  /* Light */
5494
5488
  ) {
@@ -5497,7 +5491,7 @@ function computeShadowMode(vm) {
5497
5491
  shadowMode = 0
5498
5492
  /* Native */
5499
5493
  ;
5500
- } else if (isNativeShadowDefined$1) {
5494
+ } else if (isNativeShadowDefined) {
5501
5495
  // Not combined with above condition because @lwc/features only supports identifiers in
5502
5496
  // the if-condition.
5503
5497
  if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
@@ -5587,7 +5581,8 @@ function rehydrate(vm) {
5587
5581
  function patchShadowRoot(vm, newCh) {
5588
5582
  const {
5589
5583
  renderRoot,
5590
- children: oldCh
5584
+ children: oldCh,
5585
+ renderer
5591
5586
  } = vm; // caching the new children collection
5592
5587
 
5593
5588
  vm.children = newCh;
@@ -5603,7 +5598,7 @@ function patchShadowRoot(vm, newCh) {
5603
5598
  , vm);
5604
5599
  }, () => {
5605
5600
  // job
5606
- patchChildren(oldCh, newCh, renderRoot);
5601
+ patchChildren(oldCh, newCh, renderRoot, renderer);
5607
5602
  }, () => {
5608
5603
  // post
5609
5604
  logOperationEnd(2
@@ -5628,10 +5623,13 @@ function runRenderedCallback(vm) {
5628
5623
  const {
5629
5624
  def: {
5630
5625
  renderedCallback
5626
+ },
5627
+ renderer: {
5628
+ ssr
5631
5629
  }
5632
5630
  } = vm;
5633
5631
 
5634
- if (isTrue(ssr$1)) {
5632
+ if (isTrue(ssr)) {
5635
5633
  return;
5636
5634
  }
5637
5635
 
@@ -5865,14 +5863,17 @@ function recursivelyDisconnectChildren(vnodes) {
5865
5863
  function resetComponentRoot(vm) {
5866
5864
  const {
5867
5865
  children,
5868
- renderRoot
5866
+ renderRoot,
5867
+ renderer: {
5868
+ remove
5869
+ }
5869
5870
  } = vm;
5870
5871
 
5871
5872
  for (let i = 0, len = children.length; i < len; i++) {
5872
5873
  const child = children[i];
5873
5874
 
5874
5875
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5875
- remove$1(child.elm, renderRoot);
5876
+ remove(child.elm, renderRoot);
5876
5877
  }
5877
5878
  }
5878
5879
 
@@ -5881,7 +5882,13 @@ function resetComponentRoot(vm) {
5881
5882
  vm.velements = EmptyArray;
5882
5883
  }
5883
5884
  function scheduleRehydration(vm) {
5884
- if (isTrue(ssr$1) || isTrue(vm.isScheduled)) {
5885
+ const {
5886
+ renderer: {
5887
+ ssr
5888
+ }
5889
+ } = vm;
5890
+
5891
+ if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5885
5892
  return;
5886
5893
  }
5887
5894
 
@@ -6057,6 +6064,9 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
6057
6064
  context: {
6058
6065
  wiredConnecting,
6059
6066
  wiredDisconnecting
6067
+ },
6068
+ renderer: {
6069
+ dispatchEvent
6060
6070
  }
6061
6071
  } = vm; // waiting for the component to be connected to formally request the context via the token
6062
6072
 
@@ -6080,7 +6090,7 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
6080
6090
  }
6081
6091
 
6082
6092
  });
6083
- dispatchEvent$1(elm, contextRegistrationEvent);
6093
+ dispatchEvent(elm, contextRegistrationEvent);
6084
6094
  });
6085
6095
  }
6086
6096
 
@@ -6328,95 +6338,116 @@ function hydrateRoot(vm) {
6328
6338
  function hydrateVM(vm) {
6329
6339
  const children = renderComponent(vm);
6330
6340
  vm.children = children;
6331
- const parentNode = vm.renderRoot;
6332
- hydrateChildren(getFirstChild$1(parentNode), children, parentNode, vm);
6341
+ const { renderRoot: parentNode, renderer: { getFirstChild }, } = vm;
6342
+ hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
6333
6343
  runRenderedCallback(vm);
6334
6344
  }
6335
- function hydrateNode(node, vnode) {
6345
+ function hydrateNode(node, vnode, renderer) {
6346
+ var _a, _b;
6336
6347
  let hydratedNode;
6337
6348
  switch (vnode.type) {
6338
6349
  case 0 /* Text */:
6339
- hydratedNode = hydrateText(node, vnode);
6350
+ // VText has no special capability, fallback to the owner's renderer
6351
+ hydratedNode = hydrateText(node, vnode, renderer);
6340
6352
  break;
6341
6353
  case 1 /* Comment */:
6342
- 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);
6343
6360
  break;
6344
6361
  case 2 /* Element */:
6345
- hydratedNode = hydrateElement(node, vnode);
6362
+ hydratedNode = hydrateElement(node, vnode, (_a = vnode.data.renderer) !== null && _a !== void 0 ? _a : renderer);
6346
6363
  break;
6347
6364
  case 3 /* CustomElement */:
6348
- hydratedNode = hydrateCustomElement(node, vnode);
6365
+ hydratedNode = hydrateCustomElement(node, vnode, (_b = vnode.data.renderer) !== null && _b !== void 0 ? _b : renderer);
6349
6366
  break;
6350
6367
  }
6351
- return nextSibling$1(hydratedNode);
6368
+ return renderer.nextSibling(hydratedNode);
6352
6369
  }
6353
- function hydrateText(node, vnode) {
6370
+ function hydrateText(node, vnode, renderer) {
6354
6371
  var _a;
6355
- if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */)) {
6356
- return handleMismatch(node, vnode);
6372
+ if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */, renderer)) {
6373
+ return handleMismatch(node, vnode, renderer);
6357
6374
  }
6358
6375
  if (process.env.NODE_ENV !== 'production') {
6359
- const nodeValue = getProperty$1(node, 'nodeValue');
6376
+ const { getProperty } = renderer;
6377
+ const nodeValue = getProperty(node, 'nodeValue');
6360
6378
  if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
6361
6379
  logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
6362
6380
  }
6363
6381
  }
6364
- 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);
6365
6384
  vnode.elm = node;
6366
6385
  return node;
6367
6386
  }
6368
- function hydrateComment(node, vnode) {
6387
+ function hydrateComment(node, vnode, renderer) {
6369
6388
  var _a;
6370
- if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */)) {
6371
- return handleMismatch(node, vnode);
6389
+ if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */, renderer)) {
6390
+ return handleMismatch(node, vnode, renderer);
6372
6391
  }
6373
6392
  if (process.env.NODE_ENV !== 'production') {
6374
- const nodeValue = getProperty$1(node, 'nodeValue');
6393
+ const { getProperty } = renderer;
6394
+ const nodeValue = getProperty(node, 'nodeValue');
6375
6395
  if (nodeValue !== vnode.text) {
6376
6396
  logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
6377
6397
  }
6378
6398
  }
6379
- 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);
6380
6401
  vnode.elm = node;
6381
6402
  return node;
6382
6403
  }
6383
- function hydrateElement(elm, vnode) {
6384
- if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
6385
- !isMatchingElement(vnode, elm)) {
6386
- return handleMismatch(elm, vnode);
6404
+ function hydrateStaticElement(elm, vnode, renderer) {
6405
+ if (!areCompatibleNodes(vnode.fragment, elm, vnode, renderer)) {
6406
+ return handleMismatch(elm, vnode, renderer);
6387
6407
  }
6388
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;
6389
6418
  const { context } = vnode.data;
6390
6419
  const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual" /* Manual */);
6391
6420
  if (isDomManual) {
6392
6421
  // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
6393
6422
  // remove the innerHTML from props so it reuses the existing dom elements.
6394
- const { props } = vnode.data;
6423
+ const { data: { props }, } = vnode;
6424
+ const { getProperty } = renderer;
6395
6425
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
6396
- if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
6426
+ if (getProperty(elm, 'innerHTML') === props.innerHTML) {
6397
6427
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
6398
6428
  vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
6399
6429
  }
6400
6430
  else {
6401
6431
  if (process.env.NODE_ENV !== 'production') {
6402
- 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);
6403
6433
  }
6404
6434
  }
6405
6435
  }
6406
6436
  }
6407
- patchElementPropsAndAttrs(vnode);
6437
+ patchElementPropsAndAttrs(vnode, renderer);
6408
6438
  if (!isDomManual) {
6409
- hydrateChildren(getFirstChild$1(elm), vnode.children, elm, vnode.owner);
6439
+ const { getFirstChild } = renderer;
6440
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, owner);
6410
6441
  }
6411
6442
  return elm;
6412
6443
  }
6413
- function hydrateCustomElement(elm, vnode) {
6414
- if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
6415
- !isMatchingElement(vnode, elm)) {
6416
- 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);
6417
6448
  }
6418
6449
  const { sel, mode, ctor, owner } = vnode;
6419
- const vm = createVM(elm, ctor, {
6450
+ const vm = createVM(elm, ctor, renderer, {
6420
6451
  mode,
6421
6452
  owner,
6422
6453
  tagName: sel,
@@ -6425,16 +6456,17 @@ function hydrateCustomElement(elm, vnode) {
6425
6456
  vnode.elm = elm;
6426
6457
  vnode.vm = vm;
6427
6458
  allocateChildren(vnode, vm);
6428
- patchElementPropsAndAttrs(vnode);
6459
+ patchElementPropsAndAttrs(vnode, renderer);
6429
6460
  // Insert hook section:
6430
6461
  if (process.env.NODE_ENV !== 'production') {
6431
6462
  assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
6432
6463
  }
6433
6464
  runConnectedCallback(vm);
6434
6465
  if (vm.renderMode !== 0 /* Light */) {
6466
+ const { getFirstChild } = renderer;
6435
6467
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
6436
6468
  // Note: for Light DOM, this is handled while hydrating the VM
6437
- hydrateChildren(getFirstChild$1(elm), vnode.children, elm, vm);
6469
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
6438
6470
  }
6439
6471
  hydrateVM(vm);
6440
6472
  return elm;
@@ -6443,11 +6475,12 @@ function hydrateChildren(node, children, parentNode, owner) {
6443
6475
  let hasWarned = false;
6444
6476
  let nextNode = node;
6445
6477
  let anchor = null;
6478
+ const { renderer } = owner;
6446
6479
  for (let i = 0; i < children.length; i++) {
6447
6480
  const childVnode = children[i];
6448
6481
  if (!isNull(childVnode)) {
6449
6482
  if (nextNode) {
6450
- nextNode = hydrateNode(nextNode, childVnode);
6483
+ nextNode = hydrateNode(nextNode, childVnode, renderer);
6451
6484
  anchor = childVnode.elm;
6452
6485
  }
6453
6486
  else {
@@ -6458,7 +6491,7 @@ function hydrateChildren(node, children, parentNode, owner) {
6458
6491
  logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
6459
6492
  }
6460
6493
  }
6461
- mount(childVnode, parentNode, anchor);
6494
+ mount(childVnode, parentNode, renderer, anchor);
6462
6495
  anchor = childVnode.elm;
6463
6496
  }
6464
6497
  }
@@ -6470,31 +6503,33 @@ function hydrateChildren(node, children, parentNode, owner) {
6470
6503
  logError(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
6471
6504
  }
6472
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;
6473
6511
  do {
6474
6512
  const current = nextNode;
6475
- nextNode = nextSibling$1(nextNode);
6476
- removeNode(current, parentNode);
6513
+ nextNode = nextSibling(nextNode);
6514
+ removeNode(current, parentNode, renderer);
6477
6515
  } while (nextNode);
6478
6516
  }
6479
6517
  }
6480
- function handleMismatch(node, vnode, msg) {
6518
+ function handleMismatch(node, vnode, renderer) {
6481
6519
  hasMismatch = true;
6482
- if (!isUndefined$1(msg)) {
6483
- if (process.env.NODE_ENV !== 'production') {
6484
- logError(msg, vnode.owner);
6485
- }
6486
- }
6487
- const parentNode = getProperty$1(node, 'parentNode');
6488
- mount(vnode, parentNode, node);
6489
- removeNode(node, parentNode);
6520
+ const { getProperty } = renderer;
6521
+ const parentNode = getProperty(node, 'parentNode');
6522
+ mount(vnode, parentNode, renderer, node);
6523
+ removeNode(node, parentNode, renderer);
6490
6524
  return vnode.elm;
6491
6525
  }
6492
- function patchElementPropsAndAttrs(vnode) {
6493
- applyEventListeners(vnode);
6494
- patchProps(null, vnode);
6526
+ function patchElementPropsAndAttrs(vnode, renderer) {
6527
+ applyEventListeners(vnode, renderer);
6528
+ patchProps(null, vnode, renderer);
6495
6529
  }
6496
- function hasCorrectNodeType(vnode, node, nodeType) {
6497
- if (getProperty$1(node, 'nodeType') !== nodeType) {
6530
+ function hasCorrectNodeType(vnode, node, nodeType, renderer) {
6531
+ const { getProperty } = renderer;
6532
+ if (getProperty(node, 'nodeType') !== nodeType) {
6498
6533
  if (process.env.NODE_ENV !== 'production') {
6499
6534
  logError('Hydration mismatch: incorrect node type received', vnode.owner);
6500
6535
  }
@@ -6502,46 +6537,51 @@ function hasCorrectNodeType(vnode, node, nodeType) {
6502
6537
  }
6503
6538
  return true;
6504
6539
  }
6505
- function isMatchingElement(vnode, elm) {
6506
- 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()) {
6507
6543
  if (process.env.NODE_ENV !== 'production') {
6508
- 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);
6509
6545
  }
6510
6546
  return false;
6511
6547
  }
6512
- const hasIncompatibleAttrs = validateAttrs(vnode, elm);
6513
- const hasIncompatibleClass = validateClassAttr(vnode, elm);
6514
- 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);
6515
6551
  return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
6516
6552
  }
6517
- function validateAttrs(vnode, elm) {
6553
+ function validateAttrs(vnode, elm, renderer) {
6518
6554
  const { data: { attrs = {} }, } = vnode;
6519
6555
  let nodesAreCompatible = true;
6520
6556
  // Validate attributes, though we could always recovery from those by running the update mods.
6521
6557
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6522
6558
  for (const [attrName, attrValue] of Object.entries(attrs)) {
6523
- const elmAttrValue = getAttribute$1(elm, attrName);
6559
+ const { owner } = vnode;
6560
+ const { getAttribute } = renderer;
6561
+ const elmAttrValue = getAttribute(elm, attrName);
6524
6562
  if (String(attrValue) !== elmAttrValue) {
6525
6563
  if (process.env.NODE_ENV !== 'production') {
6526
- 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);
6527
6566
  }
6528
6567
  nodesAreCompatible = false;
6529
6568
  }
6530
6569
  }
6531
6570
  return nodesAreCompatible;
6532
6571
  }
6533
- function validateClassAttr(vnode, elm) {
6572
+ function validateClassAttr(vnode, elm, renderer) {
6534
6573
  const { data: { className, classMap }, } = vnode;
6574
+ const { getProperty, getClassList } = renderer;
6535
6575
  let nodesAreCompatible = true;
6536
6576
  let vnodeClassName;
6537
- if (!isUndefined$1(className) && String(className) !== getProperty$1(elm, 'className')) {
6577
+ if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
6538
6578
  // className is used when class is bound to an expr.
6539
6579
  nodesAreCompatible = false;
6540
6580
  vnodeClassName = className;
6541
6581
  }
6542
6582
  else if (!isUndefined$1(classMap)) {
6543
6583
  // classMap is used when class is set to static value.
6544
- const classList = getClassList$1(elm);
6584
+ const classList = getClassList(elm);
6545
6585
  let computedClassName = '';
6546
6586
  // all classes from the vnode should be in the element.classList
6547
6587
  for (const name in classMap) {
@@ -6557,14 +6597,15 @@ function validateClassAttr(vnode, elm) {
6557
6597
  }
6558
6598
  if (!nodesAreCompatible) {
6559
6599
  if (process.env.NODE_ENV !== 'production') {
6560
- 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);
6561
6601
  }
6562
6602
  }
6563
6603
  return nodesAreCompatible;
6564
6604
  }
6565
- function validateStyleAttr(vnode, elm) {
6605
+ function validateStyleAttr(vnode, elm, renderer) {
6566
6606
  const { data: { style, styleDecls }, } = vnode;
6567
- const elmStyle = getAttribute$1(elm, 'style') || '';
6607
+ const { getAttribute } = renderer;
6608
+ const elmStyle = getAttribute(elm, 'style') || '';
6568
6609
  let vnodeStyle;
6569
6610
  let nodesAreCompatible = true;
6570
6611
  if (!isUndefined$1(style) && style !== elmStyle) {
@@ -6596,11 +6637,45 @@ function validateStyleAttr(vnode, elm) {
6596
6637
  }
6597
6638
  if (!nodesAreCompatible) {
6598
6639
  if (process.env.NODE_ENV !== 'production') {
6599
- 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);
6600
6642
  }
6601
6643
  }
6602
6644
  return nodesAreCompatible;
6603
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
+ }
6604
6679
 
6605
6680
  /*
6606
6681
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6736,7 +6811,7 @@ function getComponentConstructor(elm) {
6736
6811
  }
6737
6812
  return ctor;
6738
6813
  }
6739
- /* version: 2.14.1 */
6814
+ /* version: 2.16.0 */
6740
6815
 
6741
6816
  /*
6742
6817
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6895,7 +6970,7 @@ function isCustomElementRegistryAvailable() {
6895
6970
  try {
6896
6971
  // dereference HTMLElement global because babel wraps globals in compat mode with a
6897
6972
  // _wrapNativeSuper()
6898
- // 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
6899
6974
  // get wrapped by babel.
6900
6975
  const HTMLElementAlias = HTMLElement;
6901
6976
  // In case we use compat mode with a modern browser, the compat mode transformation
@@ -6949,8 +7024,17 @@ function setIsHydrating(value) {
6949
7024
  hydrating = value;
6950
7025
  }
6951
7026
  const ssr = false;
7027
+ function isHydrating() {
7028
+ return hydrating;
7029
+ }
6952
7030
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
6953
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
+ }
6954
7038
  function createElement$1(tagName, namespace) {
6955
7039
  return isUndefined$1(namespace)
6956
7040
  ? document.createElement(tagName)
@@ -7067,76 +7151,49 @@ function assertInstanceOfHTMLElement(elm, msg) {
7067
7151
  assert.invariant(elm instanceof HTMLElement, msg);
7068
7152
  }
7069
7153
  const HTMLElementExported = HTMLElementConstructor;
7070
-
7071
- /*
7072
- * Copyright (c) 2020, salesforce.com, inc.
7073
- * All rights reserved.
7074
- * SPDX-License-Identifier: MIT
7075
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7076
- */
7077
- setAssertInstanceOfHTMLElement(assertInstanceOfHTMLElement);
7078
- setAttachShadow(attachShadow);
7079
- setCreateComment(createComment);
7080
- setCreateElement(createElement$1);
7081
- setCreateText(createText);
7082
- setDefineCustomElement(defineCustomElement);
7083
- setDispatchEvent(dispatchEvent);
7084
- setGetAttribute(getAttribute);
7085
- setGetBoundingClientRect(getBoundingClientRect);
7086
- setGetChildNodes(getChildNodes);
7087
- setGetChildren(getChildren);
7088
- setGetClassList(getClassList);
7089
- setGetCustomElement(getCustomElement);
7090
- setGetElementsByClassName(getElementsByClassName);
7091
- setGetElementsByTagName(getElementsByTagName);
7092
- setGetFirstChild(getFirstChild);
7093
- setGetFirstElementChild(getFirstElementChild);
7094
- setGetLastChild(getLastChild);
7095
- setGetLastElementChild(getLastElementChild);
7096
- setGetProperty(getProperty);
7097
- setHTMLElement(HTMLElementExported);
7098
- setInsert(insert);
7099
- setIsConnected(isConnected);
7100
- setIsNativeShadowDefined(isNativeShadowDefined);
7101
- setIsSyntheticShadowDefined(isSyntheticShadowDefined);
7102
- setNextSibling(nextSibling);
7103
- setQuerySelector(querySelector);
7104
- setQuerySelectorAll(querySelectorAll);
7105
- setRemove(remove);
7106
- setRemoveAttribute(removeAttribute);
7107
- setRemoveEventListener(removeEventListener);
7108
- setSetAttribute(setAttribute);
7109
- setSetCSSStyleProperty(setCSSStyleProperty);
7110
- setSetProperty(setProperty);
7111
- setSetText(setText);
7112
- setSsr(ssr);
7113
- setAddEventListener(addEventListener);
7114
- setInsertStylesheet(insertStylesheet);
7115
-
7116
- /*
7117
- * Copyright (c) 2018, salesforce.com, inc.
7118
- * All rights reserved.
7119
- * SPDX-License-Identifier: MIT
7120
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7121
- */
7122
- // @ts-ignore
7123
-
7124
- if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
7125
- window.addEventListener('test-dummy-flag', () => {
7126
- let hasFlag = false;
7127
-
7128
- if (runtimeFlags.DUMMY_TEST_FLAG) {
7129
- hasFlag = true;
7130
- }
7131
-
7132
- window.dispatchEvent(new CustomEvent('has-dummy-flag', {
7133
- detail: {
7134
- package: '@lwc/engine-dom',
7135
- hasFlag
7136
- }
7137
- }));
7138
- });
7139
- }
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
+ };
7140
7197
 
7141
7198
  /*
7142
7199
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7158,7 +7215,7 @@ function resetShadowRootAndLightDom(element, Ctor) {
7158
7215
  }
7159
7216
  }
7160
7217
  function createVMWithProps(element, Ctor, props) {
7161
- const vm = createVM(element, Ctor, {
7218
+ const vm = createVM(element, Ctor, renderer, {
7162
7219
  mode: 'open',
7163
7220
  owner: null,
7164
7221
  tagName: element.tagName.toLowerCase(),
@@ -7254,7 +7311,7 @@ function buildCustomElementConstructor(Ctor) {
7254
7311
  hydratedCustomElements.add(this);
7255
7312
  }
7256
7313
  else {
7257
- createVM(this, Ctor, {
7314
+ createVM(this, Ctor, renderer, {
7258
7315
  mode: 'open',
7259
7316
  owner: null,
7260
7317
  tagName: this.tagName,
@@ -7339,7 +7396,7 @@ function createElement(sel, options) {
7339
7396
  if (!isFunction$1(Ctor)) {
7340
7397
  throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
7341
7398
  }
7342
- const UpgradableConstructor = getUpgradableConstructor(sel);
7399
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
7343
7400
  let wasComponentUpgraded = false;
7344
7401
  // the custom element from the registry is expecting an upgrade callback
7345
7402
  /**
@@ -7349,7 +7406,7 @@ function createElement(sel, options) {
7349
7406
  * an upgradable custom element.
7350
7407
  */
7351
7408
  const element = new UpgradableConstructor((elm) => {
7352
- createVM(elm, Ctor, {
7409
+ createVM(elm, Ctor, renderer, {
7353
7410
  tagName: sel,
7354
7411
  mode: options.mode !== 'closed' ? 'open' : 'closed',
7355
7412
  owner: null,
@@ -7433,6 +7490,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
7433
7490
  });
7434
7491
  freeze(LightningElement);
7435
7492
  seal(LightningElement.prototype);
7436
- /* version: 2.14.1 */
7493
+ /* version: 2.16.0 */
7437
7494
 
7438
- 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 };