lwc 2.14.0 → 2.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +637 -554
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +639 -553
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +574 -497
  5. package/dist/engine-dom/iife/es5/engine-dom.js +807 -694
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +729 -634
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +639 -553
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +574 -497
  11. package/dist/engine-dom/umd/es5/engine-dom.js +807 -694
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +729 -634
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +494 -473
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +492 -474
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +24 -4
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +24 -4
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +24 -4
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +29 -3
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +29 -3
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +24 -4
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +24 -4
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +29 -3
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +29 -3
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. package/package.json +7 -7
@@ -229,6 +229,7 @@ const _globalThis = /*@__PURE__*/ (function () {
229
229
  return _globalThis;
230
230
  })();
231
231
  const KEY__SHADOW_RESOLVER = '$shadowResolver$';
232
+ const KEY__SHADOW_STATIC = '$shadowStaticNode$';
232
233
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
233
234
  const KEY__SCOPED_CSS = '$scoped$';
234
235
 
@@ -410,6 +411,24 @@ function htmlPropertyToAttribute(propName) {
410
411
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
411
412
  return attributeName;
412
413
  }
414
+
415
+ /*
416
+ * Copyright (c) 2020, salesforce.com, inc.
417
+ * All rights reserved.
418
+ * SPDX-License-Identifier: MIT
419
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
420
+ */
421
+ const ESCAPED_CHARS = {
422
+ '"': '"',
423
+ "'": ''',
424
+ '<': '&lt;',
425
+ '>': '&gt;',
426
+ '&': '&amp;',
427
+ };
428
+ function htmlEscape(str, attrMode = false) {
429
+ const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
430
+ return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
431
+ }
413
432
  const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
414
433
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
415
434
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
@@ -421,9 +440,9 @@ const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
421
440
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
422
441
  */
423
442
  // Increment whenever the LWC template compiler changes
424
- const LWC_VERSION = "2.14.0";
443
+ const LWC_VERSION = "2.15.0";
425
444
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
426
- /** version: 2.14.0 */
445
+ /** version: 2.15.0 */
427
446
 
428
447
  /*
429
448
  * Copyright (c) 2020, salesforce.com, inc.
@@ -532,7 +551,7 @@ function setFeatureFlagForTest(name, value) {
532
551
  setFeatureFlag(name, value);
533
552
  }
534
553
  }
535
- /** version: 2.14.0 */
554
+ /** version: 2.15.0 */
536
555
 
537
556
  /* proxy-compat-disable */
538
557
 
@@ -615,162 +634,6 @@ function flattenStylesheets(stylesheets) {
615
634
  return list;
616
635
  }
617
636
 
618
- //
619
- // Primitives
620
- //
621
- let ssr$1;
622
- function setSsr(ssrImpl) {
623
- ssr$1 = ssrImpl;
624
- }
625
- let isNativeShadowDefined$1;
626
- function setIsNativeShadowDefined(isNativeShadowDefinedImpl) {
627
- isNativeShadowDefined$1 = isNativeShadowDefinedImpl;
628
- }
629
- let isSyntheticShadowDefined$1;
630
- function setIsSyntheticShadowDefined(isSyntheticShadowDefinedImpl) {
631
- isSyntheticShadowDefined$1 = isSyntheticShadowDefinedImpl;
632
- }
633
- let HTMLElementExported$1;
634
- function setHTMLElement(HTMLElementImpl) {
635
- HTMLElementExported$1 = HTMLElementImpl;
636
- }
637
- let insert$1;
638
- function setInsert(insertImpl) {
639
- insert$1 = insertImpl;
640
- }
641
- let remove$1;
642
- function setRemove(removeImpl) {
643
- remove$1 = removeImpl;
644
- }
645
- let createElement$1;
646
- function setCreateElement(createElementImpl) {
647
- createElement$1 = createElementImpl;
648
- }
649
- let createText$1;
650
- function setCreateText(createTextImpl) {
651
- createText$1 = createTextImpl;
652
- }
653
- let createComment$1;
654
- function setCreateComment(createCommentImpl) {
655
- createComment$1 = createCommentImpl;
656
- }
657
- let nextSibling$1;
658
- function setNextSibling(nextSiblingImpl) {
659
- nextSibling$1 = nextSiblingImpl;
660
- }
661
- let attachShadow$1;
662
- function setAttachShadow(attachShadowImpl) {
663
- attachShadow$1 = attachShadowImpl;
664
- }
665
- let getProperty$1;
666
- function setGetProperty(getPropertyImpl) {
667
- getProperty$1 = getPropertyImpl;
668
- }
669
- let setProperty$1;
670
- function setSetProperty(setPropertyImpl) {
671
- setProperty$1 = setPropertyImpl;
672
- }
673
- let setText$1;
674
- function setSetText(setTextImpl) {
675
- setText$1 = setTextImpl;
676
- }
677
- let getAttribute$1;
678
- function setGetAttribute(getAttributeImpl) {
679
- getAttribute$1 = getAttributeImpl;
680
- }
681
- let setAttribute$1;
682
- function setSetAttribute(setAttributeImpl) {
683
- setAttribute$1 = setAttributeImpl;
684
- }
685
- let removeAttribute$1;
686
- function setRemoveAttribute(removeAttributeImpl) {
687
- removeAttribute$1 = removeAttributeImpl;
688
- }
689
- let addEventListener$1;
690
- function setAddEventListener(addEventListenerImpl) {
691
- addEventListener$1 = addEventListenerImpl;
692
- }
693
- let removeEventListener$1;
694
- function setRemoveEventListener(removeEventListenerImpl) {
695
- removeEventListener$1 = removeEventListenerImpl;
696
- }
697
- let dispatchEvent$1;
698
- function setDispatchEvent(dispatchEventImpl) {
699
- dispatchEvent$1 = dispatchEventImpl;
700
- }
701
- let getClassList$1;
702
- function setGetClassList(getClassListImpl) {
703
- getClassList$1 = getClassListImpl;
704
- }
705
- let setCSSStyleProperty$1;
706
- function setSetCSSStyleProperty(setCSSStylePropertyImpl) {
707
- setCSSStyleProperty$1 = setCSSStylePropertyImpl;
708
- }
709
- let getBoundingClientRect$1;
710
- function setGetBoundingClientRect(getBoundingClientRectImpl) {
711
- getBoundingClientRect$1 = getBoundingClientRectImpl;
712
- }
713
- let querySelector$1;
714
- function setQuerySelector(querySelectorImpl) {
715
- querySelector$1 = querySelectorImpl;
716
- }
717
- let querySelectorAll$1;
718
- function setQuerySelectorAll(querySelectorAllImpl) {
719
- querySelectorAll$1 = querySelectorAllImpl;
720
- }
721
- let getElementsByTagName$1;
722
- function setGetElementsByTagName(getElementsByTagNameImpl) {
723
- getElementsByTagName$1 = getElementsByTagNameImpl;
724
- }
725
- let getElementsByClassName$1;
726
- function setGetElementsByClassName(getElementsByClassNameImpl) {
727
- getElementsByClassName$1 = getElementsByClassNameImpl;
728
- }
729
- let getChildren$1;
730
- function setGetChildren(getChildrenImpl) {
731
- getChildren$1 = getChildrenImpl;
732
- }
733
- let getChildNodes$1;
734
- function setGetChildNodes(getChildNodesImpl) {
735
- getChildNodes$1 = getChildNodesImpl;
736
- }
737
- let getFirstChild$1;
738
- function setGetFirstChild(getFirstChildImpl) {
739
- getFirstChild$1 = getFirstChildImpl;
740
- }
741
- let getFirstElementChild$1;
742
- function setGetFirstElementChild(getFirstElementChildImpl) {
743
- getFirstElementChild$1 = getFirstElementChildImpl;
744
- }
745
- let getLastChild$1;
746
- function setGetLastChild(getLastChildImpl) {
747
- getLastChild$1 = getLastChildImpl;
748
- }
749
- let getLastElementChild$1;
750
- function setGetLastElementChild(getLastElementChildImpl) {
751
- getLastElementChild$1 = getLastElementChildImpl;
752
- }
753
- let isConnected$1;
754
- function setIsConnected(isConnectedImpl) {
755
- isConnected$1 = isConnectedImpl;
756
- }
757
- let insertStylesheet$1;
758
- function setInsertStylesheet(insertStylesheetImpl) {
759
- insertStylesheet$1 = insertStylesheetImpl;
760
- }
761
- let assertInstanceOfHTMLElement$1;
762
- function setAssertInstanceOfHTMLElement(assertInstanceOfHTMLElementImpl) {
763
- assertInstanceOfHTMLElement$1 = assertInstanceOfHTMLElementImpl;
764
- }
765
- let defineCustomElement$1;
766
- function setDefineCustomElement(defineCustomElementImpl) {
767
- defineCustomElement$1 = defineCustomElementImpl;
768
- }
769
- let getCustomElement$1;
770
- function setGetCustomElement(getCustomElementImpl) {
771
- getCustomElement$1 = getCustomElementImpl;
772
- }
773
-
774
637
  /*
775
638
  * Copyright (c) 2019, salesforce.com, inc.
776
639
  * All rights reserved.
@@ -2072,7 +1935,8 @@ const LightningElement = function () {
2072
1935
  const { def, elm } = vm;
2073
1936
  const { bridge } = def;
2074
1937
  if (process.env.NODE_ENV !== 'production') {
2075
- assertInstanceOfHTMLElement$1(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
1938
+ const { assertInstanceOfHTMLElement } = vm.renderer;
1939
+ assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
2076
1940
  }
2077
1941
  const component = this;
2078
1942
  setPrototypeOf(elm, bridge.prototype);
@@ -2106,8 +1970,8 @@ const LightningElement = function () {
2106
1970
  return this;
2107
1971
  };
2108
1972
  function doAttachShadow(vm) {
2109
- const { elm, mode, shadowMode, def: { ctor }, } = vm;
2110
- const shadowRoot = attachShadow$1(elm, {
1973
+ const { elm, mode, shadowMode, def: { ctor }, renderer: { attachShadow }, } = vm;
1974
+ const shadowRoot = attachShadow(elm, {
2111
1975
  [KEY__SYNTHETIC_MODE]: shadowMode === 1 /* Synthetic */,
2112
1976
  delegatesFocus: Boolean(ctor.delegatesFocus),
2113
1977
  mode,
@@ -2128,12 +1992,13 @@ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
2128
1992
  LightningElement.prototype = {
2129
1993
  constructor: LightningElement,
2130
1994
  dispatchEvent(event) {
2131
- const { elm } = getAssociatedVM(this);
2132
- return dispatchEvent$1(elm, event);
1995
+ const vm = getAssociatedVM(this);
1996
+ const { elm, renderer: { dispatchEvent }, } = vm;
1997
+ return dispatchEvent(elm, event);
2133
1998
  },
2134
1999
  addEventListener(type, listener, options) {
2135
2000
  const vm = getAssociatedVM(this);
2136
- const { elm } = vm;
2001
+ const { elm, renderer: { addEventListener }, } = vm;
2137
2002
  if (process.env.NODE_ENV !== 'production') {
2138
2003
  const vmBeingRendered = getVMBeingRendered();
2139
2004
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
@@ -2141,83 +2006,91 @@ LightningElement.prototype = {
2141
2006
  assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
2142
2007
  }
2143
2008
  const wrappedListener = getWrappedComponentsListener(vm, listener);
2144
- addEventListener$1(elm, type, wrappedListener, options);
2009
+ addEventListener(elm, type, wrappedListener, options);
2145
2010
  },
2146
2011
  removeEventListener(type, listener, options) {
2147
2012
  const vm = getAssociatedVM(this);
2148
- const { elm } = vm;
2013
+ const { elm, renderer: { removeEventListener }, } = vm;
2149
2014
  const wrappedListener = getWrappedComponentsListener(vm, listener);
2150
- removeEventListener$1(elm, type, wrappedListener, options);
2015
+ removeEventListener(elm, type, wrappedListener, options);
2151
2016
  },
2152
2017
  hasAttribute(name) {
2153
- const { elm } = getAssociatedVM(this);
2154
- return !isNull(getAttribute$1(elm, name));
2018
+ const vm = getAssociatedVM(this);
2019
+ const { elm, renderer: { getAttribute }, } = vm;
2020
+ return !isNull(getAttribute(elm, name));
2155
2021
  },
2156
2022
  hasAttributeNS(namespace, name) {
2157
- const { elm } = getAssociatedVM(this);
2158
- return !isNull(getAttribute$1(elm, name, namespace));
2023
+ const vm = getAssociatedVM(this);
2024
+ const { elm, renderer: { getAttribute }, } = vm;
2025
+ return !isNull(getAttribute(elm, name, namespace));
2159
2026
  },
2160
2027
  removeAttribute(name) {
2161
- const { elm } = getAssociatedVM(this);
2028
+ const vm = getAssociatedVM(this);
2029
+ const { elm, renderer: { removeAttribute }, } = vm;
2162
2030
  unlockAttribute(elm, name);
2163
- removeAttribute$1(elm, name);
2031
+ removeAttribute(elm, name);
2164
2032
  lockAttribute();
2165
2033
  },
2166
2034
  removeAttributeNS(namespace, name) {
2167
- const { elm } = getAssociatedVM(this);
2035
+ const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
2168
2036
  unlockAttribute(elm, name);
2169
- removeAttribute$1(elm, name, namespace);
2037
+ removeAttribute(elm, name, namespace);
2170
2038
  lockAttribute();
2171
2039
  },
2172
2040
  getAttribute(name) {
2173
- const { elm } = getAssociatedVM(this);
2174
- return getAttribute$1(elm, name);
2041
+ const vm = getAssociatedVM(this);
2042
+ const { elm } = vm;
2043
+ const { getAttribute } = vm.renderer;
2044
+ return getAttribute(elm, name);
2175
2045
  },
2176
2046
  getAttributeNS(namespace, name) {
2177
- const { elm } = getAssociatedVM(this);
2178
- return getAttribute$1(elm, name, namespace);
2047
+ const vm = getAssociatedVM(this);
2048
+ const { elm } = vm;
2049
+ const { getAttribute } = vm.renderer;
2050
+ return getAttribute(elm, name, namespace);
2179
2051
  },
2180
2052
  setAttribute(name, value) {
2181
2053
  const vm = getAssociatedVM(this);
2182
- const { elm } = vm;
2054
+ const { elm, renderer: { setAttribute }, } = vm;
2183
2055
  if (process.env.NODE_ENV !== 'production') {
2184
2056
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2185
2057
  }
2186
2058
  unlockAttribute(elm, name);
2187
- setAttribute$1(elm, name, value);
2059
+ setAttribute(elm, name, value);
2188
2060
  lockAttribute();
2189
2061
  },
2190
2062
  setAttributeNS(namespace, name, value) {
2191
2063
  const vm = getAssociatedVM(this);
2192
- const { elm } = vm;
2064
+ const { elm, renderer: { setAttribute }, } = vm;
2193
2065
  if (process.env.NODE_ENV !== 'production') {
2194
2066
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2195
2067
  }
2196
2068
  unlockAttribute(elm, name);
2197
- setAttribute$1(elm, name, value, namespace);
2069
+ setAttribute(elm, name, value, namespace);
2198
2070
  lockAttribute();
2199
2071
  },
2200
2072
  getBoundingClientRect() {
2201
2073
  const vm = getAssociatedVM(this);
2202
- const { elm } = vm;
2074
+ const { elm, renderer: { getBoundingClientRect }, } = vm;
2203
2075
  if (process.env.NODE_ENV !== 'production') {
2204
2076
  warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
2205
2077
  }
2206
- return getBoundingClientRect$1(elm);
2078
+ return getBoundingClientRect(elm);
2207
2079
  },
2208
2080
  get isConnected() {
2209
- const { elm } = getAssociatedVM(this);
2210
- return isConnected$1(elm);
2081
+ const vm = getAssociatedVM(this);
2082
+ const { elm, renderer: { isConnected }, } = vm;
2083
+ return isConnected(elm);
2211
2084
  },
2212
2085
  get classList() {
2213
2086
  const vm = getAssociatedVM(this);
2214
- const { elm } = vm;
2087
+ const { elm, renderer: { getClassList }, } = vm;
2215
2088
  if (process.env.NODE_ENV !== 'production') {
2216
2089
  // TODO [#1290]: this still fails in dev but works in production, eventually, we should
2217
2090
  // just throw in all modes
2218
2091
  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.`);
2219
2092
  }
2220
- return getClassList$1(elm);
2093
+ return getClassList(elm);
2221
2094
  },
2222
2095
  get template() {
2223
2096
  const vm = getAssociatedVM(this);
@@ -2233,6 +2106,54 @@ LightningElement.prototype = {
2233
2106
  // Authors should rely on this.template instead.
2234
2107
  return null;
2235
2108
  },
2109
+ get children() {
2110
+ const vm = getAssociatedVM(this);
2111
+ const renderer = vm.renderer;
2112
+ if (process.env.NODE_ENV !== 'production') {
2113
+ warnIfInvokedDuringConstruction(vm, 'children');
2114
+ }
2115
+ return renderer.getChildren(vm.elm);
2116
+ },
2117
+ get childNodes() {
2118
+ const vm = getAssociatedVM(this);
2119
+ const renderer = vm.renderer;
2120
+ if (process.env.NODE_ENV !== 'production') {
2121
+ warnIfInvokedDuringConstruction(vm, 'childNodes');
2122
+ }
2123
+ return renderer.getChildNodes(vm.elm);
2124
+ },
2125
+ get firstChild() {
2126
+ const vm = getAssociatedVM(this);
2127
+ const renderer = vm.renderer;
2128
+ if (process.env.NODE_ENV !== 'production') {
2129
+ warnIfInvokedDuringConstruction(vm, 'firstChild');
2130
+ }
2131
+ return renderer.getFirstChild(vm.elm);
2132
+ },
2133
+ get firstElementChild() {
2134
+ const vm = getAssociatedVM(this);
2135
+ const renderer = vm.renderer;
2136
+ if (process.env.NODE_ENV !== 'production') {
2137
+ warnIfInvokedDuringConstruction(vm, 'firstElementChild');
2138
+ }
2139
+ return renderer.getFirstElementChild(vm.elm);
2140
+ },
2141
+ get lastChild() {
2142
+ const vm = getAssociatedVM(this);
2143
+ const renderer = vm.renderer;
2144
+ if (process.env.NODE_ENV !== 'production') {
2145
+ warnIfInvokedDuringConstruction(vm, 'lastChild');
2146
+ }
2147
+ return renderer.getLastChild(vm.elm);
2148
+ },
2149
+ get lastElementChild() {
2150
+ const vm = getAssociatedVM(this);
2151
+ const renderer = vm.renderer;
2152
+ if (process.env.NODE_ENV !== 'production') {
2153
+ warnIfInvokedDuringConstruction(vm, 'lastElementChild');
2154
+ }
2155
+ return renderer.getLastElementChild(vm.elm);
2156
+ },
2236
2157
  render() {
2237
2158
  const vm = getAssociatedVM(this);
2238
2159
  return vm.def.template;
@@ -2243,76 +2164,22 @@ LightningElement.prototype = {
2243
2164
  },
2244
2165
  };
2245
2166
  const queryAndChildGetterDescriptors = create(null);
2246
- // The reason we don't just call `import * as renderer from '../renderer'` here is that the bundle size
2247
- // is smaller if we reference each function individually. Otherwise Rollup will create one big frozen
2248
- // object representing the renderer, with a lot of methods we don't actually need.
2249
- const childGetters = [
2250
- 'children',
2251
- 'childNodes',
2252
- 'firstChild',
2253
- 'firstElementChild',
2254
- 'lastChild',
2255
- 'lastElementChild',
2256
- ];
2257
- function getChildGetter(methodName) {
2258
- switch (methodName) {
2259
- case 'children':
2260
- return getChildren$1;
2261
- case 'childNodes':
2262
- return getChildNodes$1;
2263
- case 'firstChild':
2264
- return getFirstChild$1;
2265
- case 'firstElementChild':
2266
- return getFirstElementChild$1;
2267
- case 'lastChild':
2268
- return getLastChild$1;
2269
- case 'lastElementChild':
2270
- return getLastElementChild$1;
2271
- }
2272
- }
2273
- // Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
2274
- for (const childGetter of childGetters) {
2275
- queryAndChildGetterDescriptors[childGetter] = {
2276
- get() {
2277
- const vm = getAssociatedVM(this);
2278
- const { elm } = vm;
2279
- if (process.env.NODE_ENV !== 'production') {
2280
- warnIfInvokedDuringConstruction(vm, childGetter);
2281
- }
2282
- return getChildGetter(childGetter)(elm);
2283
- },
2284
- configurable: true,
2285
- enumerable: true,
2286
- };
2287
- }
2288
2167
  const queryMethods = [
2289
2168
  'getElementsByClassName',
2290
2169
  'getElementsByTagName',
2291
2170
  'querySelector',
2292
2171
  'querySelectorAll',
2293
2172
  ];
2294
- function getQueryMethod(methodName) {
2295
- switch (methodName) {
2296
- case 'getElementsByClassName':
2297
- return getElementsByClassName$1;
2298
- case 'getElementsByTagName':
2299
- return getElementsByTagName$1;
2300
- case 'querySelector':
2301
- return querySelector$1;
2302
- case 'querySelectorAll':
2303
- return querySelectorAll$1;
2304
- }
2305
- }
2306
2173
  // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
2307
2174
  for (const queryMethod of queryMethods) {
2308
2175
  queryAndChildGetterDescriptors[queryMethod] = {
2309
2176
  value(arg) {
2310
2177
  const vm = getAssociatedVM(this);
2311
- const { elm } = vm;
2178
+ const { elm, renderer } = vm;
2312
2179
  if (process.env.NODE_ENV !== 'production') {
2313
2180
  warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
2314
2181
  }
2315
- return getQueryMethod(queryMethod)(elm, arg);
2182
+ return renderer[queryMethod](elm, arg);
2316
2183
  },
2317
2184
  configurable: true,
2318
2185
  enumerable: true,
@@ -2817,7 +2684,8 @@ function getDecoratorsMeta(Ctor) {
2817
2684
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2818
2685
  */
2819
2686
  let warned = false;
2820
- if (process.env.NODE_ENV === 'development') {
2687
+ // @ts-ignore
2688
+ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
2821
2689
  // @ts-ignore
2822
2690
  window.__lwcResetWarnedOnVersionMismatch = () => {
2823
2691
  warned = false;
@@ -3414,12 +3282,13 @@ function getComponentDef(Ctor) {
3414
3282
  * SPDX-License-Identifier: MIT
3415
3283
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3416
3284
  */
3417
- function getUpgradableConstructor(tagName) {
3285
+ function getUpgradableConstructor(tagName, renderer) {
3286
+ const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
3418
3287
  // Should never get a tag with upper case letter at this point, the compiler should
3419
3288
  // produce only tags with lowercase letters
3420
3289
  // But, for backwards compatibility, we will lower case the tagName
3421
3290
  tagName = tagName.toLowerCase();
3422
- let CE = getCustomElement$1(tagName);
3291
+ let CE = getCustomElement(tagName);
3423
3292
  if (!isUndefined$1(CE)) {
3424
3293
  return CE;
3425
3294
  }
@@ -3427,7 +3296,7 @@ function getUpgradableConstructor(tagName) {
3427
3296
  * LWC Upgradable Element reference to an element that was created
3428
3297
  * via the scoped registry mechanism, and that is ready to be upgraded.
3429
3298
  */
3430
- CE = class LWCUpgradableElement extends HTMLElementExported$1 {
3299
+ CE = class LWCUpgradableElement extends RendererHTMLElement {
3431
3300
  constructor(upgradeCallback) {
3432
3301
  super();
3433
3302
  if (isFunction$1(upgradeCallback)) {
@@ -3435,7 +3304,7 @@ function getUpgradableConstructor(tagName) {
3435
3304
  }
3436
3305
  }
3437
3306
  };
3438
- defineCustomElement$1(tagName, CE);
3307
+ defineCustomElement(tagName, CE);
3439
3308
  return CE;
3440
3309
  }
3441
3310
 
@@ -3460,7 +3329,7 @@ function isSameVnode(vnode1, vnode2) {
3460
3329
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3461
3330
  */
3462
3331
  const ColonCharCode = 58;
3463
- function patchAttributes(oldVnode, vnode) {
3332
+ function patchAttributes(oldVnode, vnode, renderer) {
3464
3333
  const { attrs } = vnode.data;
3465
3334
  if (isUndefined$1(attrs)) {
3466
3335
  return;
@@ -3470,6 +3339,7 @@ function patchAttributes(oldVnode, vnode) {
3470
3339
  return;
3471
3340
  }
3472
3341
  const { elm } = vnode;
3342
+ const { setAttribute, removeAttribute } = renderer;
3473
3343
  for (const key in attrs) {
3474
3344
  const cur = attrs[key];
3475
3345
  const old = oldAttrs[key];
@@ -3477,17 +3347,17 @@ function patchAttributes(oldVnode, vnode) {
3477
3347
  unlockAttribute(elm, key);
3478
3348
  if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
3479
3349
  // Assume xml namespace
3480
- setAttribute$1(elm, key, cur, XML_NAMESPACE);
3350
+ setAttribute(elm, key, cur, XML_NAMESPACE);
3481
3351
  }
3482
3352
  else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
3483
3353
  // Assume xlink namespace
3484
- setAttribute$1(elm, key, cur, XLINK_NAMESPACE);
3354
+ setAttribute(elm, key, cur, XLINK_NAMESPACE);
3485
3355
  }
3486
3356
  else if (isNull(cur) || isUndefined$1(cur)) {
3487
- removeAttribute$1(elm, key);
3357
+ removeAttribute(elm, key);
3488
3358
  }
3489
3359
  else {
3490
- setAttribute$1(elm, key, cur);
3360
+ setAttribute(elm, key, cur);
3491
3361
  }
3492
3362
  lockAttribute();
3493
3363
  }
@@ -3505,7 +3375,7 @@ function isLiveBindingProp(sel, key) {
3505
3375
  // instead of relying on internally tracked values.
3506
3376
  return sel === 'input' && (key === 'value' || key === 'checked');
3507
3377
  }
3508
- function patchProps(oldVnode, vnode) {
3378
+ function patchProps(oldVnode, vnode, renderer) {
3509
3379
  const { props } = vnode.data;
3510
3380
  if (isUndefined$1(props)) {
3511
3381
  return;
@@ -3516,13 +3386,14 @@ function patchProps(oldVnode, vnode) {
3516
3386
  }
3517
3387
  const isFirstPatch = isNull(oldVnode);
3518
3388
  const { elm, sel } = vnode;
3389
+ const { getProperty, setProperty } = renderer;
3519
3390
  for (const key in props) {
3520
3391
  const cur = props[key];
3521
3392
  // Set the property if it's the first time is is patched or if the previous property is
3522
3393
  // different than the one previously set.
3523
3394
  if (isFirstPatch ||
3524
- cur !== (isLiveBindingProp(sel, key) ? getProperty$1(elm, key) : oldProps[key])) {
3525
- setProperty$1(elm, key, cur);
3395
+ cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
3396
+ setProperty(elm, key, cur);
3526
3397
  }
3527
3398
  }
3528
3399
  }
@@ -3567,13 +3438,14 @@ function getMapFromClassName(className) {
3567
3438
  }
3568
3439
  return map;
3569
3440
  }
3570
- function patchClassAttribute(oldVnode, vnode) {
3441
+ function patchClassAttribute(oldVnode, vnode, renderer) {
3571
3442
  const { elm, data: { className: newClass }, } = vnode;
3572
3443
  const oldClass = isNull(oldVnode) ? undefined : oldVnode.data.className;
3573
3444
  if (oldClass === newClass) {
3574
3445
  return;
3575
3446
  }
3576
- const classList = getClassList$1(elm);
3447
+ const { getClassList } = renderer;
3448
+ const classList = getClassList(elm);
3577
3449
  const newClassMap = getMapFromClassName(newClass);
3578
3450
  const oldClassMap = getMapFromClassName(oldClass);
3579
3451
  let name;
@@ -3597,17 +3469,18 @@ function patchClassAttribute(oldVnode, vnode) {
3597
3469
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3598
3470
  */
3599
3471
  // The style property is a string when defined via an expression in the template.
3600
- function patchStyleAttribute(oldVnode, vnode) {
3472
+ function patchStyleAttribute(oldVnode, vnode, renderer) {
3601
3473
  const { elm, data: { style: newStyle }, } = vnode;
3602
3474
  const oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
3603
3475
  if (oldStyle === newStyle) {
3604
3476
  return;
3605
3477
  }
3478
+ const { setAttribute, removeAttribute } = renderer;
3606
3479
  if (!isString(newStyle) || newStyle === '') {
3607
- removeAttribute$1(elm, 'style');
3480
+ removeAttribute(elm, 'style');
3608
3481
  }
3609
3482
  else {
3610
- setAttribute$1(elm, 'style', newStyle);
3483
+ setAttribute(elm, 'style', newStyle);
3611
3484
  }
3612
3485
  }
3613
3486
 
@@ -3617,14 +3490,15 @@ function patchStyleAttribute(oldVnode, vnode) {
3617
3490
  * SPDX-License-Identifier: MIT
3618
3491
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3619
3492
  */
3620
- function applyEventListeners(vnode) {
3493
+ function applyEventListeners(vnode, renderer) {
3621
3494
  const { elm, data: { on }, } = vnode;
3622
3495
  if (isUndefined$1(on)) {
3623
3496
  return;
3624
3497
  }
3498
+ const { addEventListener } = renderer;
3625
3499
  for (const name in on) {
3626
3500
  const handler = on[name];
3627
- addEventListener$1(elm, name, handler);
3501
+ addEventListener(elm, name, handler);
3628
3502
  }
3629
3503
  }
3630
3504
 
@@ -3637,12 +3511,13 @@ function applyEventListeners(vnode) {
3637
3511
  // The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
3638
3512
  // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
3639
3513
  // different classnames properties individually instead of via a string.
3640
- function applyStaticClassAttribute(vnode) {
3514
+ function applyStaticClassAttribute(vnode, renderer) {
3641
3515
  const { elm, data: { classMap }, } = vnode;
3642
3516
  if (isUndefined$1(classMap)) {
3643
3517
  return;
3644
3518
  }
3645
- const classList = getClassList$1(elm);
3519
+ const { getClassList } = renderer;
3520
+ const classList = getClassList(elm);
3646
3521
  for (const name in classMap) {
3647
3522
  classList.add(name);
3648
3523
  }
@@ -3657,14 +3532,15 @@ function applyStaticClassAttribute(vnode) {
3657
3532
  // The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
3658
3533
  // The compiler takes care of transforming the inline style into an object. It's faster to set the
3659
3534
  // different style properties individually instead of via a string.
3660
- function applyStaticStyleAttribute(vnode) {
3535
+ function applyStaticStyleAttribute(vnode, renderer) {
3661
3536
  const { elm, data: { styleDecls }, } = vnode;
3662
3537
  if (isUndefined$1(styleDecls)) {
3663
3538
  return;
3664
3539
  }
3540
+ const { setCSSStyleProperty } = renderer;
3665
3541
  for (let i = 0; i < styleDecls.length; i++) {
3666
3542
  const [prop, value, important] = styleDecls[i];
3667
- setCSSStyleProperty$1(elm, prop, value, important);
3543
+ setCSSStyleProperty(elm, prop, value, important);
3668
3544
  }
3669
3545
  }
3670
3546
 
@@ -3674,15 +3550,16 @@ function applyStaticStyleAttribute(vnode) {
3674
3550
  * SPDX-License-Identifier: MIT
3675
3551
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3676
3552
  */
3677
- function patchChildren(c1, c2, parent) {
3553
+ function patchChildren(c1, c2, parent, renderer) {
3678
3554
  if (hasDynamicChildren(c2)) {
3679
- updateDynamicChildren(c1, c2, parent);
3555
+ updateDynamicChildren(c1, c2, parent, renderer);
3680
3556
  }
3681
3557
  else {
3682
- updateStaticChildren(c1, c2, parent);
3558
+ updateStaticChildren(c1, c2, parent, renderer);
3683
3559
  }
3684
3560
  }
3685
- function patch(n1, n2) {
3561
+ function patch(n1, n2, renderer) {
3562
+ var _a, _b;
3686
3563
  if (n1 === n2) {
3687
3564
  return;
3688
3565
  }
@@ -3696,80 +3573,115 @@ function patch(n1, n2) {
3696
3573
  }
3697
3574
  switch (n2.type) {
3698
3575
  case 0 /* Text */:
3699
- patchText(n1, n2);
3576
+ // VText has no special capability, fallback to the owner's renderer
3577
+ patchText(n1, n2, renderer);
3700
3578
  break;
3701
3579
  case 1 /* Comment */:
3702
- patchComment(n1, n2);
3580
+ // VComment has no special capability, fallback to the owner's renderer
3581
+ patchComment(n1, n2, renderer);
3582
+ break;
3583
+ case 4 /* Static */:
3584
+ n2.elm = n1.elm;
3703
3585
  break;
3704
3586
  case 2 /* Element */:
3705
- patchElement(n1, n2);
3587
+ patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3706
3588
  break;
3707
3589
  case 3 /* CustomElement */:
3708
- patchCustomElement(n1, n2);
3590
+ patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3709
3591
  break;
3710
3592
  }
3711
3593
  }
3712
- function mount(node, parent, anchor) {
3594
+ function mount(node, parent, renderer, anchor) {
3595
+ var _a, _b;
3713
3596
  switch (node.type) {
3714
3597
  case 0 /* Text */:
3715
- mountText(node, parent, anchor);
3598
+ // VText has no special capability, fallback to the owner's renderer
3599
+ mountText(node, parent, anchor, renderer);
3716
3600
  break;
3717
3601
  case 1 /* Comment */:
3718
- mountComment(node, parent, anchor);
3602
+ // VComment has no special capability, fallback to the owner's renderer
3603
+ mountComment(node, parent, anchor, renderer);
3604
+ break;
3605
+ case 4 /* Static */:
3606
+ // VStatic cannot have a custom renderer associated to them, using owner's renderer
3607
+ mountStatic(node, parent, anchor, renderer);
3719
3608
  break;
3720
3609
  case 2 /* Element */:
3721
- mountElement(node, parent, anchor);
3610
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3611
+ mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3722
3612
  break;
3723
3613
  case 3 /* CustomElement */:
3724
- mountCustomElement(node, parent, anchor);
3614
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3615
+ mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3725
3616
  break;
3726
3617
  }
3727
3618
  }
3728
- function patchText(n1, n2) {
3619
+ function patchText(n1, n2, renderer) {
3729
3620
  n2.elm = n1.elm;
3730
3621
  if (n2.text !== n1.text) {
3731
- updateTextContent(n2);
3622
+ updateTextContent(n2, renderer);
3732
3623
  }
3733
3624
  }
3734
- function mountText(node, parent, anchor) {
3735
- const { owner } = node;
3736
- const textNode = (node.elm = createText$1(node.text));
3737
- linkNodeToShadow(textNode, owner);
3738
- insertNode(textNode, parent, anchor);
3625
+ function mountText(vnode, parent, anchor, renderer) {
3626
+ const { owner } = vnode;
3627
+ const { createText } = renderer;
3628
+ const textNode = (vnode.elm = createText(vnode.text));
3629
+ linkNodeToShadow(textNode, owner, renderer);
3630
+ insertNode(textNode, parent, anchor, renderer);
3739
3631
  }
3740
- function patchComment(n1, n2) {
3632
+ function patchComment(n1, n2, renderer) {
3741
3633
  n2.elm = n1.elm;
3742
3634
  // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3743
3635
  // it is the case today.
3744
3636
  if (n2.text !== n1.text) {
3745
- updateTextContent(n2);
3637
+ updateTextContent(n2, renderer);
3746
3638
  }
3747
3639
  }
3748
- function mountComment(node, parent, anchor) {
3749
- const { owner } = node;
3750
- const commentNode = (node.elm = createComment$1(node.text));
3751
- linkNodeToShadow(commentNode, owner);
3752
- insertNode(commentNode, parent, anchor);
3640
+ function mountComment(vnode, parent, anchor, renderer) {
3641
+ const { owner } = vnode;
3642
+ const { createComment } = renderer;
3643
+ const commentNode = (vnode.elm = createComment(vnode.text));
3644
+ linkNodeToShadow(commentNode, owner, renderer);
3645
+ insertNode(commentNode, parent, anchor, renderer);
3753
3646
  }
3754
- function mountElement(vnode, parent, anchor) {
3647
+ function mountElement(vnode, parent, anchor, renderer) {
3755
3648
  const { sel, owner, data: { svg }, } = vnode;
3649
+ const { createElement } = renderer;
3756
3650
  const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3757
- const elm = createElement$1(sel, namespace);
3758
- linkNodeToShadow(elm, owner);
3759
- fallbackElmHook(elm, vnode);
3651
+ const elm = createElement(sel, namespace);
3652
+ linkNodeToShadow(elm, owner, renderer);
3653
+ fallbackElmHook(elm, vnode, renderer);
3760
3654
  vnode.elm = elm;
3761
- patchElementPropsAndAttrs$1(null, vnode);
3762
- insertNode(elm, parent, anchor);
3763
- mountVNodes(vnode.children, elm, null);
3655
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3656
+ insertNode(elm, parent, anchor, renderer);
3657
+ mountVNodes(vnode.children, elm, renderer, null);
3764
3658
  }
3765
- function patchElement(n1, n2) {
3659
+ function patchElement(n1, n2, renderer) {
3766
3660
  const elm = (n2.elm = n1.elm);
3767
- patchElementPropsAndAttrs$1(n1, n2);
3768
- patchChildren(n1.children, n2.children, elm);
3661
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3662
+ patchChildren(n1.children, n2.children, elm, renderer);
3769
3663
  }
3770
- function mountCustomElement(vnode, parent, anchor) {
3664
+ function mountStatic(vnode, parent, anchor, renderer) {
3665
+ const { owner } = vnode;
3666
+ const { cloneNode, isSyntheticShadowDefined } = renderer;
3667
+ const elm = (vnode.elm = cloneNode(vnode.fragment, true));
3668
+ linkNodeToShadow(elm, owner, renderer);
3669
+ // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3670
+ const { renderMode, shadowMode } = owner;
3671
+ if (isSyntheticShadowDefined) {
3672
+ if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
3673
+ elm[KEY__SHADOW_STATIC] = true;
3674
+ }
3675
+ }
3676
+ if (process.env.NODE_ENV !== 'production') {
3677
+ const isLight = renderMode === 0 /* Light */;
3678
+ patchElementWithRestrictions(elm, { isPortal: false, isLight });
3679
+ }
3680
+ insertNode(elm, parent, anchor, renderer);
3681
+ }
3682
+ function mountCustomElement(vnode, parent, anchor, renderer) {
3771
3683
  const { sel, owner } = vnode;
3772
- const UpgradableConstructor = getUpgradableConstructor(sel);
3684
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3773
3685
  /**
3774
3686
  * Note: if the upgradable constructor does not expect, or throw when we new it
3775
3687
  * with a callback as the first argument, we could implement a more advanced
@@ -3779,9 +3691,9 @@ function mountCustomElement(vnode, parent, anchor) {
3779
3691
  let vm;
3780
3692
  const elm = new UpgradableConstructor((elm) => {
3781
3693
  // the custom element from the registry is expecting an upgrade callback
3782
- vm = createViewModelHook(elm, vnode);
3694
+ vm = createViewModelHook(elm, vnode, renderer);
3783
3695
  });
3784
- linkNodeToShadow(elm, owner);
3696
+ linkNodeToShadow(elm, owner, renderer);
3785
3697
  vnode.elm = elm;
3786
3698
  vnode.vm = vm;
3787
3699
  if (vm) {
@@ -3790,23 +3702,23 @@ function mountCustomElement(vnode, parent, anchor) {
3790
3702
  else if (vnode.ctor !== UpgradableConstructor) {
3791
3703
  throw new TypeError(`Incorrect Component Constructor`);
3792
3704
  }
3793
- patchElementPropsAndAttrs$1(null, vnode);
3794
- insertNode(elm, parent, anchor);
3705
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3706
+ insertNode(elm, parent, anchor, renderer);
3795
3707
  if (vm) {
3796
3708
  if (process.env.NODE_ENV !== 'production') {
3797
3709
  assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
3798
3710
  }
3799
3711
  runConnectedCallback(vm);
3800
3712
  }
3801
- mountVNodes(vnode.children, elm, null);
3713
+ mountVNodes(vnode.children, elm, renderer, null);
3802
3714
  if (vm) {
3803
3715
  appendVM(vm);
3804
3716
  }
3805
3717
  }
3806
- function patchCustomElement(n1, n2) {
3718
+ function patchCustomElement(n1, n2, renderer) {
3807
3719
  const elm = (n2.elm = n1.elm);
3808
3720
  const vm = (n2.vm = n1.vm);
3809
- patchElementPropsAndAttrs$1(n1, n2);
3721
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3810
3722
  if (!isUndefined$1(vm)) {
3811
3723
  // in fallback mode, the allocation will always set children to
3812
3724
  // empty and delegate the real allocation to the slot elements
@@ -3814,33 +3726,38 @@ function patchCustomElement(n1, n2) {
3814
3726
  }
3815
3727
  // in fallback mode, the children will be always empty, so, nothing
3816
3728
  // will happen, but in native, it does allocate the light dom
3817
- patchChildren(n1.children, n2.children, elm);
3729
+ patchChildren(n1.children, n2.children, elm, renderer);
3818
3730
  if (!isUndefined$1(vm)) {
3819
3731
  // this will probably update the shadowRoot, but only if the vm is in a dirty state
3820
3732
  // this is important to preserve the top to bottom synchronous rendering phase.
3821
3733
  rerenderVM(vm);
3822
3734
  }
3823
3735
  }
3824
- function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
3736
+ function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
3825
3737
  for (; start < end; ++start) {
3826
3738
  const vnode = vnodes[start];
3827
3739
  if (isVNode(vnode)) {
3828
- mount(vnode, parent, anchor);
3740
+ mount(vnode, parent, renderer, anchor);
3829
3741
  }
3830
3742
  }
3831
3743
  }
3832
- function unmount(vnode, parent, doRemove = false) {
3744
+ function unmount(vnode, parent, renderer, doRemove = false) {
3833
3745
  const { type, elm, sel } = vnode;
3834
3746
  // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3835
3747
  // subtree root, is the only element worth unmounting from the subtree.
3836
3748
  if (doRemove) {
3837
- removeNode(elm, parent);
3749
+ // The vnode might or might not have a data.renderer associated to it
3750
+ // but the removal used here is from the owner instead.
3751
+ removeNode(elm, parent, renderer);
3838
3752
  }
3839
- const removeChildren = sel === 'slot'; // slot content is removed to trigger slotchange event when removing slot
3840
3753
  switch (type) {
3841
- case 2 /* Element */:
3842
- unmountVNodes(vnode.children, elm, removeChildren);
3754
+ case 2 /* Element */: {
3755
+ // Slot content is removed to trigger slotchange event when removing slot.
3756
+ // Only required for synthetic shadow.
3757
+ const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
3758
+ unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
3843
3759
  break;
3760
+ }
3844
3761
  case 3 /* CustomElement */: {
3845
3762
  const { vm } = vnode;
3846
3763
  // No need to unmount the children here, `removeVM` will take care of removing the
@@ -3851,11 +3768,11 @@ function unmount(vnode, parent, doRemove = false) {
3851
3768
  }
3852
3769
  }
3853
3770
  }
3854
- function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
3771
+ function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
3855
3772
  for (; start < end; ++start) {
3856
3773
  const ch = vnodes[start];
3857
3774
  if (isVNode(ch)) {
3858
- unmount(ch, parent, doRemove);
3775
+ unmount(ch, parent, renderer, doRemove);
3859
3776
  }
3860
3777
  }
3861
3778
  }
@@ -3869,66 +3786,71 @@ function setElementShadowToken(elm, token) {
3869
3786
  elm.$shadowToken$ = token;
3870
3787
  }
3871
3788
  // Set the scope token class for *.scoped.css styles
3872
- function setScopeTokenClassIfNecessary(elm, owner) {
3789
+ function setScopeTokenClassIfNecessary(elm, owner, renderer) {
3873
3790
  const { cmpTemplate, context } = owner;
3791
+ const { getClassList } = renderer;
3874
3792
  const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
3875
3793
  if (!isUndefined$1(token) && context.hasScopedStyles) {
3876
- getClassList$1(elm).add(token);
3794
+ // TODO [#2762]: this dot notation with add is probably problematic
3795
+ // probably we should have a renderer api for just the add operation
3796
+ getClassList(elm).add(token);
3877
3797
  }
3878
3798
  }
3879
- function linkNodeToShadow(elm, owner) {
3799
+ function linkNodeToShadow(elm, owner, renderer) {
3880
3800
  const { renderRoot, renderMode, shadowMode } = owner;
3801
+ const { isSyntheticShadowDefined } = renderer;
3881
3802
  // TODO [#1164]: this should eventually be done by the polyfill directly
3882
- if (isSyntheticShadowDefined$1) {
3803
+ if (isSyntheticShadowDefined) {
3883
3804
  if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
3884
3805
  elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
3885
3806
  }
3886
3807
  }
3887
3808
  }
3888
- function updateTextContent(vnode) {
3809
+ function updateTextContent(vnode, renderer) {
3889
3810
  const { elm, text } = vnode;
3811
+ const { setText } = renderer;
3890
3812
  if (process.env.NODE_ENV !== 'production') {
3891
3813
  unlockDomMutation();
3892
3814
  }
3893
- setText$1(elm, text);
3815
+ setText(elm, text);
3894
3816
  if (process.env.NODE_ENV !== 'production') {
3895
3817
  lockDomMutation();
3896
3818
  }
3897
3819
  }
3898
- function insertNode(node, parent, anchor) {
3820
+ function insertNode(node, parent, anchor, renderer) {
3899
3821
  if (process.env.NODE_ENV !== 'production') {
3900
3822
  unlockDomMutation();
3901
3823
  }
3902
- insert$1(node, parent, anchor);
3824
+ renderer.insert(node, parent, anchor);
3903
3825
  if (process.env.NODE_ENV !== 'production') {
3904
3826
  lockDomMutation();
3905
3827
  }
3906
3828
  }
3907
- function removeNode(node, parent) {
3829
+ function removeNode(node, parent, renderer) {
3908
3830
  if (process.env.NODE_ENV !== 'production') {
3909
3831
  unlockDomMutation();
3910
3832
  }
3911
- remove$1(node, parent);
3833
+ renderer.remove(node, parent);
3912
3834
  if (process.env.NODE_ENV !== 'production') {
3913
3835
  lockDomMutation();
3914
3836
  }
3915
3837
  }
3916
- function patchElementPropsAndAttrs$1(oldVnode, vnode) {
3838
+ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
3917
3839
  if (isNull(oldVnode)) {
3918
- applyEventListeners(vnode);
3919
- applyStaticClassAttribute(vnode);
3920
- applyStaticStyleAttribute(vnode);
3840
+ applyEventListeners(vnode, renderer);
3841
+ applyStaticClassAttribute(vnode, renderer);
3842
+ applyStaticStyleAttribute(vnode, renderer);
3921
3843
  }
3922
3844
  // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
3923
3845
  // value is set before type=radio.
3924
- patchClassAttribute(oldVnode, vnode);
3925
- patchStyleAttribute(oldVnode, vnode);
3926
- patchAttributes(oldVnode, vnode);
3927
- patchProps(oldVnode, vnode);
3846
+ patchClassAttribute(oldVnode, vnode, renderer);
3847
+ patchStyleAttribute(oldVnode, vnode, renderer);
3848
+ patchAttributes(oldVnode, vnode, renderer);
3849
+ patchProps(oldVnode, vnode, renderer);
3928
3850
  }
3929
- function fallbackElmHook(elm, vnode) {
3851
+ function fallbackElmHook(elm, vnode, renderer) {
3930
3852
  const { owner } = vnode;
3931
- setScopeTokenClassIfNecessary(elm, owner);
3853
+ setScopeTokenClassIfNecessary(elm, owner, renderer);
3932
3854
  if (owner.shadowMode === 1 /* Synthetic */) {
3933
3855
  const { data: { context }, } = vnode;
3934
3856
  const { stylesheetToken } = owner.context;
@@ -3976,7 +3898,7 @@ function allocateChildren(vnode, vm) {
3976
3898
  vnode.children = EmptyArray;
3977
3899
  }
3978
3900
  }
3979
- function createViewModelHook(elm, vnode) {
3901
+ function createViewModelHook(elm, vnode, renderer) {
3980
3902
  let vm = getAssociatedVMIfPresent(elm);
3981
3903
  // There is a possibility that a custom element is registered under tagName, in which case, the
3982
3904
  // initialization is already carry on, and there is nothing else to do here since this hook is
@@ -3985,7 +3907,7 @@ function createViewModelHook(elm, vnode) {
3985
3907
  return vm;
3986
3908
  }
3987
3909
  const { sel, mode, ctor, owner } = vnode;
3988
- setScopeTokenClassIfNecessary(elm, owner);
3910
+ setScopeTokenClassIfNecessary(elm, owner, renderer);
3989
3911
  if (owner.shadowMode === 1 /* Synthetic */) {
3990
3912
  const { stylesheetToken } = owner.context;
3991
3913
  // when running in synthetic shadow mode, we need to set the shadowToken value
@@ -3994,7 +3916,7 @@ function createViewModelHook(elm, vnode) {
3994
3916
  setElementShadowToken(elm, stylesheetToken);
3995
3917
  }
3996
3918
  }
3997
- vm = createVM(elm, ctor, {
3919
+ vm = createVM(elm, ctor, renderer, {
3998
3920
  mode,
3999
3921
  owner,
4000
3922
  tagName: sel,
@@ -4069,7 +3991,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
4069
3991
  }
4070
3992
  return map;
4071
3993
  }
4072
- function updateDynamicChildren(oldCh, newCh, parent) {
3994
+ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4073
3995
  let oldStartIdx = 0;
4074
3996
  let newStartIdx = 0;
4075
3997
  let oldEndIdx = oldCh.length - 1;
@@ -4098,26 +4020,26 @@ function updateDynamicChildren(oldCh, newCh, parent) {
4098
4020
  newEndVnode = newCh[--newEndIdx];
4099
4021
  }
4100
4022
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4101
- patch(oldStartVnode, newStartVnode);
4023
+ patch(oldStartVnode, newStartVnode, renderer);
4102
4024
  oldStartVnode = oldCh[++oldStartIdx];
4103
4025
  newStartVnode = newCh[++newStartIdx];
4104
4026
  }
4105
4027
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4106
- patch(oldEndVnode, newEndVnode);
4028
+ patch(oldEndVnode, newEndVnode, renderer);
4107
4029
  oldEndVnode = oldCh[--oldEndIdx];
4108
4030
  newEndVnode = newCh[--newEndIdx];
4109
4031
  }
4110
4032
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4111
4033
  // Vnode moved right
4112
- patch(oldStartVnode, newEndVnode);
4113
- insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
4034
+ patch(oldStartVnode, newEndVnode, renderer);
4035
+ insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4114
4036
  oldStartVnode = oldCh[++oldStartIdx];
4115
4037
  newEndVnode = newCh[--newEndIdx];
4116
4038
  }
4117
4039
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4118
4040
  // Vnode moved left
4119
- patch(oldEndVnode, newStartVnode);
4120
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
4041
+ patch(oldEndVnode, newStartVnode, renderer);
4042
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4121
4043
  oldEndVnode = oldCh[--oldEndIdx];
4122
4044
  newStartVnode = newCh[++newStartIdx];
4123
4045
  }
@@ -4128,7 +4050,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
4128
4050
  idxInOld = oldKeyToIdx[newStartVnode.key];
4129
4051
  if (isUndefined$1(idxInOld)) {
4130
4052
  // New element
4131
- mount(newStartVnode, parent, oldStartVnode.elm);
4053
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4132
4054
  newStartVnode = newCh[++newStartIdx];
4133
4055
  }
4134
4056
  else {
@@ -4136,10 +4058,10 @@ function updateDynamicChildren(oldCh, newCh, parent) {
4136
4058
  if (isVNode(elmToMove)) {
4137
4059
  if (elmToMove.sel !== newStartVnode.sel) {
4138
4060
  // New element
4139
- mount(newStartVnode, parent, oldStartVnode.elm);
4061
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4140
4062
  }
4141
4063
  else {
4142
- patch(elmToMove, newStartVnode);
4064
+ patch(elmToMove, newStartVnode, renderer);
4143
4065
  // Delete the old child, but copy the array since it is read-only.
4144
4066
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4145
4067
  // so we only care about the `oldCh` object inside this function.
@@ -4151,7 +4073,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
4151
4073
  }
4152
4074
  // We've already cloned at least once, so it's no longer read-only
4153
4075
  oldCh[idxInOld] = undefined;
4154
- insertNode(elmToMove.elm, parent, oldStartVnode.elm);
4076
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4155
4077
  }
4156
4078
  }
4157
4079
  newStartVnode = newCh[++newStartIdx];
@@ -4168,25 +4090,25 @@ function updateDynamicChildren(oldCh, newCh, parent) {
4168
4090
  n = newCh[++i];
4169
4091
  } while (!isVNode(n) && i < newChEnd);
4170
4092
  before = isVNode(n) ? n.elm : null;
4171
- mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
4093
+ mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
4172
4094
  }
4173
4095
  else {
4174
- unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
4096
+ unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
4175
4097
  }
4176
4098
  }
4177
4099
  }
4178
- function updateStaticChildren(c1, c2, parent) {
4100
+ function updateStaticChildren(c1, c2, parent, renderer) {
4179
4101
  const c1Length = c1.length;
4180
4102
  const c2Length = c2.length;
4181
4103
  if (c1Length === 0) {
4182
4104
  // the old list is empty, we can directly insert anything new
4183
- mountVNodes(c2, parent, null);
4105
+ mountVNodes(c2, parent, renderer, null);
4184
4106
  return;
4185
4107
  }
4186
4108
  if (c2Length === 0) {
4187
4109
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4188
4110
  // this is the case in which the dynamic children of an if-directive should be removed
4189
- unmountVNodes(c1, parent, true);
4111
+ unmountVNodes(c1, parent, renderer, true);
4190
4112
  return;
4191
4113
  }
4192
4114
  // if the old list is not empty, the new list MUST have the same
@@ -4199,16 +4121,16 @@ function updateStaticChildren(c1, c2, parent) {
4199
4121
  if (isVNode(n1)) {
4200
4122
  if (isVNode(n2)) {
4201
4123
  // both vnodes are equivalent, and we just need to patch them
4202
- patch(n1, n2);
4124
+ patch(n1, n2, renderer);
4203
4125
  anchor = n2.elm;
4204
4126
  }
4205
4127
  else {
4206
4128
  // removing the old vnode since the new one is null
4207
- unmount(n1, parent, true);
4129
+ unmount(n1, parent, renderer, true);
4208
4130
  }
4209
4131
  }
4210
4132
  else if (isVNode(n2)) {
4211
- mount(n2, parent, anchor);
4133
+ mount(n2, parent, renderer, anchor);
4212
4134
  anchor = n2.elm;
4213
4135
  }
4214
4136
  }
@@ -4225,6 +4147,17 @@ const SymbolIterator = Symbol.iterator;
4225
4147
  function addVNodeToChildLWC(vnode) {
4226
4148
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
4227
4149
  }
4150
+ // [st]atic node
4151
+ function st(fragment, key) {
4152
+ return {
4153
+ type: 4 /* Static */,
4154
+ sel: undefined,
4155
+ key,
4156
+ elm: undefined,
4157
+ fragment,
4158
+ owner: getVMBeingRendered(),
4159
+ };
4160
+ }
4228
4161
  // [h]tml node
4229
4162
  function h(sel, data, children = EmptyArray) {
4230
4163
  const vmBeingRendered = getVMBeingRendered();
@@ -4614,6 +4547,7 @@ const api = freeze({
4614
4547
  co,
4615
4548
  dc,
4616
4549
  ti,
4550
+ st,
4617
4551
  gid,
4618
4552
  fid,
4619
4553
  shc,
@@ -4637,7 +4571,7 @@ function createInlineStyleVNode(content) {
4637
4571
  }, [api.t(content)]);
4638
4572
  }
4639
4573
  function updateStylesheetToken(vm, template) {
4640
- const { elm, context, renderMode, shadowMode } = vm;
4574
+ const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
4641
4575
  const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
4642
4576
  const isSyntheticShadow = renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */;
4643
4577
  const { hasScopedStyles } = context;
@@ -4648,10 +4582,10 @@ function updateStylesheetToken(vm, template) {
4648
4582
  const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
4649
4583
  if (!isUndefined$1(oldToken)) {
4650
4584
  if (oldHasTokenInClass) {
4651
- getClassList$1(elm).remove(makeHostToken(oldToken));
4585
+ getClassList(elm).remove(makeHostToken(oldToken));
4652
4586
  }
4653
4587
  if (oldHasTokenInAttribute) {
4654
- removeAttribute$1(elm, makeHostToken(oldToken));
4588
+ removeAttribute(elm, makeHostToken(oldToken));
4655
4589
  }
4656
4590
  }
4657
4591
  // Apply the new template styling token to the host element, if the new template has any
@@ -4662,11 +4596,11 @@ function updateStylesheetToken(vm, template) {
4662
4596
  // Set the new styling token on the host element
4663
4597
  if (!isUndefined$1(newToken)) {
4664
4598
  if (hasScopedStyles) {
4665
- getClassList$1(elm).add(makeHostToken(newToken));
4599
+ getClassList(elm).add(makeHostToken(newToken));
4666
4600
  newHasTokenInClass = true;
4667
4601
  }
4668
4602
  if (isSyntheticShadow) {
4669
- setAttribute$1(elm, makeHostToken(newToken), '');
4603
+ setAttribute(elm, makeHostToken(newToken), '');
4670
4604
  newHasTokenInAttribute = true;
4671
4605
  }
4672
4606
  }
@@ -4754,19 +4688,18 @@ function getNearestNativeShadowComponent(vm) {
4754
4688
  return owner;
4755
4689
  }
4756
4690
  function createStylesheet(vm, stylesheets) {
4757
- const { renderMode, shadowMode } = vm;
4691
+ const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
4758
4692
  if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
4759
4693
  for (let i = 0; i < stylesheets.length; i++) {
4760
- insertStylesheet$1(stylesheets[i]);
4694
+ insertStylesheet(stylesheets[i]);
4761
4695
  }
4762
4696
  }
4763
- else if (ssr$1 || vm.hydrated) {
4697
+ else if (ssr || vm.hydrated) {
4764
4698
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4765
4699
  // This works in the client, because the stylesheets are created, and cached in the VM
4766
4700
  // the first time the VM renders.
4767
4701
  // native shadow or light DOM, SSR
4768
- const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4769
- return createInlineStyleVNode(combinedStylesheetContent);
4702
+ return ArrayMap.call(stylesheets, createInlineStyleVNode);
4770
4703
  }
4771
4704
  else {
4772
4705
  // native shadow or light DOM, DOM renderer
@@ -4774,7 +4707,7 @@ function createStylesheet(vm, stylesheets) {
4774
4707
  // null root means a global style
4775
4708
  const target = isNull(root) ? undefined : root.shadowRoot;
4776
4709
  for (let i = 0; i < stylesheets.length; i++) {
4777
- insertStylesheet$1(stylesheets[i], target);
4710
+ insertStylesheet(stylesheets[i], target);
4778
4711
  }
4779
4712
  }
4780
4713
  return null;
@@ -4900,6 +4833,54 @@ function validateLightDomTemplate(template, vm) {
4900
4833
  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"`);
4901
4834
  }
4902
4835
  }
4836
+ function buildParseFragmentFn(createFragmentFn) {
4837
+ return (strings, ...keys) => {
4838
+ const cache = create(null);
4839
+ return function () {
4840
+ const { context: { hasScopedStyles, stylesheetToken }, shadowMode, renderer, } = getVMBeingRendered();
4841
+ const hasStyleToken = !isUndefined$1(stylesheetToken);
4842
+ const isSyntheticShadow = shadowMode === 1 /* Synthetic */;
4843
+ let cacheKey = 0;
4844
+ if (hasStyleToken && hasScopedStyles) {
4845
+ cacheKey |= 1 /* HAS_SCOPED_STYLE */;
4846
+ }
4847
+ if (hasStyleToken && isSyntheticShadow) {
4848
+ cacheKey |= 2 /* SHADOW_MODE_SYNTHETIC */;
4849
+ }
4850
+ if (!isUndefined$1(cache[cacheKey])) {
4851
+ return cache[cacheKey];
4852
+ }
4853
+ const classToken = hasScopedStyles && hasStyleToken ? ' ' + stylesheetToken : '';
4854
+ const classAttrToken = hasScopedStyles && hasStyleToken ? ` class="${stylesheetToken}"` : '';
4855
+ const attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetToken : '';
4856
+ let htmlFragment = '';
4857
+ for (let i = 0, n = keys.length; i < n; i++) {
4858
+ switch (keys[i]) {
4859
+ case 0: // styleToken in existing class attr
4860
+ htmlFragment += strings[i] + classToken;
4861
+ break;
4862
+ case 1: // styleToken for added class attr
4863
+ htmlFragment += strings[i] + classAttrToken;
4864
+ break;
4865
+ case 2: // styleToken as attr
4866
+ htmlFragment += strings[i] + attrToken;
4867
+ break;
4868
+ case 3: // ${1}${2}
4869
+ htmlFragment += strings[i] + classAttrToken + attrToken;
4870
+ break;
4871
+ }
4872
+ }
4873
+ htmlFragment += strings[strings.length - 1];
4874
+ cache[cacheKey] = createFragmentFn(htmlFragment, renderer);
4875
+ return cache[cacheKey];
4876
+ };
4877
+ };
4878
+ }
4879
+ // Note: at the moment this code executes, we don't have a renderer yet.
4880
+ const parseFragment = buildParseFragmentFn((html, renderer) => {
4881
+ const { createFragment } = renderer;
4882
+ return createFragment(html);
4883
+ });
4903
4884
  function evaluateTemplate(vm, html) {
4904
4885
  if (process.env.NODE_ENV !== 'production') {
4905
4886
  assert.isTrue(isFunction$1(html), `evaluateTemplate() second argument must be an imported template instead of ${toString$1(html)}`);
@@ -4946,7 +4927,7 @@ function evaluateTemplate(vm, html) {
4946
4927
  // Evaluate, create stylesheet and cache the produced VNode for future
4947
4928
  // re-rendering.
4948
4929
  const stylesheetsContent = getStylesheetsContent(vm, html);
4949
- context.styleVNode =
4930
+ context.styleVNodes =
4950
4931
  stylesheetsContent.length === 0
4951
4932
  ? null
4952
4933
  : createStylesheet(vm, stylesheetsContent);
@@ -4963,9 +4944,9 @@ function evaluateTemplate(vm, html) {
4963
4944
  // Set the global flag that template is being updated
4964
4945
  isUpdatingTemplate = true;
4965
4946
  vnodes = html.call(undefined, api, component, cmpSlots, context.tplCache);
4966
- const { styleVNode } = context;
4967
- if (!isNull(styleVNode)) {
4968
- ArrayUnshift.call(vnodes, styleVNode);
4947
+ const { styleVNodes } = context;
4948
+ if (!isNull(styleVNodes)) {
4949
+ ArrayUnshift.apply(vnodes, styleVNodes);
4969
4950
  }
4970
4951
  });
4971
4952
  }, () => {
@@ -5282,9 +5263,20 @@ function removeVM(vm) {
5282
5263
 
5283
5264
  resetComponentStateWhenRemoved(vm);
5284
5265
  }
5285
- function createVM(elm, ctor, options) {
5286
- var _a;
5287
5266
 
5267
+ function getNearestShadowAncestor(vm) {
5268
+ let ancestor = vm.owner;
5269
+
5270
+ while (!isNull(ancestor) && ancestor.renderMode === 0
5271
+ /* Light */
5272
+ ) {
5273
+ ancestor = ancestor.owner;
5274
+ }
5275
+
5276
+ return ancestor;
5277
+ }
5278
+
5279
+ function createVM(elm, ctor, renderer, options) {
5288
5280
  const {
5289
5281
  mode,
5290
5282
  owner,
@@ -5314,28 +5306,29 @@ function createVM(elm, ctor, options) {
5314
5306
  cmpTemplate: null,
5315
5307
  hydrated: Boolean(hydrated),
5316
5308
  renderMode: def.renderMode,
5317
- shadowMode: computeShadowMode(def, owner),
5318
- nearestShadowMode: (owner === null || owner === void 0 ? void 0 : owner.shadowRoot) ? owner.shadowMode : (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : null,
5319
5309
  context: {
5320
5310
  stylesheetToken: undefined,
5321
5311
  hasTokenInClass: undefined,
5322
5312
  hasTokenInAttribute: undefined,
5323
5313
  hasScopedStyles: undefined,
5324
- styleVNode: null,
5314
+ styleVNodes: null,
5325
5315
  tplCache: EmptyObject,
5326
5316
  wiredConnecting: EmptyArray,
5327
5317
  wiredDisconnecting: EmptyArray
5328
5318
  },
5329
5319
  // Properties set right after VM creation.
5330
5320
  tro: null,
5321
+ shadowMode: null,
5331
5322
  // Properties set by the LightningElement constructor.
5332
5323
  component: null,
5333
5324
  shadowRoot: null,
5334
5325
  renderRoot: null,
5335
5326
  callHook,
5336
5327
  setHook,
5337
- getHook
5328
+ getHook,
5329
+ renderer
5338
5330
  };
5331
+ vm.shadowMode = computeShadowMode(vm, renderer);
5339
5332
  vm.tro = getTemplateReactiveObserver(vm);
5340
5333
 
5341
5334
  if (process.env.NODE_ENV !== 'production') {
@@ -5360,12 +5353,17 @@ function createVM(elm, ctor, options) {
5360
5353
  return vm;
5361
5354
  }
5362
5355
 
5363
- function computeShadowMode(def, owner) {
5364
- var _a;
5365
-
5356
+ function computeShadowMode(vm, renderer) {
5357
+ const {
5358
+ def
5359
+ } = vm;
5360
+ const {
5361
+ isSyntheticShadowDefined,
5362
+ isNativeShadowDefined
5363
+ } = renderer;
5366
5364
  let shadowMode;
5367
5365
 
5368
- if (isSyntheticShadowDefined$1) {
5366
+ if (isSyntheticShadowDefined) {
5369
5367
  if (def.renderMode === 0
5370
5368
  /* Light */
5371
5369
  ) {
@@ -5374,7 +5372,7 @@ function computeShadowMode(def, owner) {
5374
5372
  shadowMode = 0
5375
5373
  /* Native */
5376
5374
  ;
5377
- } else if (isNativeShadowDefined$1) {
5375
+ } else if (isNativeShadowDefined) {
5378
5376
  // Not combined with above condition because @lwc/features only supports identifiers in
5379
5377
  // the if-condition.
5380
5378
  if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
@@ -5385,13 +5383,23 @@ function computeShadowMode(def, owner) {
5385
5383
  /* Native */
5386
5384
  ;
5387
5385
  } else {
5388
- // Transitive support for native Shadow DOM. A component in native mode
5389
- // transitively opts all of its descendants into native.
5390
- // Synthetic if neither this component nor any of its ancestors are configured
5391
- // to be native.
5392
- shadowMode = (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : 1
5393
- /* Synthetic */
5394
- ;
5386
+ const shadowAncestor = getNearestShadowAncestor(vm);
5387
+
5388
+ if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
5389
+ /* Native */
5390
+ ) {
5391
+ // Transitive support for native Shadow DOM. A component in native mode
5392
+ // transitively opts all of its descendants into native.
5393
+ shadowMode = 0
5394
+ /* Native */
5395
+ ;
5396
+ } else {
5397
+ // Synthetic if neither this component nor any of its ancestors are configured
5398
+ // to be native.
5399
+ shadowMode = 1
5400
+ /* Synthetic */
5401
+ ;
5402
+ }
5395
5403
  }
5396
5404
  } else {
5397
5405
  shadowMode = 1
@@ -5454,7 +5462,8 @@ function rehydrate(vm) {
5454
5462
  function patchShadowRoot(vm, newCh) {
5455
5463
  const {
5456
5464
  renderRoot,
5457
- children: oldCh
5465
+ children: oldCh,
5466
+ renderer
5458
5467
  } = vm; // caching the new children collection
5459
5468
 
5460
5469
  vm.children = newCh;
@@ -5470,7 +5479,7 @@ function patchShadowRoot(vm, newCh) {
5470
5479
  , vm);
5471
5480
  }, () => {
5472
5481
  // job
5473
- patchChildren(oldCh, newCh, renderRoot);
5482
+ patchChildren(oldCh, newCh, renderRoot, renderer);
5474
5483
  }, () => {
5475
5484
  // post
5476
5485
  logOperationEnd(2
@@ -5495,10 +5504,13 @@ function runRenderedCallback(vm) {
5495
5504
  const {
5496
5505
  def: {
5497
5506
  renderedCallback
5507
+ },
5508
+ renderer: {
5509
+ ssr
5498
5510
  }
5499
5511
  } = vm;
5500
5512
 
5501
- if (isTrue(ssr$1)) {
5513
+ if (isTrue(ssr)) {
5502
5514
  return;
5503
5515
  }
5504
5516
 
@@ -5732,14 +5744,17 @@ function recursivelyDisconnectChildren(vnodes) {
5732
5744
  function resetComponentRoot(vm) {
5733
5745
  const {
5734
5746
  children,
5735
- renderRoot
5747
+ renderRoot,
5748
+ renderer: {
5749
+ remove
5750
+ }
5736
5751
  } = vm;
5737
5752
 
5738
5753
  for (let i = 0, len = children.length; i < len; i++) {
5739
5754
  const child = children[i];
5740
5755
 
5741
5756
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5742
- remove$1(child.elm, renderRoot);
5757
+ remove(child.elm, renderRoot);
5743
5758
  }
5744
5759
  }
5745
5760
 
@@ -5748,7 +5763,13 @@ function resetComponentRoot(vm) {
5748
5763
  vm.velements = EmptyArray;
5749
5764
  }
5750
5765
  function scheduleRehydration(vm) {
5751
- if (isTrue(ssr$1) || isTrue(vm.isScheduled)) {
5766
+ const {
5767
+ renderer: {
5768
+ ssr
5769
+ }
5770
+ } = vm;
5771
+
5772
+ if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5752
5773
  return;
5753
5774
  }
5754
5775
 
@@ -5907,6 +5928,9 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
5907
5928
  context: {
5908
5929
  wiredConnecting,
5909
5930
  wiredDisconnecting
5931
+ },
5932
+ renderer: {
5933
+ dispatchEvent
5910
5934
  }
5911
5935
  } = vm; // waiting for the component to be connected to formally request the context via the token
5912
5936
 
@@ -5930,7 +5954,7 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
5930
5954
  }
5931
5955
 
5932
5956
  });
5933
- dispatchEvent$1(elm, contextRegistrationEvent);
5957
+ dispatchEvent(elm, contextRegistrationEvent);
5934
5958
  });
5935
5959
  }
5936
5960
 
@@ -6270,7 +6294,7 @@ function freezeTemplate(tmpl) {
6270
6294
  });
6271
6295
  }
6272
6296
  }
6273
- /* version: 2.14.0 */
6297
+ /* version: 2.15.0 */
6274
6298
 
6275
6299
  /*
6276
6300
  * Copyright (c) 2020, salesforce.com, inc.
@@ -6343,6 +6367,9 @@ class HTMLElementImpl {
6343
6367
  }
6344
6368
  }
6345
6369
  const ssr = true;
6370
+ function isHydrating() {
6371
+ return false;
6372
+ }
6346
6373
  const isNativeShadowDefined = false;
6347
6374
  const isSyntheticShadowDefined = false;
6348
6375
  function insert(node, parent, anchor) {
@@ -6363,6 +6390,16 @@ function remove(node, parent) {
6363
6390
  const nodeIndex = parent.children.indexOf(node);
6364
6391
  parent.children.splice(nodeIndex, 1);
6365
6392
  }
6393
+ function cloneNode(node) {
6394
+ return node;
6395
+ }
6396
+ function createFragment(html) {
6397
+ return {
6398
+ type: HostNodeType.Raw,
6399
+ parent: null,
6400
+ value: html,
6401
+ };
6402
+ }
6366
6403
  function createText(content) {
6367
6404
  return {
6368
6405
  type: HostNodeType.Text,
@@ -6569,68 +6606,49 @@ function getCustomElement(name) {
6569
6606
  const HTMLElementExported = HTMLElementImpl;
6570
6607
  /* noop */
6571
6608
  const assertInstanceOfHTMLElement = noop;
6572
-
6573
- /*
6574
- * Copyright (c) 2020, salesforce.com, inc.
6575
- * All rights reserved.
6576
- * SPDX-License-Identifier: MIT
6577
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6578
- */
6579
- setAssertInstanceOfHTMLElement(assertInstanceOfHTMLElement);
6580
- setAttachShadow(attachShadow);
6581
- setCreateComment(createComment);
6582
- setCreateElement(createElement);
6583
- setCreateText(createText);
6584
- setDefineCustomElement(defineCustomElement);
6585
- setDispatchEvent(dispatchEvent);
6586
- setGetAttribute(getAttribute);
6587
- setGetBoundingClientRect(getBoundingClientRect);
6588
- setGetChildNodes(getChildNodes);
6589
- setGetChildren(getChildren);
6590
- setGetClassList(getClassList);
6591
- setGetCustomElement(getCustomElement);
6592
- setGetElementsByClassName(getElementsByClassName);
6593
- setGetElementsByTagName(getElementsByTagName);
6594
- setGetFirstChild(getFirstChild);
6595
- setGetFirstElementChild(getFirstElementChild);
6596
- setGetLastChild(getLastChild);
6597
- setGetLastElementChild(getLastElementChild);
6598
- setGetProperty(getProperty);
6599
- setHTMLElement(HTMLElementExported);
6600
- setInsert(insert);
6601
- setIsConnected(isConnected);
6602
- setIsNativeShadowDefined(isNativeShadowDefined);
6603
- setIsSyntheticShadowDefined(isSyntheticShadowDefined);
6604
- setNextSibling(nextSibling);
6605
- setQuerySelector(querySelector);
6606
- setQuerySelectorAll(querySelectorAll);
6607
- setRemove(remove);
6608
- setRemoveAttribute(removeAttribute);
6609
- setRemoveEventListener(removeEventListener);
6610
- setSetAttribute(setAttribute);
6611
- setSetCSSStyleProperty(setCSSStyleProperty);
6612
- setSetProperty(setProperty);
6613
- setSetText(setText);
6614
- setSsr(ssr);
6615
- setAddEventListener(addEventListener);
6616
- setInsertStylesheet(insertStylesheet);
6617
-
6618
- /*
6619
- * Copyright (c) 2020, salesforce.com, inc.
6620
- * All rights reserved.
6621
- * SPDX-License-Identifier: MIT
6622
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6623
- */
6624
- const ESCAPED_CHARS = {
6625
- '"': '&quot;',
6626
- "'": '&#x27;',
6627
- '<': '&lt;',
6628
- '>': '&gt;',
6629
- '&': '&amp;',
6609
+ const renderer = {
6610
+ ssr,
6611
+ isNativeShadowDefined,
6612
+ isSyntheticShadowDefined,
6613
+ HTMLElementExported,
6614
+ isHydrating,
6615
+ insert,
6616
+ remove,
6617
+ cloneNode,
6618
+ createFragment,
6619
+ createElement,
6620
+ createText,
6621
+ createComment,
6622
+ nextSibling,
6623
+ attachShadow,
6624
+ getProperty,
6625
+ setProperty,
6626
+ setText,
6627
+ getAttribute,
6628
+ setAttribute,
6629
+ removeAttribute,
6630
+ addEventListener,
6631
+ removeEventListener,
6632
+ dispatchEvent,
6633
+ getClassList,
6634
+ setCSSStyleProperty,
6635
+ getBoundingClientRect,
6636
+ querySelector,
6637
+ querySelectorAll,
6638
+ getElementsByTagName,
6639
+ getElementsByClassName,
6640
+ getChildren,
6641
+ getChildNodes,
6642
+ getFirstChild,
6643
+ getFirstElementChild,
6644
+ getLastChild,
6645
+ getLastElementChild,
6646
+ isConnected,
6647
+ insertStylesheet,
6648
+ assertInstanceOfHTMLElement,
6649
+ defineCustomElement,
6650
+ getCustomElement,
6630
6651
  };
6631
- function htmlEscape(str) {
6632
- return str.replace(/["'<>&]/g, (char) => ESCAPED_CHARS[char]);
6633
- }
6634
6652
 
6635
6653
  /*
6636
6654
  * Copyright (c) 2020, salesforce.com, inc.
@@ -6707,8 +6725,8 @@ function renderComponent(tagName, Ctor, props = {}) {
6707
6725
  if (!isObject(props) || isNull(props)) {
6708
6726
  throw new TypeError(`"renderComponent" expects an object as the third parameter but instead received ${props}.`);
6709
6727
  }
6710
- const element = createElement(tagName);
6711
- createVM(element, Ctor, {
6728
+ const element = renderer.createElement(tagName);
6729
+ createVM(element, Ctor, renderer, {
6712
6730
  mode: 'open',
6713
6731
  owner: null,
6714
6732
  tagName,
@@ -6729,7 +6747,7 @@ function renderComponent(tagName, Ctor, props = {}) {
6729
6747
  */
6730
6748
  freeze(LightningElement);
6731
6749
  seal(LightningElement.prototype);
6732
- /* version: 2.14.0 */
6750
+ /* version: 2.15.0 */
6733
6751
 
6734
6752
  exports.LightningElement = LightningElement;
6735
6753
  exports.api = api$1;
@@ -6737,12 +6755,15 @@ exports.createContextProvider = createContextProvider;
6737
6755
  exports.freezeTemplate = freezeTemplate;
6738
6756
  exports.getComponentDef = getComponentDef;
6739
6757
  exports.isComponentConstructor = isComponentConstructor;
6758
+ exports.parseFragment = parseFragment;
6759
+ exports.parseSVGFragment = parseFragment;
6740
6760
  exports.readonly = readonly;
6741
6761
  exports.register = register;
6742
6762
  exports.registerComponent = registerComponent;
6743
6763
  exports.registerDecorators = registerDecorators;
6744
6764
  exports.registerTemplate = registerTemplate;
6745
6765
  exports.renderComponent = renderComponent;
6766
+ exports.renderer = renderer;
6746
6767
  exports.sanitizeAttribute = sanitizeAttribute;
6747
6768
  exports.setFeatureFlag = setFeatureFlag;
6748
6769
  exports.setFeatureFlagForTest = setFeatureFlagForTest;