@lwc/engine-core 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.
@@ -1,7 +1,7 @@
1
1
  /* proxy-compat-disable */
2
2
  import { runtimeFlags } from '@lwc/features';
3
3
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
4
- import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_RESOLVER, isArray as isArray$1, isNumber, StringReplace, KEY__SCOPED_CSS, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
4
+ import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, isArray as isArray$1, isNumber, StringReplace, ArrayMap, KEY__SCOPED_CSS, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
5
5
 
6
6
  /*
7
7
  * Copyright (c) 2018, salesforce.com, inc.
@@ -109,164 +109,6 @@ function flattenStylesheets(stylesheets) {
109
109
  return list;
110
110
  }
111
111
 
112
- //
113
- // Primitives
114
- //
115
- let ssr;
116
- function setSsr(ssrImpl) {
117
- ssr = ssrImpl;
118
- }
119
- let isNativeShadowDefined;
120
- function setIsNativeShadowDefined(isNativeShadowDefinedImpl) {
121
- isNativeShadowDefined = isNativeShadowDefinedImpl;
122
- }
123
- let isSyntheticShadowDefined;
124
- function setIsSyntheticShadowDefined(isSyntheticShadowDefinedImpl) {
125
- isSyntheticShadowDefined = isSyntheticShadowDefinedImpl;
126
- }
127
- let HTMLElementExported;
128
- function setHTMLElement(HTMLElementImpl) {
129
- HTMLElementExported = HTMLElementImpl;
130
- }
131
- function setIsHydrating(isHydratingImpl) {
132
- }
133
- let insert;
134
- function setInsert(insertImpl) {
135
- insert = insertImpl;
136
- }
137
- let remove;
138
- function setRemove(removeImpl) {
139
- remove = removeImpl;
140
- }
141
- let createElement;
142
- function setCreateElement(createElementImpl) {
143
- createElement = createElementImpl;
144
- }
145
- let createText;
146
- function setCreateText(createTextImpl) {
147
- createText = createTextImpl;
148
- }
149
- let createComment;
150
- function setCreateComment(createCommentImpl) {
151
- createComment = createCommentImpl;
152
- }
153
- let nextSibling;
154
- function setNextSibling(nextSiblingImpl) {
155
- nextSibling = nextSiblingImpl;
156
- }
157
- let attachShadow;
158
- function setAttachShadow(attachShadowImpl) {
159
- attachShadow = attachShadowImpl;
160
- }
161
- let getProperty;
162
- function setGetProperty(getPropertyImpl) {
163
- getProperty = getPropertyImpl;
164
- }
165
- let setProperty;
166
- function setSetProperty(setPropertyImpl) {
167
- setProperty = setPropertyImpl;
168
- }
169
- let setText;
170
- function setSetText(setTextImpl) {
171
- setText = setTextImpl;
172
- }
173
- let getAttribute;
174
- function setGetAttribute(getAttributeImpl) {
175
- getAttribute = getAttributeImpl;
176
- }
177
- let setAttribute;
178
- function setSetAttribute(setAttributeImpl) {
179
- setAttribute = setAttributeImpl;
180
- }
181
- let removeAttribute;
182
- function setRemoveAttribute(removeAttributeImpl) {
183
- removeAttribute = removeAttributeImpl;
184
- }
185
- let addEventListener;
186
- function setAddEventListener(addEventListenerImpl) {
187
- addEventListener = addEventListenerImpl;
188
- }
189
- let removeEventListener;
190
- function setRemoveEventListener(removeEventListenerImpl) {
191
- removeEventListener = removeEventListenerImpl;
192
- }
193
- let dispatchEvent;
194
- function setDispatchEvent(dispatchEventImpl) {
195
- dispatchEvent = dispatchEventImpl;
196
- }
197
- let getClassList;
198
- function setGetClassList(getClassListImpl) {
199
- getClassList = getClassListImpl;
200
- }
201
- let setCSSStyleProperty;
202
- function setSetCSSStyleProperty(setCSSStylePropertyImpl) {
203
- setCSSStyleProperty = setCSSStylePropertyImpl;
204
- }
205
- let getBoundingClientRect;
206
- function setGetBoundingClientRect(getBoundingClientRectImpl) {
207
- getBoundingClientRect = getBoundingClientRectImpl;
208
- }
209
- let querySelector;
210
- function setQuerySelector(querySelectorImpl) {
211
- querySelector = querySelectorImpl;
212
- }
213
- let querySelectorAll;
214
- function setQuerySelectorAll(querySelectorAllImpl) {
215
- querySelectorAll = querySelectorAllImpl;
216
- }
217
- let getElementsByTagName;
218
- function setGetElementsByTagName(getElementsByTagNameImpl) {
219
- getElementsByTagName = getElementsByTagNameImpl;
220
- }
221
- let getElementsByClassName;
222
- function setGetElementsByClassName(getElementsByClassNameImpl) {
223
- getElementsByClassName = getElementsByClassNameImpl;
224
- }
225
- let getChildren;
226
- function setGetChildren(getChildrenImpl) {
227
- getChildren = getChildrenImpl;
228
- }
229
- let getChildNodes;
230
- function setGetChildNodes(getChildNodesImpl) {
231
- getChildNodes = getChildNodesImpl;
232
- }
233
- let getFirstChild;
234
- function setGetFirstChild(getFirstChildImpl) {
235
- getFirstChild = getFirstChildImpl;
236
- }
237
- let getFirstElementChild;
238
- function setGetFirstElementChild(getFirstElementChildImpl) {
239
- getFirstElementChild = getFirstElementChildImpl;
240
- }
241
- let getLastChild;
242
- function setGetLastChild(getLastChildImpl) {
243
- getLastChild = getLastChildImpl;
244
- }
245
- let getLastElementChild;
246
- function setGetLastElementChild(getLastElementChildImpl) {
247
- getLastElementChild = getLastElementChildImpl;
248
- }
249
- let isConnected;
250
- function setIsConnected(isConnectedImpl) {
251
- isConnected = isConnectedImpl;
252
- }
253
- let insertStylesheet;
254
- function setInsertStylesheet(insertStylesheetImpl) {
255
- insertStylesheet = insertStylesheetImpl;
256
- }
257
- let assertInstanceOfHTMLElement;
258
- function setAssertInstanceOfHTMLElement(assertInstanceOfHTMLElementImpl) {
259
- assertInstanceOfHTMLElement = assertInstanceOfHTMLElementImpl;
260
- }
261
- let defineCustomElement;
262
- function setDefineCustomElement(defineCustomElementImpl) {
263
- defineCustomElement = defineCustomElementImpl;
264
- }
265
- let getCustomElement;
266
- function setGetCustomElement(getCustomElementImpl) {
267
- getCustomElement = getCustomElementImpl;
268
- }
269
-
270
112
  /*
271
113
  * Copyright (c) 2019, salesforce.com, inc.
272
114
  * All rights reserved.
@@ -1571,6 +1413,7 @@ const LightningElement = function () {
1571
1413
  const { def, elm } = vm;
1572
1414
  const { bridge } = def;
1573
1415
  if (process.env.NODE_ENV !== 'production') {
1416
+ const { assertInstanceOfHTMLElement } = vm.renderer;
1574
1417
  assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
1575
1418
  }
1576
1419
  const component = this;
@@ -1605,7 +1448,7 @@ const LightningElement = function () {
1605
1448
  return this;
1606
1449
  };
1607
1450
  function doAttachShadow(vm) {
1608
- const { elm, mode, shadowMode, def: { ctor }, } = vm;
1451
+ const { elm, mode, shadowMode, def: { ctor }, renderer: { attachShadow }, } = vm;
1609
1452
  const shadowRoot = attachShadow(elm, {
1610
1453
  [KEY__SYNTHETIC_MODE]: shadowMode === 1 /* Synthetic */,
1611
1454
  delegatesFocus: Boolean(ctor.delegatesFocus),
@@ -1627,12 +1470,13 @@ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
1627
1470
  LightningElement.prototype = {
1628
1471
  constructor: LightningElement,
1629
1472
  dispatchEvent(event) {
1630
- const { elm } = getAssociatedVM(this);
1473
+ const vm = getAssociatedVM(this);
1474
+ const { elm, renderer: { dispatchEvent }, } = vm;
1631
1475
  return dispatchEvent(elm, event);
1632
1476
  },
1633
1477
  addEventListener(type, listener, options) {
1634
1478
  const vm = getAssociatedVM(this);
1635
- const { elm } = vm;
1479
+ const { elm, renderer: { addEventListener }, } = vm;
1636
1480
  if (process.env.NODE_ENV !== 'production') {
1637
1481
  const vmBeingRendered = getVMBeingRendered();
1638
1482
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
@@ -1644,41 +1488,48 @@ LightningElement.prototype = {
1644
1488
  },
1645
1489
  removeEventListener(type, listener, options) {
1646
1490
  const vm = getAssociatedVM(this);
1647
- const { elm } = vm;
1491
+ const { elm, renderer: { removeEventListener }, } = vm;
1648
1492
  const wrappedListener = getWrappedComponentsListener(vm, listener);
1649
1493
  removeEventListener(elm, type, wrappedListener, options);
1650
1494
  },
1651
1495
  hasAttribute(name) {
1652
- const { elm } = getAssociatedVM(this);
1496
+ const vm = getAssociatedVM(this);
1497
+ const { elm, renderer: { getAttribute }, } = vm;
1653
1498
  return !isNull(getAttribute(elm, name));
1654
1499
  },
1655
1500
  hasAttributeNS(namespace, name) {
1656
- const { elm } = getAssociatedVM(this);
1501
+ const vm = getAssociatedVM(this);
1502
+ const { elm, renderer: { getAttribute }, } = vm;
1657
1503
  return !isNull(getAttribute(elm, name, namespace));
1658
1504
  },
1659
1505
  removeAttribute(name) {
1660
- const { elm } = getAssociatedVM(this);
1506
+ const vm = getAssociatedVM(this);
1507
+ const { elm, renderer: { removeAttribute }, } = vm;
1661
1508
  unlockAttribute(elm, name);
1662
1509
  removeAttribute(elm, name);
1663
1510
  lockAttribute();
1664
1511
  },
1665
1512
  removeAttributeNS(namespace, name) {
1666
- const { elm } = getAssociatedVM(this);
1513
+ const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
1667
1514
  unlockAttribute(elm, name);
1668
1515
  removeAttribute(elm, name, namespace);
1669
1516
  lockAttribute();
1670
1517
  },
1671
1518
  getAttribute(name) {
1672
- const { elm } = getAssociatedVM(this);
1519
+ const vm = getAssociatedVM(this);
1520
+ const { elm } = vm;
1521
+ const { getAttribute } = vm.renderer;
1673
1522
  return getAttribute(elm, name);
1674
1523
  },
1675
1524
  getAttributeNS(namespace, name) {
1676
- const { elm } = getAssociatedVM(this);
1525
+ const vm = getAssociatedVM(this);
1526
+ const { elm } = vm;
1527
+ const { getAttribute } = vm.renderer;
1677
1528
  return getAttribute(elm, name, namespace);
1678
1529
  },
1679
1530
  setAttribute(name, value) {
1680
1531
  const vm = getAssociatedVM(this);
1681
- const { elm } = vm;
1532
+ const { elm, renderer: { setAttribute }, } = vm;
1682
1533
  if (process.env.NODE_ENV !== 'production') {
1683
1534
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1684
1535
  }
@@ -1688,7 +1539,7 @@ LightningElement.prototype = {
1688
1539
  },
1689
1540
  setAttributeNS(namespace, name, value) {
1690
1541
  const vm = getAssociatedVM(this);
1691
- const { elm } = vm;
1542
+ const { elm, renderer: { setAttribute }, } = vm;
1692
1543
  if (process.env.NODE_ENV !== 'production') {
1693
1544
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1694
1545
  }
@@ -1698,19 +1549,20 @@ LightningElement.prototype = {
1698
1549
  },
1699
1550
  getBoundingClientRect() {
1700
1551
  const vm = getAssociatedVM(this);
1701
- const { elm } = vm;
1552
+ const { elm, renderer: { getBoundingClientRect }, } = vm;
1702
1553
  if (process.env.NODE_ENV !== 'production') {
1703
1554
  warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
1704
1555
  }
1705
1556
  return getBoundingClientRect(elm);
1706
1557
  },
1707
1558
  get isConnected() {
1708
- const { elm } = getAssociatedVM(this);
1559
+ const vm = getAssociatedVM(this);
1560
+ const { elm, renderer: { isConnected }, } = vm;
1709
1561
  return isConnected(elm);
1710
1562
  },
1711
1563
  get classList() {
1712
1564
  const vm = getAssociatedVM(this);
1713
- const { elm } = vm;
1565
+ const { elm, renderer: { getClassList }, } = vm;
1714
1566
  if (process.env.NODE_ENV !== 'production') {
1715
1567
  // TODO [#1290]: this still fails in dev but works in production, eventually, we should
1716
1568
  // just throw in all modes
@@ -1732,6 +1584,54 @@ LightningElement.prototype = {
1732
1584
  // Authors should rely on this.template instead.
1733
1585
  return null;
1734
1586
  },
1587
+ get children() {
1588
+ const vm = getAssociatedVM(this);
1589
+ const renderer = vm.renderer;
1590
+ if (process.env.NODE_ENV !== 'production') {
1591
+ warnIfInvokedDuringConstruction(vm, 'children');
1592
+ }
1593
+ return renderer.getChildren(vm.elm);
1594
+ },
1595
+ get childNodes() {
1596
+ const vm = getAssociatedVM(this);
1597
+ const renderer = vm.renderer;
1598
+ if (process.env.NODE_ENV !== 'production') {
1599
+ warnIfInvokedDuringConstruction(vm, 'childNodes');
1600
+ }
1601
+ return renderer.getChildNodes(vm.elm);
1602
+ },
1603
+ get firstChild() {
1604
+ const vm = getAssociatedVM(this);
1605
+ const renderer = vm.renderer;
1606
+ if (process.env.NODE_ENV !== 'production') {
1607
+ warnIfInvokedDuringConstruction(vm, 'firstChild');
1608
+ }
1609
+ return renderer.getFirstChild(vm.elm);
1610
+ },
1611
+ get firstElementChild() {
1612
+ const vm = getAssociatedVM(this);
1613
+ const renderer = vm.renderer;
1614
+ if (process.env.NODE_ENV !== 'production') {
1615
+ warnIfInvokedDuringConstruction(vm, 'firstElementChild');
1616
+ }
1617
+ return renderer.getFirstElementChild(vm.elm);
1618
+ },
1619
+ get lastChild() {
1620
+ const vm = getAssociatedVM(this);
1621
+ const renderer = vm.renderer;
1622
+ if (process.env.NODE_ENV !== 'production') {
1623
+ warnIfInvokedDuringConstruction(vm, 'lastChild');
1624
+ }
1625
+ return renderer.getLastChild(vm.elm);
1626
+ },
1627
+ get lastElementChild() {
1628
+ const vm = getAssociatedVM(this);
1629
+ const renderer = vm.renderer;
1630
+ if (process.env.NODE_ENV !== 'production') {
1631
+ warnIfInvokedDuringConstruction(vm, 'lastElementChild');
1632
+ }
1633
+ return renderer.getLastElementChild(vm.elm);
1634
+ },
1735
1635
  render() {
1736
1636
  const vm = getAssociatedVM(this);
1737
1637
  return vm.def.template;
@@ -1742,76 +1642,22 @@ LightningElement.prototype = {
1742
1642
  },
1743
1643
  };
1744
1644
  const queryAndChildGetterDescriptors = create(null);
1745
- // The reason we don't just call `import * as renderer from '../renderer'` here is that the bundle size
1746
- // is smaller if we reference each function individually. Otherwise Rollup will create one big frozen
1747
- // object representing the renderer, with a lot of methods we don't actually need.
1748
- const childGetters = [
1749
- 'children',
1750
- 'childNodes',
1751
- 'firstChild',
1752
- 'firstElementChild',
1753
- 'lastChild',
1754
- 'lastElementChild',
1755
- ];
1756
- function getChildGetter(methodName) {
1757
- switch (methodName) {
1758
- case 'children':
1759
- return getChildren;
1760
- case 'childNodes':
1761
- return getChildNodes;
1762
- case 'firstChild':
1763
- return getFirstChild;
1764
- case 'firstElementChild':
1765
- return getFirstElementChild;
1766
- case 'lastChild':
1767
- return getLastChild;
1768
- case 'lastElementChild':
1769
- return getLastElementChild;
1770
- }
1771
- }
1772
- // Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
1773
- for (const childGetter of childGetters) {
1774
- queryAndChildGetterDescriptors[childGetter] = {
1775
- get() {
1776
- const vm = getAssociatedVM(this);
1777
- const { elm } = vm;
1778
- if (process.env.NODE_ENV !== 'production') {
1779
- warnIfInvokedDuringConstruction(vm, childGetter);
1780
- }
1781
- return getChildGetter(childGetter)(elm);
1782
- },
1783
- configurable: true,
1784
- enumerable: true,
1785
- };
1786
- }
1787
1645
  const queryMethods = [
1788
1646
  'getElementsByClassName',
1789
1647
  'getElementsByTagName',
1790
1648
  'querySelector',
1791
1649
  'querySelectorAll',
1792
1650
  ];
1793
- function getQueryMethod(methodName) {
1794
- switch (methodName) {
1795
- case 'getElementsByClassName':
1796
- return getElementsByClassName;
1797
- case 'getElementsByTagName':
1798
- return getElementsByTagName;
1799
- case 'querySelector':
1800
- return querySelector;
1801
- case 'querySelectorAll':
1802
- return querySelectorAll;
1803
- }
1804
- }
1805
1651
  // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
1806
1652
  for (const queryMethod of queryMethods) {
1807
1653
  queryAndChildGetterDescriptors[queryMethod] = {
1808
1654
  value(arg) {
1809
1655
  const vm = getAssociatedVM(this);
1810
- const { elm } = vm;
1656
+ const { elm, renderer } = vm;
1811
1657
  if (process.env.NODE_ENV !== 'production') {
1812
1658
  warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
1813
1659
  }
1814
- return getQueryMethod(queryMethod)(elm, arg);
1660
+ return renderer[queryMethod](elm, arg);
1815
1661
  },
1816
1662
  configurable: true,
1817
1663
  enumerable: true,
@@ -3035,7 +2881,8 @@ function getComponentDef(Ctor) {
3035
2881
  * SPDX-License-Identifier: MIT
3036
2882
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3037
2883
  */
3038
- function getUpgradableConstructor(tagName) {
2884
+ function getUpgradableConstructor(tagName, renderer) {
2885
+ const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
3039
2886
  // Should never get a tag with upper case letter at this point, the compiler should
3040
2887
  // produce only tags with lowercase letters
3041
2888
  // But, for backwards compatibility, we will lower case the tagName
@@ -3048,7 +2895,7 @@ function getUpgradableConstructor(tagName) {
3048
2895
  * LWC Upgradable Element reference to an element that was created
3049
2896
  * via the scoped registry mechanism, and that is ready to be upgraded.
3050
2897
  */
3051
- CE = class LWCUpgradableElement extends HTMLElementExported {
2898
+ CE = class LWCUpgradableElement extends RendererHTMLElement {
3052
2899
  constructor(upgradeCallback) {
3053
2900
  super();
3054
2901
  if (isFunction$1(upgradeCallback)) {
@@ -3081,7 +2928,7 @@ function isSameVnode(vnode1, vnode2) {
3081
2928
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3082
2929
  */
3083
2930
  const ColonCharCode = 58;
3084
- function patchAttributes(oldVnode, vnode) {
2931
+ function patchAttributes(oldVnode, vnode, renderer) {
3085
2932
  const { attrs } = vnode.data;
3086
2933
  if (isUndefined$1(attrs)) {
3087
2934
  return;
@@ -3091,6 +2938,7 @@ function patchAttributes(oldVnode, vnode) {
3091
2938
  return;
3092
2939
  }
3093
2940
  const { elm } = vnode;
2941
+ const { setAttribute, removeAttribute } = renderer;
3094
2942
  for (const key in attrs) {
3095
2943
  const cur = attrs[key];
3096
2944
  const old = oldAttrs[key];
@@ -3126,7 +2974,7 @@ function isLiveBindingProp(sel, key) {
3126
2974
  // instead of relying on internally tracked values.
3127
2975
  return sel === 'input' && (key === 'value' || key === 'checked');
3128
2976
  }
3129
- function patchProps(oldVnode, vnode) {
2977
+ function patchProps(oldVnode, vnode, renderer) {
3130
2978
  const { props } = vnode.data;
3131
2979
  if (isUndefined$1(props)) {
3132
2980
  return;
@@ -3137,6 +2985,7 @@ function patchProps(oldVnode, vnode) {
3137
2985
  }
3138
2986
  const isFirstPatch = isNull(oldVnode);
3139
2987
  const { elm, sel } = vnode;
2988
+ const { getProperty, setProperty } = renderer;
3140
2989
  for (const key in props) {
3141
2990
  const cur = props[key];
3142
2991
  // Set the property if it's the first time is is patched or if the previous property is
@@ -3188,12 +3037,13 @@ function getMapFromClassName(className) {
3188
3037
  }
3189
3038
  return map;
3190
3039
  }
3191
- function patchClassAttribute(oldVnode, vnode) {
3040
+ function patchClassAttribute(oldVnode, vnode, renderer) {
3192
3041
  const { elm, data: { className: newClass }, } = vnode;
3193
3042
  const oldClass = isNull(oldVnode) ? undefined : oldVnode.data.className;
3194
3043
  if (oldClass === newClass) {
3195
3044
  return;
3196
3045
  }
3046
+ const { getClassList } = renderer;
3197
3047
  const classList = getClassList(elm);
3198
3048
  const newClassMap = getMapFromClassName(newClass);
3199
3049
  const oldClassMap = getMapFromClassName(oldClass);
@@ -3218,12 +3068,13 @@ function patchClassAttribute(oldVnode, vnode) {
3218
3068
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3219
3069
  */
3220
3070
  // The style property is a string when defined via an expression in the template.
3221
- function patchStyleAttribute(oldVnode, vnode) {
3071
+ function patchStyleAttribute(oldVnode, vnode, renderer) {
3222
3072
  const { elm, data: { style: newStyle }, } = vnode;
3223
3073
  const oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
3224
3074
  if (oldStyle === newStyle) {
3225
3075
  return;
3226
3076
  }
3077
+ const { setAttribute, removeAttribute } = renderer;
3227
3078
  if (!isString(newStyle) || newStyle === '') {
3228
3079
  removeAttribute(elm, 'style');
3229
3080
  }
@@ -3238,11 +3089,12 @@ function patchStyleAttribute(oldVnode, vnode) {
3238
3089
  * SPDX-License-Identifier: MIT
3239
3090
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3240
3091
  */
3241
- function applyEventListeners(vnode) {
3092
+ function applyEventListeners(vnode, renderer) {
3242
3093
  const { elm, data: { on }, } = vnode;
3243
3094
  if (isUndefined$1(on)) {
3244
3095
  return;
3245
3096
  }
3097
+ const { addEventListener } = renderer;
3246
3098
  for (const name in on) {
3247
3099
  const handler = on[name];
3248
3100
  addEventListener(elm, name, handler);
@@ -3258,11 +3110,12 @@ function applyEventListeners(vnode) {
3258
3110
  // The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
3259
3111
  // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
3260
3112
  // different classnames properties individually instead of via a string.
3261
- function applyStaticClassAttribute(vnode) {
3113
+ function applyStaticClassAttribute(vnode, renderer) {
3262
3114
  const { elm, data: { classMap }, } = vnode;
3263
3115
  if (isUndefined$1(classMap)) {
3264
3116
  return;
3265
3117
  }
3118
+ const { getClassList } = renderer;
3266
3119
  const classList = getClassList(elm);
3267
3120
  for (const name in classMap) {
3268
3121
  classList.add(name);
@@ -3278,11 +3131,12 @@ function applyStaticClassAttribute(vnode) {
3278
3131
  // The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
3279
3132
  // The compiler takes care of transforming the inline style into an object. It's faster to set the
3280
3133
  // different style properties individually instead of via a string.
3281
- function applyStaticStyleAttribute(vnode) {
3134
+ function applyStaticStyleAttribute(vnode, renderer) {
3282
3135
  const { elm, data: { styleDecls }, } = vnode;
3283
3136
  if (isUndefined$1(styleDecls)) {
3284
3137
  return;
3285
3138
  }
3139
+ const { setCSSStyleProperty } = renderer;
3286
3140
  for (let i = 0; i < styleDecls.length; i++) {
3287
3141
  const [prop, value, important] = styleDecls[i];
3288
3142
  setCSSStyleProperty(elm, prop, value, important);
@@ -3295,15 +3149,16 @@ function applyStaticStyleAttribute(vnode) {
3295
3149
  * SPDX-License-Identifier: MIT
3296
3150
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3297
3151
  */
3298
- function patchChildren(c1, c2, parent) {
3152
+ function patchChildren(c1, c2, parent, renderer) {
3299
3153
  if (hasDynamicChildren(c2)) {
3300
- updateDynamicChildren(c1, c2, parent);
3154
+ updateDynamicChildren(c1, c2, parent, renderer);
3301
3155
  }
3302
3156
  else {
3303
- updateStaticChildren(c1, c2, parent);
3157
+ updateStaticChildren(c1, c2, parent, renderer);
3304
3158
  }
3305
3159
  }
3306
- function patch(n1, n2) {
3160
+ function patch(n1, n2, renderer) {
3161
+ var _a, _b;
3307
3162
  if (n1 === n2) {
3308
3163
  return;
3309
3164
  }
@@ -3317,80 +3172,115 @@ function patch(n1, n2) {
3317
3172
  }
3318
3173
  switch (n2.type) {
3319
3174
  case 0 /* Text */:
3320
- patchText(n1, n2);
3175
+ // VText has no special capability, fallback to the owner's renderer
3176
+ patchText(n1, n2, renderer);
3321
3177
  break;
3322
3178
  case 1 /* Comment */:
3323
- patchComment(n1, n2);
3179
+ // VComment has no special capability, fallback to the owner's renderer
3180
+ patchComment(n1, n2, renderer);
3181
+ break;
3182
+ case 4 /* Static */:
3183
+ n2.elm = n1.elm;
3324
3184
  break;
3325
3185
  case 2 /* Element */:
3326
- patchElement(n1, n2);
3186
+ patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3327
3187
  break;
3328
3188
  case 3 /* CustomElement */:
3329
- patchCustomElement(n1, n2);
3189
+ patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3330
3190
  break;
3331
3191
  }
3332
3192
  }
3333
- function mount(node, parent, anchor) {
3193
+ function mount(node, parent, renderer, anchor) {
3194
+ var _a, _b;
3334
3195
  switch (node.type) {
3335
3196
  case 0 /* Text */:
3336
- mountText(node, parent, anchor);
3197
+ // VText has no special capability, fallback to the owner's renderer
3198
+ mountText(node, parent, anchor, renderer);
3337
3199
  break;
3338
3200
  case 1 /* Comment */:
3339
- mountComment(node, parent, anchor);
3201
+ // VComment has no special capability, fallback to the owner's renderer
3202
+ mountComment(node, parent, anchor, renderer);
3203
+ break;
3204
+ case 4 /* Static */:
3205
+ // VStatic cannot have a custom renderer associated to them, using owner's renderer
3206
+ mountStatic(node, parent, anchor, renderer);
3340
3207
  break;
3341
3208
  case 2 /* Element */:
3342
- mountElement(node, parent, anchor);
3209
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3210
+ mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3343
3211
  break;
3344
3212
  case 3 /* CustomElement */:
3345
- mountCustomElement(node, parent, anchor);
3213
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3214
+ mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3346
3215
  break;
3347
3216
  }
3348
3217
  }
3349
- function patchText(n1, n2) {
3218
+ function patchText(n1, n2, renderer) {
3350
3219
  n2.elm = n1.elm;
3351
3220
  if (n2.text !== n1.text) {
3352
- updateTextContent(n2);
3221
+ updateTextContent(n2, renderer);
3353
3222
  }
3354
3223
  }
3355
- function mountText(node, parent, anchor) {
3356
- const { owner } = node;
3357
- const textNode = (node.elm = createText(node.text));
3358
- linkNodeToShadow(textNode, owner);
3359
- insertNode(textNode, parent, anchor);
3224
+ function mountText(vnode, parent, anchor, renderer) {
3225
+ const { owner } = vnode;
3226
+ const { createText } = renderer;
3227
+ const textNode = (vnode.elm = createText(vnode.text));
3228
+ linkNodeToShadow(textNode, owner, renderer);
3229
+ insertNode(textNode, parent, anchor, renderer);
3360
3230
  }
3361
- function patchComment(n1, n2) {
3231
+ function patchComment(n1, n2, renderer) {
3362
3232
  n2.elm = n1.elm;
3363
3233
  // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3364
3234
  // it is the case today.
3365
3235
  if (n2.text !== n1.text) {
3366
- updateTextContent(n2);
3236
+ updateTextContent(n2, renderer);
3367
3237
  }
3368
3238
  }
3369
- function mountComment(node, parent, anchor) {
3370
- const { owner } = node;
3371
- const commentNode = (node.elm = createComment(node.text));
3372
- linkNodeToShadow(commentNode, owner);
3373
- insertNode(commentNode, parent, anchor);
3239
+ function mountComment(vnode, parent, anchor, renderer) {
3240
+ const { owner } = vnode;
3241
+ const { createComment } = renderer;
3242
+ const commentNode = (vnode.elm = createComment(vnode.text));
3243
+ linkNodeToShadow(commentNode, owner, renderer);
3244
+ insertNode(commentNode, parent, anchor, renderer);
3374
3245
  }
3375
- function mountElement(vnode, parent, anchor) {
3246
+ function mountElement(vnode, parent, anchor, renderer) {
3376
3247
  const { sel, owner, data: { svg }, } = vnode;
3248
+ const { createElement } = renderer;
3377
3249
  const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3378
3250
  const elm = createElement(sel, namespace);
3379
- linkNodeToShadow(elm, owner);
3380
- fallbackElmHook(elm, vnode);
3251
+ linkNodeToShadow(elm, owner, renderer);
3252
+ fallbackElmHook(elm, vnode, renderer);
3381
3253
  vnode.elm = elm;
3382
- patchElementPropsAndAttrs$1(null, vnode);
3383
- insertNode(elm, parent, anchor);
3384
- mountVNodes(vnode.children, elm, null);
3254
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3255
+ insertNode(elm, parent, anchor, renderer);
3256
+ mountVNodes(vnode.children, elm, renderer, null);
3385
3257
  }
3386
- function patchElement(n1, n2) {
3258
+ function patchElement(n1, n2, renderer) {
3387
3259
  const elm = (n2.elm = n1.elm);
3388
- patchElementPropsAndAttrs$1(n1, n2);
3389
- patchChildren(n1.children, n2.children, elm);
3260
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3261
+ patchChildren(n1.children, n2.children, elm, renderer);
3390
3262
  }
3391
- function mountCustomElement(vnode, parent, anchor) {
3263
+ function mountStatic(vnode, parent, anchor, renderer) {
3264
+ const { owner } = vnode;
3265
+ const { cloneNode, isSyntheticShadowDefined } = renderer;
3266
+ const elm = (vnode.elm = cloneNode(vnode.fragment, true));
3267
+ linkNodeToShadow(elm, owner, renderer);
3268
+ // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3269
+ const { renderMode, shadowMode } = owner;
3270
+ if (isSyntheticShadowDefined) {
3271
+ if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
3272
+ elm[KEY__SHADOW_STATIC] = true;
3273
+ }
3274
+ }
3275
+ if (process.env.NODE_ENV !== 'production') {
3276
+ const isLight = renderMode === 0 /* Light */;
3277
+ patchElementWithRestrictions(elm, { isPortal: false, isLight });
3278
+ }
3279
+ insertNode(elm, parent, anchor, renderer);
3280
+ }
3281
+ function mountCustomElement(vnode, parent, anchor, renderer) {
3392
3282
  const { sel, owner } = vnode;
3393
- const UpgradableConstructor = getUpgradableConstructor(sel);
3283
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3394
3284
  /**
3395
3285
  * Note: if the upgradable constructor does not expect, or throw when we new it
3396
3286
  * with a callback as the first argument, we could implement a more advanced
@@ -3400,9 +3290,9 @@ function mountCustomElement(vnode, parent, anchor) {
3400
3290
  let vm;
3401
3291
  const elm = new UpgradableConstructor((elm) => {
3402
3292
  // the custom element from the registry is expecting an upgrade callback
3403
- vm = createViewModelHook(elm, vnode);
3293
+ vm = createViewModelHook(elm, vnode, renderer);
3404
3294
  });
3405
- linkNodeToShadow(elm, owner);
3295
+ linkNodeToShadow(elm, owner, renderer);
3406
3296
  vnode.elm = elm;
3407
3297
  vnode.vm = vm;
3408
3298
  if (vm) {
@@ -3411,23 +3301,23 @@ function mountCustomElement(vnode, parent, anchor) {
3411
3301
  else if (vnode.ctor !== UpgradableConstructor) {
3412
3302
  throw new TypeError(`Incorrect Component Constructor`);
3413
3303
  }
3414
- patchElementPropsAndAttrs$1(null, vnode);
3415
- insertNode(elm, parent, anchor);
3304
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3305
+ insertNode(elm, parent, anchor, renderer);
3416
3306
  if (vm) {
3417
3307
  if (process.env.NODE_ENV !== 'production') {
3418
3308
  assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
3419
3309
  }
3420
3310
  runConnectedCallback(vm);
3421
3311
  }
3422
- mountVNodes(vnode.children, elm, null);
3312
+ mountVNodes(vnode.children, elm, renderer, null);
3423
3313
  if (vm) {
3424
3314
  appendVM(vm);
3425
3315
  }
3426
3316
  }
3427
- function patchCustomElement(n1, n2) {
3317
+ function patchCustomElement(n1, n2, renderer) {
3428
3318
  const elm = (n2.elm = n1.elm);
3429
3319
  const vm = (n2.vm = n1.vm);
3430
- patchElementPropsAndAttrs$1(n1, n2);
3320
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3431
3321
  if (!isUndefined$1(vm)) {
3432
3322
  // in fallback mode, the allocation will always set children to
3433
3323
  // empty and delegate the real allocation to the slot elements
@@ -3435,34 +3325,36 @@ function patchCustomElement(n1, n2) {
3435
3325
  }
3436
3326
  // in fallback mode, the children will be always empty, so, nothing
3437
3327
  // will happen, but in native, it does allocate the light dom
3438
- patchChildren(n1.children, n2.children, elm);
3328
+ patchChildren(n1.children, n2.children, elm, renderer);
3439
3329
  if (!isUndefined$1(vm)) {
3440
3330
  // this will probably update the shadowRoot, but only if the vm is in a dirty state
3441
3331
  // this is important to preserve the top to bottom synchronous rendering phase.
3442
3332
  rerenderVM(vm);
3443
3333
  }
3444
3334
  }
3445
- function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
3335
+ function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
3446
3336
  for (; start < end; ++start) {
3447
3337
  const vnode = vnodes[start];
3448
3338
  if (isVNode(vnode)) {
3449
- mount(vnode, parent, anchor);
3339
+ mount(vnode, parent, renderer, anchor);
3450
3340
  }
3451
3341
  }
3452
3342
  }
3453
- function unmount(vnode, parent, doRemove = false) {
3343
+ function unmount(vnode, parent, renderer, doRemove = false) {
3454
3344
  const { type, elm, sel } = vnode;
3455
3345
  // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3456
3346
  // subtree root, is the only element worth unmounting from the subtree.
3457
3347
  if (doRemove) {
3458
- removeNode(elm, parent);
3348
+ // The vnode might or might not have a data.renderer associated to it
3349
+ // but the removal used here is from the owner instead.
3350
+ removeNode(elm, parent, renderer);
3459
3351
  }
3460
3352
  switch (type) {
3461
3353
  case 2 /* Element */: {
3462
3354
  // Slot content is removed to trigger slotchange event when removing slot.
3463
3355
  // Only required for synthetic shadow.
3464
- const removeChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
3465
- unmountVNodes(vnode.children, elm, removeChildren);
3356
+ const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
3357
+ unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
3466
3358
  break;
3467
3359
  }
3468
3360
  case 3 /* CustomElement */: {
@@ -3475,11 +3367,11 @@ function unmount(vnode, parent, doRemove = false) {
3475
3367
  }
3476
3368
  }
3477
3369
  }
3478
- function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
3370
+ function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
3479
3371
  for (; start < end; ++start) {
3480
3372
  const ch = vnodes[start];
3481
3373
  if (isVNode(ch)) {
3482
- unmount(ch, parent, doRemove);
3374
+ unmount(ch, parent, renderer, doRemove);
3483
3375
  }
3484
3376
  }
3485
3377
  }
@@ -3493,15 +3385,19 @@ function setElementShadowToken(elm, token) {
3493
3385
  elm.$shadowToken$ = token;
3494
3386
  }
3495
3387
  // Set the scope token class for *.scoped.css styles
3496
- function setScopeTokenClassIfNecessary(elm, owner) {
3388
+ function setScopeTokenClassIfNecessary(elm, owner, renderer) {
3497
3389
  const { cmpTemplate, context } = owner;
3390
+ const { getClassList } = renderer;
3498
3391
  const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
3499
3392
  if (!isUndefined$1(token) && context.hasScopedStyles) {
3393
+ // TODO [#2762]: this dot notation with add is probably problematic
3394
+ // probably we should have a renderer api for just the add operation
3500
3395
  getClassList(elm).add(token);
3501
3396
  }
3502
3397
  }
3503
- function linkNodeToShadow(elm, owner) {
3398
+ function linkNodeToShadow(elm, owner, renderer) {
3504
3399
  const { renderRoot, renderMode, shadowMode } = owner;
3400
+ const { isSyntheticShadowDefined } = renderer;
3505
3401
  // TODO [#1164]: this should eventually be done by the polyfill directly
3506
3402
  if (isSyntheticShadowDefined) {
3507
3403
  if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
@@ -3509,8 +3405,9 @@ function linkNodeToShadow(elm, owner) {
3509
3405
  }
3510
3406
  }
3511
3407
  }
3512
- function updateTextContent(vnode) {
3408
+ function updateTextContent(vnode, renderer) {
3513
3409
  const { elm, text } = vnode;
3410
+ const { setText } = renderer;
3514
3411
  if (process.env.NODE_ENV !== 'production') {
3515
3412
  unlockDomMutation();
3516
3413
  }
@@ -3519,40 +3416,40 @@ function updateTextContent(vnode) {
3519
3416
  lockDomMutation();
3520
3417
  }
3521
3418
  }
3522
- function insertNode(node, parent, anchor) {
3419
+ function insertNode(node, parent, anchor, renderer) {
3523
3420
  if (process.env.NODE_ENV !== 'production') {
3524
3421
  unlockDomMutation();
3525
3422
  }
3526
- insert(node, parent, anchor);
3423
+ renderer.insert(node, parent, anchor);
3527
3424
  if (process.env.NODE_ENV !== 'production') {
3528
3425
  lockDomMutation();
3529
3426
  }
3530
3427
  }
3531
- function removeNode(node, parent) {
3428
+ function removeNode(node, parent, renderer) {
3532
3429
  if (process.env.NODE_ENV !== 'production') {
3533
3430
  unlockDomMutation();
3534
3431
  }
3535
- remove(node, parent);
3432
+ renderer.remove(node, parent);
3536
3433
  if (process.env.NODE_ENV !== 'production') {
3537
3434
  lockDomMutation();
3538
3435
  }
3539
3436
  }
3540
- function patchElementPropsAndAttrs$1(oldVnode, vnode) {
3437
+ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
3541
3438
  if (isNull(oldVnode)) {
3542
- applyEventListeners(vnode);
3543
- applyStaticClassAttribute(vnode);
3544
- applyStaticStyleAttribute(vnode);
3439
+ applyEventListeners(vnode, renderer);
3440
+ applyStaticClassAttribute(vnode, renderer);
3441
+ applyStaticStyleAttribute(vnode, renderer);
3545
3442
  }
3546
3443
  // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
3547
3444
  // value is set before type=radio.
3548
- patchClassAttribute(oldVnode, vnode);
3549
- patchStyleAttribute(oldVnode, vnode);
3550
- patchAttributes(oldVnode, vnode);
3551
- patchProps(oldVnode, vnode);
3445
+ patchClassAttribute(oldVnode, vnode, renderer);
3446
+ patchStyleAttribute(oldVnode, vnode, renderer);
3447
+ patchAttributes(oldVnode, vnode, renderer);
3448
+ patchProps(oldVnode, vnode, renderer);
3552
3449
  }
3553
- function fallbackElmHook(elm, vnode) {
3450
+ function fallbackElmHook(elm, vnode, renderer) {
3554
3451
  const { owner } = vnode;
3555
- setScopeTokenClassIfNecessary(elm, owner);
3452
+ setScopeTokenClassIfNecessary(elm, owner, renderer);
3556
3453
  if (owner.shadowMode === 1 /* Synthetic */) {
3557
3454
  const { data: { context }, } = vnode;
3558
3455
  const { stylesheetToken } = owner.context;
@@ -3600,7 +3497,7 @@ function allocateChildren(vnode, vm) {
3600
3497
  vnode.children = EmptyArray;
3601
3498
  }
3602
3499
  }
3603
- function createViewModelHook(elm, vnode) {
3500
+ function createViewModelHook(elm, vnode, renderer) {
3604
3501
  let vm = getAssociatedVMIfPresent(elm);
3605
3502
  // There is a possibility that a custom element is registered under tagName, in which case, the
3606
3503
  // initialization is already carry on, and there is nothing else to do here since this hook is
@@ -3609,7 +3506,7 @@ function createViewModelHook(elm, vnode) {
3609
3506
  return vm;
3610
3507
  }
3611
3508
  const { sel, mode, ctor, owner } = vnode;
3612
- setScopeTokenClassIfNecessary(elm, owner);
3509
+ setScopeTokenClassIfNecessary(elm, owner, renderer);
3613
3510
  if (owner.shadowMode === 1 /* Synthetic */) {
3614
3511
  const { stylesheetToken } = owner.context;
3615
3512
  // when running in synthetic shadow mode, we need to set the shadowToken value
@@ -3618,7 +3515,7 @@ function createViewModelHook(elm, vnode) {
3618
3515
  setElementShadowToken(elm, stylesheetToken);
3619
3516
  }
3620
3517
  }
3621
- vm = createVM(elm, ctor, {
3518
+ vm = createVM(elm, ctor, renderer, {
3622
3519
  mode,
3623
3520
  owner,
3624
3521
  tagName: sel,
@@ -3693,7 +3590,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
3693
3590
  }
3694
3591
  return map;
3695
3592
  }
3696
- function updateDynamicChildren(oldCh, newCh, parent) {
3593
+ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
3697
3594
  let oldStartIdx = 0;
3698
3595
  let newStartIdx = 0;
3699
3596
  let oldEndIdx = oldCh.length - 1;
@@ -3722,26 +3619,26 @@ function updateDynamicChildren(oldCh, newCh, parent) {
3722
3619
  newEndVnode = newCh[--newEndIdx];
3723
3620
  }
3724
3621
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
3725
- patch(oldStartVnode, newStartVnode);
3622
+ patch(oldStartVnode, newStartVnode, renderer);
3726
3623
  oldStartVnode = oldCh[++oldStartIdx];
3727
3624
  newStartVnode = newCh[++newStartIdx];
3728
3625
  }
3729
3626
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
3730
- patch(oldEndVnode, newEndVnode);
3627
+ patch(oldEndVnode, newEndVnode, renderer);
3731
3628
  oldEndVnode = oldCh[--oldEndIdx];
3732
3629
  newEndVnode = newCh[--newEndIdx];
3733
3630
  }
3734
3631
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
3735
3632
  // Vnode moved right
3736
- patch(oldStartVnode, newEndVnode);
3737
- insertNode(oldStartVnode.elm, parent, nextSibling(oldEndVnode.elm));
3633
+ patch(oldStartVnode, newEndVnode, renderer);
3634
+ insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
3738
3635
  oldStartVnode = oldCh[++oldStartIdx];
3739
3636
  newEndVnode = newCh[--newEndIdx];
3740
3637
  }
3741
3638
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
3742
3639
  // Vnode moved left
3743
- patch(oldEndVnode, newStartVnode);
3744
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
3640
+ patch(oldEndVnode, newStartVnode, renderer);
3641
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
3745
3642
  oldEndVnode = oldCh[--oldEndIdx];
3746
3643
  newStartVnode = newCh[++newStartIdx];
3747
3644
  }
@@ -3752,7 +3649,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
3752
3649
  idxInOld = oldKeyToIdx[newStartVnode.key];
3753
3650
  if (isUndefined$1(idxInOld)) {
3754
3651
  // New element
3755
- mount(newStartVnode, parent, oldStartVnode.elm);
3652
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3756
3653
  newStartVnode = newCh[++newStartIdx];
3757
3654
  }
3758
3655
  else {
@@ -3760,10 +3657,10 @@ function updateDynamicChildren(oldCh, newCh, parent) {
3760
3657
  if (isVNode(elmToMove)) {
3761
3658
  if (elmToMove.sel !== newStartVnode.sel) {
3762
3659
  // New element
3763
- mount(newStartVnode, parent, oldStartVnode.elm);
3660
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3764
3661
  }
3765
3662
  else {
3766
- patch(elmToMove, newStartVnode);
3663
+ patch(elmToMove, newStartVnode, renderer);
3767
3664
  // Delete the old child, but copy the array since it is read-only.
3768
3665
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3769
3666
  // so we only care about the `oldCh` object inside this function.
@@ -3775,7 +3672,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
3775
3672
  }
3776
3673
  // We've already cloned at least once, so it's no longer read-only
3777
3674
  oldCh[idxInOld] = undefined;
3778
- insertNode(elmToMove.elm, parent, oldStartVnode.elm);
3675
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
3779
3676
  }
3780
3677
  }
3781
3678
  newStartVnode = newCh[++newStartIdx];
@@ -3792,25 +3689,25 @@ function updateDynamicChildren(oldCh, newCh, parent) {
3792
3689
  n = newCh[++i];
3793
3690
  } while (!isVNode(n) && i < newChEnd);
3794
3691
  before = isVNode(n) ? n.elm : null;
3795
- mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
3692
+ mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
3796
3693
  }
3797
3694
  else {
3798
- unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
3695
+ unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
3799
3696
  }
3800
3697
  }
3801
3698
  }
3802
- function updateStaticChildren(c1, c2, parent) {
3699
+ function updateStaticChildren(c1, c2, parent, renderer) {
3803
3700
  const c1Length = c1.length;
3804
3701
  const c2Length = c2.length;
3805
3702
  if (c1Length === 0) {
3806
3703
  // the old list is empty, we can directly insert anything new
3807
- mountVNodes(c2, parent, null);
3704
+ mountVNodes(c2, parent, renderer, null);
3808
3705
  return;
3809
3706
  }
3810
3707
  if (c2Length === 0) {
3811
3708
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
3812
3709
  // this is the case in which the dynamic children of an if-directive should be removed
3813
- unmountVNodes(c1, parent, true);
3710
+ unmountVNodes(c1, parent, renderer, true);
3814
3711
  return;
3815
3712
  }
3816
3713
  // if the old list is not empty, the new list MUST have the same
@@ -3823,16 +3720,16 @@ function updateStaticChildren(c1, c2, parent) {
3823
3720
  if (isVNode(n1)) {
3824
3721
  if (isVNode(n2)) {
3825
3722
  // both vnodes are equivalent, and we just need to patch them
3826
- patch(n1, n2);
3723
+ patch(n1, n2, renderer);
3827
3724
  anchor = n2.elm;
3828
3725
  }
3829
3726
  else {
3830
3727
  // removing the old vnode since the new one is null
3831
- unmount(n1, parent, true);
3728
+ unmount(n1, parent, renderer, true);
3832
3729
  }
3833
3730
  }
3834
3731
  else if (isVNode(n2)) {
3835
- mount(n2, parent, anchor);
3732
+ mount(n2, parent, renderer, anchor);
3836
3733
  anchor = n2.elm;
3837
3734
  }
3838
3735
  }
@@ -3849,6 +3746,17 @@ const SymbolIterator = Symbol.iterator;
3849
3746
  function addVNodeToChildLWC(vnode) {
3850
3747
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
3851
3748
  }
3749
+ // [st]atic node
3750
+ function st(fragment, key) {
3751
+ return {
3752
+ type: 4 /* Static */,
3753
+ sel: undefined,
3754
+ key,
3755
+ elm: undefined,
3756
+ fragment,
3757
+ owner: getVMBeingRendered(),
3758
+ };
3759
+ }
3852
3760
  // [h]tml node
3853
3761
  function h(sel, data, children = EmptyArray) {
3854
3762
  const vmBeingRendered = getVMBeingRendered();
@@ -4238,6 +4146,7 @@ const api = freeze({
4238
4146
  co,
4239
4147
  dc,
4240
4148
  ti,
4149
+ st,
4241
4150
  gid,
4242
4151
  fid,
4243
4152
  shc,
@@ -4261,7 +4170,7 @@ function createInlineStyleVNode(content) {
4261
4170
  }, [api.t(content)]);
4262
4171
  }
4263
4172
  function updateStylesheetToken(vm, template) {
4264
- const { elm, context, renderMode, shadowMode } = vm;
4173
+ const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
4265
4174
  const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
4266
4175
  const isSyntheticShadow = renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */;
4267
4176
  const { hasScopedStyles } = context;
@@ -4378,7 +4287,7 @@ function getNearestNativeShadowComponent(vm) {
4378
4287
  return owner;
4379
4288
  }
4380
4289
  function createStylesheet(vm, stylesheets) {
4381
- const { renderMode, shadowMode } = vm;
4290
+ const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
4382
4291
  if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
4383
4292
  for (let i = 0; i < stylesheets.length; i++) {
4384
4293
  insertStylesheet(stylesheets[i]);
@@ -4389,8 +4298,7 @@ function createStylesheet(vm, stylesheets) {
4389
4298
  // This works in the client, because the stylesheets are created, and cached in the VM
4390
4299
  // the first time the VM renders.
4391
4300
  // native shadow or light DOM, SSR
4392
- const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4393
- return createInlineStyleVNode(combinedStylesheetContent);
4301
+ return ArrayMap.call(stylesheets, createInlineStyleVNode);
4394
4302
  }
4395
4303
  else {
4396
4304
  // native shadow or light DOM, DOM renderer
@@ -4558,6 +4466,59 @@ function validateLightDomTemplate(template, vm) {
4558
4466
  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"`);
4559
4467
  }
4560
4468
  }
4469
+ function buildParseFragmentFn(createFragmentFn) {
4470
+ return (strings, ...keys) => {
4471
+ const cache = create(null);
4472
+ return function () {
4473
+ const { context: { hasScopedStyles, stylesheetToken }, shadowMode, renderer, } = getVMBeingRendered();
4474
+ const hasStyleToken = !isUndefined$1(stylesheetToken);
4475
+ const isSyntheticShadow = shadowMode === 1 /* Synthetic */;
4476
+ let cacheKey = 0;
4477
+ if (hasStyleToken && hasScopedStyles) {
4478
+ cacheKey |= 1 /* HAS_SCOPED_STYLE */;
4479
+ }
4480
+ if (hasStyleToken && isSyntheticShadow) {
4481
+ cacheKey |= 2 /* SHADOW_MODE_SYNTHETIC */;
4482
+ }
4483
+ if (!isUndefined$1(cache[cacheKey])) {
4484
+ return cache[cacheKey];
4485
+ }
4486
+ const classToken = hasScopedStyles && hasStyleToken ? ' ' + stylesheetToken : '';
4487
+ const classAttrToken = hasScopedStyles && hasStyleToken ? ` class="${stylesheetToken}"` : '';
4488
+ const attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetToken : '';
4489
+ let htmlFragment = '';
4490
+ for (let i = 0, n = keys.length; i < n; i++) {
4491
+ switch (keys[i]) {
4492
+ case 0: // styleToken in existing class attr
4493
+ htmlFragment += strings[i] + classToken;
4494
+ break;
4495
+ case 1: // styleToken for added class attr
4496
+ htmlFragment += strings[i] + classAttrToken;
4497
+ break;
4498
+ case 2: // styleToken as attr
4499
+ htmlFragment += strings[i] + attrToken;
4500
+ break;
4501
+ case 3: // ${1}${2}
4502
+ htmlFragment += strings[i] + classAttrToken + attrToken;
4503
+ break;
4504
+ }
4505
+ }
4506
+ htmlFragment += strings[strings.length - 1];
4507
+ cache[cacheKey] = createFragmentFn(htmlFragment, renderer);
4508
+ return cache[cacheKey];
4509
+ };
4510
+ };
4511
+ }
4512
+ // Note: at the moment this code executes, we don't have a renderer yet.
4513
+ const parseFragment = buildParseFragmentFn((html, renderer) => {
4514
+ const { createFragment } = renderer;
4515
+ return createFragment(html);
4516
+ });
4517
+ const parseSVGFragment = buildParseFragmentFn((html, renderer) => {
4518
+ const { createFragment, getFirstChild } = renderer;
4519
+ const fragment = createFragment('<svg>' + html + '</svg>');
4520
+ return getFirstChild(fragment);
4521
+ });
4561
4522
  function evaluateTemplate(vm, html) {
4562
4523
  if (process.env.NODE_ENV !== 'production') {
4563
4524
  assert.isTrue(isFunction$1(html), `evaluateTemplate() second argument must be an imported template instead of ${toString$1(html)}`);
@@ -4604,7 +4565,7 @@ function evaluateTemplate(vm, html) {
4604
4565
  // Evaluate, create stylesheet and cache the produced VNode for future
4605
4566
  // re-rendering.
4606
4567
  const stylesheetsContent = getStylesheetsContent(vm, html);
4607
- context.styleVNode =
4568
+ context.styleVNodes =
4608
4569
  stylesheetsContent.length === 0
4609
4570
  ? null
4610
4571
  : createStylesheet(vm, stylesheetsContent);
@@ -4621,9 +4582,9 @@ function evaluateTemplate(vm, html) {
4621
4582
  // Set the global flag that template is being updated
4622
4583
  isUpdatingTemplate = true;
4623
4584
  vnodes = html.call(undefined, api, component, cmpSlots, context.tplCache);
4624
- const { styleVNode } = context;
4625
- if (!isNull(styleVNode)) {
4626
- ArrayUnshift.call(vnodes, styleVNode);
4585
+ const { styleVNodes } = context;
4586
+ if (!isNull(styleVNodes)) {
4587
+ ArrayUnshift.apply(vnodes, styleVNodes);
4627
4588
  }
4628
4589
  });
4629
4590
  }, () => {
@@ -4953,7 +4914,7 @@ function getNearestShadowAncestor(vm) {
4953
4914
  return ancestor;
4954
4915
  }
4955
4916
 
4956
- function createVM(elm, ctor, options) {
4917
+ function createVM(elm, ctor, renderer, options) {
4957
4918
  const {
4958
4919
  mode,
4959
4920
  owner,
@@ -4988,7 +4949,7 @@ function createVM(elm, ctor, options) {
4988
4949
  hasTokenInClass: undefined,
4989
4950
  hasTokenInAttribute: undefined,
4990
4951
  hasScopedStyles: undefined,
4991
- styleVNode: null,
4952
+ styleVNodes: null,
4992
4953
  tplCache: EmptyObject,
4993
4954
  wiredConnecting: EmptyArray,
4994
4955
  wiredDisconnecting: EmptyArray
@@ -5002,9 +4963,10 @@ function createVM(elm, ctor, options) {
5002
4963
  renderRoot: null,
5003
4964
  callHook,
5004
4965
  setHook,
5005
- getHook
4966
+ getHook,
4967
+ renderer
5006
4968
  };
5007
- vm.shadowMode = computeShadowMode(vm);
4969
+ vm.shadowMode = computeShadowMode(vm, renderer);
5008
4970
  vm.tro = getTemplateReactiveObserver(vm);
5009
4971
 
5010
4972
  if (process.env.NODE_ENV !== 'production') {
@@ -5029,10 +4991,14 @@ function createVM(elm, ctor, options) {
5029
4991
  return vm;
5030
4992
  }
5031
4993
 
5032
- function computeShadowMode(vm) {
4994
+ function computeShadowMode(vm, renderer) {
5033
4995
  const {
5034
4996
  def
5035
4997
  } = vm;
4998
+ const {
4999
+ isSyntheticShadowDefined,
5000
+ isNativeShadowDefined
5001
+ } = renderer;
5036
5002
  let shadowMode;
5037
5003
 
5038
5004
  if (isSyntheticShadowDefined) {
@@ -5134,7 +5100,8 @@ function rehydrate(vm) {
5134
5100
  function patchShadowRoot(vm, newCh) {
5135
5101
  const {
5136
5102
  renderRoot,
5137
- children: oldCh
5103
+ children: oldCh,
5104
+ renderer
5138
5105
  } = vm; // caching the new children collection
5139
5106
 
5140
5107
  vm.children = newCh;
@@ -5150,7 +5117,7 @@ function patchShadowRoot(vm, newCh) {
5150
5117
  , vm);
5151
5118
  }, () => {
5152
5119
  // job
5153
- patchChildren(oldCh, newCh, renderRoot);
5120
+ patchChildren(oldCh, newCh, renderRoot, renderer);
5154
5121
  }, () => {
5155
5122
  // post
5156
5123
  logOperationEnd(2
@@ -5175,6 +5142,9 @@ function runRenderedCallback(vm) {
5175
5142
  const {
5176
5143
  def: {
5177
5144
  renderedCallback
5145
+ },
5146
+ renderer: {
5147
+ ssr
5178
5148
  }
5179
5149
  } = vm;
5180
5150
 
@@ -5412,7 +5382,10 @@ function recursivelyDisconnectChildren(vnodes) {
5412
5382
  function resetComponentRoot(vm) {
5413
5383
  const {
5414
5384
  children,
5415
- renderRoot
5385
+ renderRoot,
5386
+ renderer: {
5387
+ remove
5388
+ }
5416
5389
  } = vm;
5417
5390
 
5418
5391
  for (let i = 0, len = children.length; i < len; i++) {
@@ -5428,6 +5401,12 @@ function resetComponentRoot(vm) {
5428
5401
  vm.velements = EmptyArray;
5429
5402
  }
5430
5403
  function scheduleRehydration(vm) {
5404
+ const {
5405
+ renderer: {
5406
+ ssr
5407
+ }
5408
+ } = vm;
5409
+
5431
5410
  if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5432
5411
  return;
5433
5412
  }
@@ -5604,6 +5583,9 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
5604
5583
  context: {
5605
5584
  wiredConnecting,
5606
5585
  wiredDisconnecting
5586
+ },
5587
+ renderer: {
5588
+ dispatchEvent
5607
5589
  }
5608
5590
  } = vm; // waiting for the component to be connected to formally request the context via the token
5609
5591
 
@@ -5875,70 +5857,90 @@ function hydrateRoot(vm) {
5875
5857
  function hydrateVM(vm) {
5876
5858
  const children = renderComponent(vm);
5877
5859
  vm.children = children;
5878
- const parentNode = vm.renderRoot;
5860
+ const { renderRoot: parentNode, renderer: { getFirstChild }, } = vm;
5879
5861
  hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
5880
5862
  runRenderedCallback(vm);
5881
5863
  }
5882
- function hydrateNode(node, vnode) {
5864
+ function hydrateNode(node, vnode, renderer) {
5865
+ var _a, _b;
5883
5866
  let hydratedNode;
5884
5867
  switch (vnode.type) {
5885
5868
  case 0 /* Text */:
5886
- hydratedNode = hydrateText(node, vnode);
5869
+ // VText has no special capability, fallback to the owner's renderer
5870
+ hydratedNode = hydrateText(node, vnode, renderer);
5887
5871
  break;
5888
5872
  case 1 /* Comment */:
5889
- hydratedNode = hydrateComment(node, vnode);
5873
+ // VComment has no special capability, fallback to the owner's renderer
5874
+ hydratedNode = hydrateComment(node, vnode, renderer);
5875
+ break;
5876
+ case 4 /* Static */:
5877
+ // VStatic are cacheable and cannot have custom renderer associated to them
5878
+ hydratedNode = hydrateStaticElement(node, vnode, renderer);
5890
5879
  break;
5891
5880
  case 2 /* Element */:
5892
- hydratedNode = hydrateElement(node, vnode);
5881
+ hydratedNode = hydrateElement(node, vnode, (_a = vnode.data.renderer) !== null && _a !== void 0 ? _a : renderer);
5893
5882
  break;
5894
5883
  case 3 /* CustomElement */:
5895
- hydratedNode = hydrateCustomElement(node, vnode);
5884
+ hydratedNode = hydrateCustomElement(node, vnode, (_b = vnode.data.renderer) !== null && _b !== void 0 ? _b : renderer);
5896
5885
  break;
5897
5886
  }
5898
- return nextSibling(hydratedNode);
5887
+ return renderer.nextSibling(hydratedNode);
5899
5888
  }
5900
- function hydrateText(node, vnode) {
5889
+ function hydrateText(node, vnode, renderer) {
5901
5890
  var _a;
5902
- if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */)) {
5903
- return handleMismatch(node, vnode);
5891
+ if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */, renderer)) {
5892
+ return handleMismatch(node, vnode, renderer);
5904
5893
  }
5905
5894
  if (process.env.NODE_ENV !== 'production') {
5895
+ const { getProperty } = renderer;
5906
5896
  const nodeValue = getProperty(node, 'nodeValue');
5907
5897
  if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
5908
5898
  logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
5909
5899
  }
5910
5900
  }
5901
+ const { setText } = renderer;
5911
5902
  setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5912
5903
  vnode.elm = node;
5913
5904
  return node;
5914
5905
  }
5915
- function hydrateComment(node, vnode) {
5906
+ function hydrateComment(node, vnode, renderer) {
5916
5907
  var _a;
5917
- if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */)) {
5918
- return handleMismatch(node, vnode);
5908
+ if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */, renderer)) {
5909
+ return handleMismatch(node, vnode, renderer);
5919
5910
  }
5920
5911
  if (process.env.NODE_ENV !== 'production') {
5912
+ const { getProperty } = renderer;
5921
5913
  const nodeValue = getProperty(node, 'nodeValue');
5922
5914
  if (nodeValue !== vnode.text) {
5923
5915
  logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
5924
5916
  }
5925
5917
  }
5918
+ const { setProperty } = renderer;
5926
5919
  setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5927
5920
  vnode.elm = node;
5928
5921
  return node;
5929
5922
  }
5930
- function hydrateElement(elm, vnode) {
5931
- if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
5932
- !isMatchingElement(vnode, elm)) {
5933
- return handleMismatch(elm, vnode);
5923
+ function hydrateStaticElement(elm, vnode, renderer) {
5924
+ if (!areCompatibleNodes(vnode.fragment, elm, vnode, renderer)) {
5925
+ return handleMismatch(elm, vnode, renderer);
5926
+ }
5927
+ vnode.elm = elm;
5928
+ return elm;
5929
+ }
5930
+ function hydrateElement(elm, vnode, renderer) {
5931
+ if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
5932
+ !isMatchingElement(vnode, elm, renderer)) {
5933
+ return handleMismatch(elm, vnode, renderer);
5934
5934
  }
5935
5935
  vnode.elm = elm;
5936
+ const { owner } = vnode;
5936
5937
  const { context } = vnode.data;
5937
5938
  const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual" /* Manual */);
5938
5939
  if (isDomManual) {
5939
5940
  // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5940
5941
  // remove the innerHTML from props so it reuses the existing dom elements.
5941
- const { props } = vnode.data;
5942
+ const { data: { props }, } = vnode;
5943
+ const { getProperty } = renderer;
5942
5944
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5943
5945
  if (getProperty(elm, 'innerHTML') === props.innerHTML) {
5944
5946
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
@@ -5946,24 +5948,25 @@ function hydrateElement(elm, vnode) {
5946
5948
  }
5947
5949
  else {
5948
5950
  if (process.env.NODE_ENV !== 'production') {
5949
- logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
5951
+ logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, owner);
5950
5952
  }
5951
5953
  }
5952
5954
  }
5953
5955
  }
5954
- patchElementPropsAndAttrs(vnode);
5956
+ patchElementPropsAndAttrs(vnode, renderer);
5955
5957
  if (!isDomManual) {
5956
- hydrateChildren(getFirstChild(elm), vnode.children, elm, vnode.owner);
5958
+ const { getFirstChild } = renderer;
5959
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, owner);
5957
5960
  }
5958
5961
  return elm;
5959
5962
  }
5960
- function hydrateCustomElement(elm, vnode) {
5961
- if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
5962
- !isMatchingElement(vnode, elm)) {
5963
- return handleMismatch(elm, vnode);
5963
+ function hydrateCustomElement(elm, vnode, renderer) {
5964
+ if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
5965
+ !isMatchingElement(vnode, elm, renderer)) {
5966
+ return handleMismatch(elm, vnode, renderer);
5964
5967
  }
5965
5968
  const { sel, mode, ctor, owner } = vnode;
5966
- const vm = createVM(elm, ctor, {
5969
+ const vm = createVM(elm, ctor, renderer, {
5967
5970
  mode,
5968
5971
  owner,
5969
5972
  tagName: sel,
@@ -5972,13 +5975,14 @@ function hydrateCustomElement(elm, vnode) {
5972
5975
  vnode.elm = elm;
5973
5976
  vnode.vm = vm;
5974
5977
  allocateChildren(vnode, vm);
5975
- patchElementPropsAndAttrs(vnode);
5978
+ patchElementPropsAndAttrs(vnode, renderer);
5976
5979
  // Insert hook section:
5977
5980
  if (process.env.NODE_ENV !== 'production') {
5978
5981
  assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
5979
5982
  }
5980
5983
  runConnectedCallback(vm);
5981
5984
  if (vm.renderMode !== 0 /* Light */) {
5985
+ const { getFirstChild } = renderer;
5982
5986
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5983
5987
  // Note: for Light DOM, this is handled while hydrating the VM
5984
5988
  hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
@@ -5990,11 +5994,12 @@ function hydrateChildren(node, children, parentNode, owner) {
5990
5994
  let hasWarned = false;
5991
5995
  let nextNode = node;
5992
5996
  let anchor = null;
5997
+ const { renderer } = owner;
5993
5998
  for (let i = 0; i < children.length; i++) {
5994
5999
  const childVnode = children[i];
5995
6000
  if (!isNull(childVnode)) {
5996
6001
  if (nextNode) {
5997
- nextNode = hydrateNode(nextNode, childVnode);
6002
+ nextNode = hydrateNode(nextNode, childVnode, renderer);
5998
6003
  anchor = childVnode.elm;
5999
6004
  }
6000
6005
  else {
@@ -6005,7 +6010,7 @@ function hydrateChildren(node, children, parentNode, owner) {
6005
6010
  logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
6006
6011
  }
6007
6012
  }
6008
- mount(childVnode, parentNode, anchor);
6013
+ mount(childVnode, parentNode, renderer, anchor);
6009
6014
  anchor = childVnode.elm;
6010
6015
  }
6011
6016
  }
@@ -6017,30 +6022,32 @@ function hydrateChildren(node, children, parentNode, owner) {
6017
6022
  logError(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
6018
6023
  }
6019
6024
  }
6025
+ // nextSibling is mostly harmless, and since we don't have
6026
+ // a good reference to what element to act upon, we instead
6027
+ // rely on the vm's associated renderer for navigating to the
6028
+ // next node in the list to be hydrated.
6029
+ const { nextSibling } = renderer;
6020
6030
  do {
6021
6031
  const current = nextNode;
6022
6032
  nextNode = nextSibling(nextNode);
6023
- removeNode(current, parentNode);
6033
+ removeNode(current, parentNode, renderer);
6024
6034
  } while (nextNode);
6025
6035
  }
6026
6036
  }
6027
- function handleMismatch(node, vnode, msg) {
6037
+ function handleMismatch(node, vnode, renderer) {
6028
6038
  hasMismatch = true;
6029
- if (!isUndefined$1(msg)) {
6030
- if (process.env.NODE_ENV !== 'production') {
6031
- logError(msg, vnode.owner);
6032
- }
6033
- }
6039
+ const { getProperty } = renderer;
6034
6040
  const parentNode = getProperty(node, 'parentNode');
6035
- mount(vnode, parentNode, node);
6036
- removeNode(node, parentNode);
6041
+ mount(vnode, parentNode, renderer, node);
6042
+ removeNode(node, parentNode, renderer);
6037
6043
  return vnode.elm;
6038
6044
  }
6039
- function patchElementPropsAndAttrs(vnode) {
6040
- applyEventListeners(vnode);
6041
- patchProps(null, vnode);
6045
+ function patchElementPropsAndAttrs(vnode, renderer) {
6046
+ applyEventListeners(vnode, renderer);
6047
+ patchProps(null, vnode, renderer);
6042
6048
  }
6043
- function hasCorrectNodeType(vnode, node, nodeType) {
6049
+ function hasCorrectNodeType(vnode, node, nodeType, renderer) {
6050
+ const { getProperty } = renderer;
6044
6051
  if (getProperty(node, 'nodeType') !== nodeType) {
6045
6052
  if (process.env.NODE_ENV !== 'production') {
6046
6053
  logError('Hydration mismatch: incorrect node type received', vnode.owner);
@@ -6049,36 +6056,41 @@ function hasCorrectNodeType(vnode, node, nodeType) {
6049
6056
  }
6050
6057
  return true;
6051
6058
  }
6052
- function isMatchingElement(vnode, elm) {
6059
+ function isMatchingElement(vnode, elm, renderer) {
6060
+ const { getProperty } = renderer;
6053
6061
  if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
6054
6062
  if (process.env.NODE_ENV !== 'production') {
6055
6063
  logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
6056
6064
  }
6057
6065
  return false;
6058
6066
  }
6059
- const hasIncompatibleAttrs = validateAttrs(vnode, elm);
6060
- const hasIncompatibleClass = validateClassAttr(vnode, elm);
6061
- const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
6067
+ const hasIncompatibleAttrs = validateAttrs(vnode, elm, renderer);
6068
+ const hasIncompatibleClass = validateClassAttr(vnode, elm, renderer);
6069
+ const hasIncompatibleStyle = validateStyleAttr(vnode, elm, renderer);
6062
6070
  return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
6063
6071
  }
6064
- function validateAttrs(vnode, elm) {
6072
+ function validateAttrs(vnode, elm, renderer) {
6065
6073
  const { data: { attrs = {} }, } = vnode;
6066
6074
  let nodesAreCompatible = true;
6067
6075
  // Validate attributes, though we could always recovery from those by running the update mods.
6068
6076
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6069
6077
  for (const [attrName, attrValue] of Object.entries(attrs)) {
6078
+ const { owner } = vnode;
6079
+ const { getAttribute } = renderer;
6070
6080
  const elmAttrValue = getAttribute(elm, attrName);
6071
6081
  if (String(attrValue) !== elmAttrValue) {
6072
6082
  if (process.env.NODE_ENV !== 'production') {
6073
- logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
6083
+ const { getProperty } = renderer;
6084
+ logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, owner);
6074
6085
  }
6075
6086
  nodesAreCompatible = false;
6076
6087
  }
6077
6088
  }
6078
6089
  return nodesAreCompatible;
6079
6090
  }
6080
- function validateClassAttr(vnode, elm) {
6091
+ function validateClassAttr(vnode, elm, renderer) {
6081
6092
  const { data: { className, classMap }, } = vnode;
6093
+ const { getProperty, getClassList } = renderer;
6082
6094
  let nodesAreCompatible = true;
6083
6095
  let vnodeClassName;
6084
6096
  if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
@@ -6109,8 +6121,9 @@ function validateClassAttr(vnode, elm) {
6109
6121
  }
6110
6122
  return nodesAreCompatible;
6111
6123
  }
6112
- function validateStyleAttr(vnode, elm) {
6124
+ function validateStyleAttr(vnode, elm, renderer) {
6113
6125
  const { data: { style, styleDecls }, } = vnode;
6126
+ const { getAttribute } = renderer;
6114
6127
  const elmStyle = getAttribute(elm, 'style') || '';
6115
6128
  let vnodeStyle;
6116
6129
  let nodesAreCompatible = true;
@@ -6143,11 +6156,45 @@ function validateStyleAttr(vnode, elm) {
6143
6156
  }
6144
6157
  if (!nodesAreCompatible) {
6145
6158
  if (process.env.NODE_ENV !== 'production') {
6159
+ const { getProperty } = renderer;
6146
6160
  logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
6147
6161
  }
6148
6162
  }
6149
6163
  return nodesAreCompatible;
6150
6164
  }
6165
+ function areCompatibleNodes(client, ssr, vnode, renderer) {
6166
+ const { getProperty, getAttribute } = renderer;
6167
+ if (getProperty(client, 'nodeType') === 3 /* TEXT */) {
6168
+ if (!hasCorrectNodeType(vnode, ssr, 3 /* TEXT */, renderer)) {
6169
+ return false;
6170
+ }
6171
+ return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
6172
+ }
6173
+ if (getProperty(client, 'nodeType') === 8 /* COMMENT */) {
6174
+ if (!hasCorrectNodeType(vnode, ssr, 8 /* COMMENT */, renderer)) {
6175
+ return false;
6176
+ }
6177
+ return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
6178
+ }
6179
+ if (!hasCorrectNodeType(vnode, ssr, 1 /* ELEMENT */, renderer)) {
6180
+ return false;
6181
+ }
6182
+ let isCompatibleElements = true;
6183
+ if (getProperty(client, 'tagName') !== getProperty(ssr, 'tagName')) {
6184
+ if (process.env.NODE_ENV !== 'production') {
6185
+ logError(`Hydration mismatch: expecting element with tag "${getProperty(client, 'tagName').toLowerCase()}" but found "${getProperty(ssr, 'tagName').toLowerCase()}".`, vnode.owner);
6186
+ }
6187
+ return false;
6188
+ }
6189
+ const clientAttrsNames = getProperty(client, 'getAttributeNames').call(client);
6190
+ clientAttrsNames.forEach((attrName) => {
6191
+ if (getAttribute(client, attrName) !== getAttribute(ssr, attrName)) {
6192
+ logError(`Mismatch hydrating element <${getProperty(client, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${getAttribute(client, attrName)}" but found "${getAttribute(ssr, attrName)}"`, vnode.owner);
6193
+ isCompatibleElements = false;
6194
+ }
6195
+ });
6196
+ return isCompatibleElements;
6197
+ }
6151
6198
 
6152
6199
  /*
6153
6200
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6284,5 +6331,5 @@ function getComponentConstructor(elm) {
6284
6331
  return ctor;
6285
6332
  }
6286
6333
 
6287
- export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setAddEventListener, setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setHooks, setInsert, setInsertStylesheet, setIsConnected, setIsHydrating, setIsNativeShadowDefined, setIsSyntheticShadowDefined, setNextSibling, setQuerySelector, setQuerySelectorAll, setRemove, setRemoveAttribute, setRemoveEventListener, setSetAttribute, setSetCSSStyleProperty, setSetProperty, setSetText, setSsr, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6288
- /* version: 2.14.1 */
6334
+ export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6335
+ /* version: 2.16.0 */