@lwc/engine-core 2.14.1 → 2.14.2
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.
- package/dist/engine-core.cjs.js +305 -430
- package/dist/engine-core.js +306 -392
- package/package.json +3 -3
- package/types/framework/main.d.ts +0 -1
- package/types/framework/modules/attrs.d.ts +2 -1
- package/types/framework/modules/computed-class-attr.d.ts +2 -1
- package/types/framework/modules/computed-style-attr.d.ts +2 -1
- package/types/framework/modules/events.d.ts +2 -1
- package/types/framework/modules/props.d.ts +2 -1
- package/types/framework/modules/static-class-attr.d.ts +2 -1
- package/types/framework/modules/static-style-attr.d.ts +2 -1
- package/types/framework/renderer.d.ts +46 -0
- package/types/framework/rendering.d.ts +4 -3
- package/types/framework/upgradable-element.d.ts +2 -1
- package/types/framework/vm.d.ts +5 -2
- package/types/framework/vnodes.d.ts +3 -1
- package/types/renderer.d.ts +0 -119
package/dist/engine-core.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,90 @@ function patch(n1, n2) {
|
|
|
3317
3172
|
}
|
|
3318
3173
|
switch (n2.type) {
|
|
3319
3174
|
case 0 /* Text */:
|
|
3320
|
-
|
|
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
|
-
|
|
3179
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3180
|
+
patchComment(n1, n2, renderer);
|
|
3324
3181
|
break;
|
|
3325
3182
|
case 2 /* Element */:
|
|
3326
|
-
patchElement(n1, n2);
|
|
3183
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3327
3184
|
break;
|
|
3328
3185
|
case 3 /* CustomElement */:
|
|
3329
|
-
patchCustomElement(n1, n2);
|
|
3186
|
+
patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3330
3187
|
break;
|
|
3331
3188
|
}
|
|
3332
3189
|
}
|
|
3333
|
-
function mount(node, parent, anchor) {
|
|
3190
|
+
function mount(node, parent, renderer, anchor) {
|
|
3191
|
+
var _a, _b;
|
|
3334
3192
|
switch (node.type) {
|
|
3335
3193
|
case 0 /* Text */:
|
|
3336
|
-
|
|
3194
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3195
|
+
mountText(node, parent, anchor, renderer);
|
|
3337
3196
|
break;
|
|
3338
3197
|
case 1 /* Comment */:
|
|
3339
|
-
|
|
3198
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3199
|
+
mountComment(node, parent, anchor, renderer);
|
|
3340
3200
|
break;
|
|
3341
3201
|
case 2 /* Element */:
|
|
3342
|
-
|
|
3202
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3203
|
+
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3343
3204
|
break;
|
|
3344
3205
|
case 3 /* CustomElement */:
|
|
3345
|
-
|
|
3206
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3207
|
+
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3346
3208
|
break;
|
|
3347
3209
|
}
|
|
3348
3210
|
}
|
|
3349
|
-
function patchText(n1, n2) {
|
|
3211
|
+
function patchText(n1, n2, renderer) {
|
|
3350
3212
|
n2.elm = n1.elm;
|
|
3351
3213
|
if (n2.text !== n1.text) {
|
|
3352
|
-
updateTextContent(n2);
|
|
3214
|
+
updateTextContent(n2, renderer);
|
|
3353
3215
|
}
|
|
3354
3216
|
}
|
|
3355
|
-
function mountText(
|
|
3356
|
-
const { owner } =
|
|
3357
|
-
const
|
|
3358
|
-
|
|
3359
|
-
|
|
3217
|
+
function mountText(vnode, parent, anchor, renderer) {
|
|
3218
|
+
const { owner } = vnode;
|
|
3219
|
+
const { createText } = renderer;
|
|
3220
|
+
const textNode = (vnode.elm = createText(vnode.text));
|
|
3221
|
+
linkNodeToShadow(textNode, owner, renderer);
|
|
3222
|
+
insertNode(textNode, parent, anchor, renderer);
|
|
3360
3223
|
}
|
|
3361
|
-
function patchComment(n1, n2) {
|
|
3224
|
+
function patchComment(n1, n2, renderer) {
|
|
3362
3225
|
n2.elm = n1.elm;
|
|
3363
3226
|
// FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3364
3227
|
// it is the case today.
|
|
3365
3228
|
if (n2.text !== n1.text) {
|
|
3366
|
-
updateTextContent(n2);
|
|
3229
|
+
updateTextContent(n2, renderer);
|
|
3367
3230
|
}
|
|
3368
3231
|
}
|
|
3369
|
-
function mountComment(
|
|
3370
|
-
const { owner } =
|
|
3371
|
-
const
|
|
3372
|
-
|
|
3373
|
-
|
|
3232
|
+
function mountComment(vnode, parent, anchor, renderer) {
|
|
3233
|
+
const { owner } = vnode;
|
|
3234
|
+
const { createComment } = renderer;
|
|
3235
|
+
const commentNode = (vnode.elm = createComment(vnode.text));
|
|
3236
|
+
linkNodeToShadow(commentNode, owner, renderer);
|
|
3237
|
+
insertNode(commentNode, parent, anchor, renderer);
|
|
3374
3238
|
}
|
|
3375
|
-
function mountElement(vnode, parent, anchor) {
|
|
3239
|
+
function mountElement(vnode, parent, anchor, renderer) {
|
|
3376
3240
|
const { sel, owner, data: { svg }, } = vnode;
|
|
3241
|
+
const { createElement } = renderer;
|
|
3377
3242
|
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
3378
3243
|
const elm = createElement(sel, namespace);
|
|
3379
|
-
linkNodeToShadow(elm, owner);
|
|
3380
|
-
fallbackElmHook(elm, vnode);
|
|
3244
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3245
|
+
fallbackElmHook(elm, vnode, renderer);
|
|
3381
3246
|
vnode.elm = elm;
|
|
3382
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
3383
|
-
insertNode(elm, parent, anchor);
|
|
3384
|
-
mountVNodes(vnode.children, elm, null);
|
|
3247
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3248
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3249
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3385
3250
|
}
|
|
3386
|
-
function patchElement(n1, n2) {
|
|
3251
|
+
function patchElement(n1, n2, renderer) {
|
|
3387
3252
|
const elm = (n2.elm = n1.elm);
|
|
3388
|
-
patchElementPropsAndAttrs$1(n1, n2);
|
|
3389
|
-
patchChildren(n1.children, n2.children, elm);
|
|
3253
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3254
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3390
3255
|
}
|
|
3391
|
-
function mountCustomElement(vnode, parent, anchor) {
|
|
3256
|
+
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3392
3257
|
const { sel, owner } = vnode;
|
|
3393
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
3258
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
3394
3259
|
/**
|
|
3395
3260
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3396
3261
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -3400,9 +3265,9 @@ function mountCustomElement(vnode, parent, anchor) {
|
|
|
3400
3265
|
let vm;
|
|
3401
3266
|
const elm = new UpgradableConstructor((elm) => {
|
|
3402
3267
|
// the custom element from the registry is expecting an upgrade callback
|
|
3403
|
-
vm = createViewModelHook(elm, vnode);
|
|
3268
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
3404
3269
|
});
|
|
3405
|
-
linkNodeToShadow(elm, owner);
|
|
3270
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3406
3271
|
vnode.elm = elm;
|
|
3407
3272
|
vnode.vm = vm;
|
|
3408
3273
|
if (vm) {
|
|
@@ -3411,23 +3276,23 @@ function mountCustomElement(vnode, parent, anchor) {
|
|
|
3411
3276
|
else if (vnode.ctor !== UpgradableConstructor) {
|
|
3412
3277
|
throw new TypeError(`Incorrect Component Constructor`);
|
|
3413
3278
|
}
|
|
3414
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
3415
|
-
insertNode(elm, parent, anchor);
|
|
3279
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3280
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3416
3281
|
if (vm) {
|
|
3417
3282
|
if (process.env.NODE_ENV !== 'production') {
|
|
3418
3283
|
assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
3419
3284
|
}
|
|
3420
3285
|
runConnectedCallback(vm);
|
|
3421
3286
|
}
|
|
3422
|
-
mountVNodes(vnode.children, elm, null);
|
|
3287
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3423
3288
|
if (vm) {
|
|
3424
3289
|
appendVM(vm);
|
|
3425
3290
|
}
|
|
3426
3291
|
}
|
|
3427
|
-
function patchCustomElement(n1, n2) {
|
|
3292
|
+
function patchCustomElement(n1, n2, renderer) {
|
|
3428
3293
|
const elm = (n2.elm = n1.elm);
|
|
3429
3294
|
const vm = (n2.vm = n1.vm);
|
|
3430
|
-
patchElementPropsAndAttrs$1(n1, n2);
|
|
3295
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3431
3296
|
if (!isUndefined$1(vm)) {
|
|
3432
3297
|
// in fallback mode, the allocation will always set children to
|
|
3433
3298
|
// empty and delegate the real allocation to the slot elements
|
|
@@ -3435,34 +3300,36 @@ function patchCustomElement(n1, n2) {
|
|
|
3435
3300
|
}
|
|
3436
3301
|
// in fallback mode, the children will be always empty, so, nothing
|
|
3437
3302
|
// will happen, but in native, it does allocate the light dom
|
|
3438
|
-
patchChildren(n1.children, n2.children, elm);
|
|
3303
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3439
3304
|
if (!isUndefined$1(vm)) {
|
|
3440
3305
|
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
3441
3306
|
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
3442
3307
|
rerenderVM(vm);
|
|
3443
3308
|
}
|
|
3444
3309
|
}
|
|
3445
|
-
function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
|
|
3310
|
+
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
3446
3311
|
for (; start < end; ++start) {
|
|
3447
3312
|
const vnode = vnodes[start];
|
|
3448
3313
|
if (isVNode(vnode)) {
|
|
3449
|
-
mount(vnode, parent, anchor);
|
|
3314
|
+
mount(vnode, parent, renderer, anchor);
|
|
3450
3315
|
}
|
|
3451
3316
|
}
|
|
3452
3317
|
}
|
|
3453
|
-
function unmount(vnode, parent, doRemove = false) {
|
|
3318
|
+
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
3454
3319
|
const { type, elm, sel } = vnode;
|
|
3455
3320
|
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
3456
3321
|
// subtree root, is the only element worth unmounting from the subtree.
|
|
3457
3322
|
if (doRemove) {
|
|
3458
|
-
|
|
3323
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
3324
|
+
// but the removal used here is from the owner instead.
|
|
3325
|
+
removeNode(elm, parent, renderer);
|
|
3459
3326
|
}
|
|
3460
3327
|
switch (type) {
|
|
3461
3328
|
case 2 /* Element */: {
|
|
3462
3329
|
// Slot content is removed to trigger slotchange event when removing slot.
|
|
3463
3330
|
// Only required for synthetic shadow.
|
|
3464
|
-
const
|
|
3465
|
-
unmountVNodes(vnode.children, elm,
|
|
3331
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
|
|
3332
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
3466
3333
|
break;
|
|
3467
3334
|
}
|
|
3468
3335
|
case 3 /* CustomElement */: {
|
|
@@ -3475,11 +3342,11 @@ function unmount(vnode, parent, doRemove = false) {
|
|
|
3475
3342
|
}
|
|
3476
3343
|
}
|
|
3477
3344
|
}
|
|
3478
|
-
function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
|
|
3345
|
+
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
3479
3346
|
for (; start < end; ++start) {
|
|
3480
3347
|
const ch = vnodes[start];
|
|
3481
3348
|
if (isVNode(ch)) {
|
|
3482
|
-
unmount(ch, parent, doRemove);
|
|
3349
|
+
unmount(ch, parent, renderer, doRemove);
|
|
3483
3350
|
}
|
|
3484
3351
|
}
|
|
3485
3352
|
}
|
|
@@ -3493,15 +3360,19 @@ function setElementShadowToken(elm, token) {
|
|
|
3493
3360
|
elm.$shadowToken$ = token;
|
|
3494
3361
|
}
|
|
3495
3362
|
// Set the scope token class for *.scoped.css styles
|
|
3496
|
-
function setScopeTokenClassIfNecessary(elm, owner) {
|
|
3363
|
+
function setScopeTokenClassIfNecessary(elm, owner, renderer) {
|
|
3497
3364
|
const { cmpTemplate, context } = owner;
|
|
3365
|
+
const { getClassList } = renderer;
|
|
3498
3366
|
const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
|
|
3499
3367
|
if (!isUndefined$1(token) && context.hasScopedStyles) {
|
|
3368
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3369
|
+
// probably we should have a renderer api for just the add operation
|
|
3500
3370
|
getClassList(elm).add(token);
|
|
3501
3371
|
}
|
|
3502
3372
|
}
|
|
3503
|
-
function linkNodeToShadow(elm, owner) {
|
|
3373
|
+
function linkNodeToShadow(elm, owner, renderer) {
|
|
3504
3374
|
const { renderRoot, renderMode, shadowMode } = owner;
|
|
3375
|
+
const { isSyntheticShadowDefined } = renderer;
|
|
3505
3376
|
// TODO [#1164]: this should eventually be done by the polyfill directly
|
|
3506
3377
|
if (isSyntheticShadowDefined) {
|
|
3507
3378
|
if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
|
|
@@ -3509,8 +3380,9 @@ function linkNodeToShadow(elm, owner) {
|
|
|
3509
3380
|
}
|
|
3510
3381
|
}
|
|
3511
3382
|
}
|
|
3512
|
-
function updateTextContent(vnode) {
|
|
3383
|
+
function updateTextContent(vnode, renderer) {
|
|
3513
3384
|
const { elm, text } = vnode;
|
|
3385
|
+
const { setText } = renderer;
|
|
3514
3386
|
if (process.env.NODE_ENV !== 'production') {
|
|
3515
3387
|
unlockDomMutation();
|
|
3516
3388
|
}
|
|
@@ -3519,40 +3391,40 @@ function updateTextContent(vnode) {
|
|
|
3519
3391
|
lockDomMutation();
|
|
3520
3392
|
}
|
|
3521
3393
|
}
|
|
3522
|
-
function insertNode(node, parent, anchor) {
|
|
3394
|
+
function insertNode(node, parent, anchor, renderer) {
|
|
3523
3395
|
if (process.env.NODE_ENV !== 'production') {
|
|
3524
3396
|
unlockDomMutation();
|
|
3525
3397
|
}
|
|
3526
|
-
insert(node, parent, anchor);
|
|
3398
|
+
renderer.insert(node, parent, anchor);
|
|
3527
3399
|
if (process.env.NODE_ENV !== 'production') {
|
|
3528
3400
|
lockDomMutation();
|
|
3529
3401
|
}
|
|
3530
3402
|
}
|
|
3531
|
-
function removeNode(node, parent) {
|
|
3403
|
+
function removeNode(node, parent, renderer) {
|
|
3532
3404
|
if (process.env.NODE_ENV !== 'production') {
|
|
3533
3405
|
unlockDomMutation();
|
|
3534
3406
|
}
|
|
3535
|
-
remove(node, parent);
|
|
3407
|
+
renderer.remove(node, parent);
|
|
3536
3408
|
if (process.env.NODE_ENV !== 'production') {
|
|
3537
3409
|
lockDomMutation();
|
|
3538
3410
|
}
|
|
3539
3411
|
}
|
|
3540
|
-
function patchElementPropsAndAttrs$1(oldVnode, vnode) {
|
|
3412
|
+
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
3541
3413
|
if (isNull(oldVnode)) {
|
|
3542
|
-
applyEventListeners(vnode);
|
|
3543
|
-
applyStaticClassAttribute(vnode);
|
|
3544
|
-
applyStaticStyleAttribute(vnode);
|
|
3414
|
+
applyEventListeners(vnode, renderer);
|
|
3415
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
3416
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
3545
3417
|
}
|
|
3546
3418
|
// Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
3547
3419
|
// value is set before type=radio.
|
|
3548
|
-
patchClassAttribute(oldVnode, vnode);
|
|
3549
|
-
patchStyleAttribute(oldVnode, vnode);
|
|
3550
|
-
patchAttributes(oldVnode, vnode);
|
|
3551
|
-
patchProps(oldVnode, vnode);
|
|
3420
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
3421
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
3422
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
3423
|
+
patchProps(oldVnode, vnode, renderer);
|
|
3552
3424
|
}
|
|
3553
|
-
function fallbackElmHook(elm, vnode) {
|
|
3425
|
+
function fallbackElmHook(elm, vnode, renderer) {
|
|
3554
3426
|
const { owner } = vnode;
|
|
3555
|
-
setScopeTokenClassIfNecessary(elm, owner);
|
|
3427
|
+
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
3556
3428
|
if (owner.shadowMode === 1 /* Synthetic */) {
|
|
3557
3429
|
const { data: { context }, } = vnode;
|
|
3558
3430
|
const { stylesheetToken } = owner.context;
|
|
@@ -3600,7 +3472,7 @@ function allocateChildren(vnode, vm) {
|
|
|
3600
3472
|
vnode.children = EmptyArray;
|
|
3601
3473
|
}
|
|
3602
3474
|
}
|
|
3603
|
-
function createViewModelHook(elm, vnode) {
|
|
3475
|
+
function createViewModelHook(elm, vnode, renderer) {
|
|
3604
3476
|
let vm = getAssociatedVMIfPresent(elm);
|
|
3605
3477
|
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
3606
3478
|
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
@@ -3609,7 +3481,7 @@ function createViewModelHook(elm, vnode) {
|
|
|
3609
3481
|
return vm;
|
|
3610
3482
|
}
|
|
3611
3483
|
const { sel, mode, ctor, owner } = vnode;
|
|
3612
|
-
setScopeTokenClassIfNecessary(elm, owner);
|
|
3484
|
+
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
3613
3485
|
if (owner.shadowMode === 1 /* Synthetic */) {
|
|
3614
3486
|
const { stylesheetToken } = owner.context;
|
|
3615
3487
|
// when running in synthetic shadow mode, we need to set the shadowToken value
|
|
@@ -3618,7 +3490,7 @@ function createViewModelHook(elm, vnode) {
|
|
|
3618
3490
|
setElementShadowToken(elm, stylesheetToken);
|
|
3619
3491
|
}
|
|
3620
3492
|
}
|
|
3621
|
-
vm = createVM(elm, ctor, {
|
|
3493
|
+
vm = createVM(elm, ctor, renderer, {
|
|
3622
3494
|
mode,
|
|
3623
3495
|
owner,
|
|
3624
3496
|
tagName: sel,
|
|
@@ -3693,7 +3565,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
|
3693
3565
|
}
|
|
3694
3566
|
return map;
|
|
3695
3567
|
}
|
|
3696
|
-
function updateDynamicChildren(oldCh, newCh, parent) {
|
|
3568
|
+
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
3697
3569
|
let oldStartIdx = 0;
|
|
3698
3570
|
let newStartIdx = 0;
|
|
3699
3571
|
let oldEndIdx = oldCh.length - 1;
|
|
@@ -3722,26 +3594,26 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3722
3594
|
newEndVnode = newCh[--newEndIdx];
|
|
3723
3595
|
}
|
|
3724
3596
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
3725
|
-
patch(oldStartVnode, newStartVnode);
|
|
3597
|
+
patch(oldStartVnode, newStartVnode, renderer);
|
|
3726
3598
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3727
3599
|
newStartVnode = newCh[++newStartIdx];
|
|
3728
3600
|
}
|
|
3729
3601
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
3730
|
-
patch(oldEndVnode, newEndVnode);
|
|
3602
|
+
patch(oldEndVnode, newEndVnode, renderer);
|
|
3731
3603
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3732
3604
|
newEndVnode = newCh[--newEndIdx];
|
|
3733
3605
|
}
|
|
3734
3606
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
3735
3607
|
// Vnode moved right
|
|
3736
|
-
patch(oldStartVnode, newEndVnode);
|
|
3737
|
-
insertNode(oldStartVnode.elm, parent, nextSibling(oldEndVnode.elm));
|
|
3608
|
+
patch(oldStartVnode, newEndVnode, renderer);
|
|
3609
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
3738
3610
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3739
3611
|
newEndVnode = newCh[--newEndIdx];
|
|
3740
3612
|
}
|
|
3741
3613
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
3742
3614
|
// Vnode moved left
|
|
3743
|
-
patch(oldEndVnode, newStartVnode);
|
|
3744
|
-
insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
|
|
3615
|
+
patch(oldEndVnode, newStartVnode, renderer);
|
|
3616
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
3745
3617
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3746
3618
|
newStartVnode = newCh[++newStartIdx];
|
|
3747
3619
|
}
|
|
@@ -3752,7 +3624,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3752
3624
|
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
3753
3625
|
if (isUndefined$1(idxInOld)) {
|
|
3754
3626
|
// New element
|
|
3755
|
-
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
3627
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3756
3628
|
newStartVnode = newCh[++newStartIdx];
|
|
3757
3629
|
}
|
|
3758
3630
|
else {
|
|
@@ -3760,10 +3632,10 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3760
3632
|
if (isVNode(elmToMove)) {
|
|
3761
3633
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
3762
3634
|
// New element
|
|
3763
|
-
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
3635
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3764
3636
|
}
|
|
3765
3637
|
else {
|
|
3766
|
-
patch(elmToMove, newStartVnode);
|
|
3638
|
+
patch(elmToMove, newStartVnode, renderer);
|
|
3767
3639
|
// Delete the old child, but copy the array since it is read-only.
|
|
3768
3640
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
3769
3641
|
// so we only care about the `oldCh` object inside this function.
|
|
@@ -3775,7 +3647,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3775
3647
|
}
|
|
3776
3648
|
// We've already cloned at least once, so it's no longer read-only
|
|
3777
3649
|
oldCh[idxInOld] = undefined;
|
|
3778
|
-
insertNode(elmToMove.elm, parent, oldStartVnode.elm);
|
|
3650
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
3779
3651
|
}
|
|
3780
3652
|
}
|
|
3781
3653
|
newStartVnode = newCh[++newStartIdx];
|
|
@@ -3792,25 +3664,25 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3792
3664
|
n = newCh[++i];
|
|
3793
3665
|
} while (!isVNode(n) && i < newChEnd);
|
|
3794
3666
|
before = isVNode(n) ? n.elm : null;
|
|
3795
|
-
mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
|
|
3667
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
3796
3668
|
}
|
|
3797
3669
|
else {
|
|
3798
|
-
unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
|
|
3670
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
3799
3671
|
}
|
|
3800
3672
|
}
|
|
3801
3673
|
}
|
|
3802
|
-
function updateStaticChildren(c1, c2, parent) {
|
|
3674
|
+
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
3803
3675
|
const c1Length = c1.length;
|
|
3804
3676
|
const c2Length = c2.length;
|
|
3805
3677
|
if (c1Length === 0) {
|
|
3806
3678
|
// the old list is empty, we can directly insert anything new
|
|
3807
|
-
mountVNodes(c2, parent, null);
|
|
3679
|
+
mountVNodes(c2, parent, renderer, null);
|
|
3808
3680
|
return;
|
|
3809
3681
|
}
|
|
3810
3682
|
if (c2Length === 0) {
|
|
3811
3683
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
3812
3684
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
3813
|
-
unmountVNodes(c1, parent, true);
|
|
3685
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
3814
3686
|
return;
|
|
3815
3687
|
}
|
|
3816
3688
|
// if the old list is not empty, the new list MUST have the same
|
|
@@ -3823,16 +3695,16 @@ function updateStaticChildren(c1, c2, parent) {
|
|
|
3823
3695
|
if (isVNode(n1)) {
|
|
3824
3696
|
if (isVNode(n2)) {
|
|
3825
3697
|
// both vnodes are equivalent, and we just need to patch them
|
|
3826
|
-
patch(n1, n2);
|
|
3698
|
+
patch(n1, n2, renderer);
|
|
3827
3699
|
anchor = n2.elm;
|
|
3828
3700
|
}
|
|
3829
3701
|
else {
|
|
3830
3702
|
// removing the old vnode since the new one is null
|
|
3831
|
-
unmount(n1, parent, true);
|
|
3703
|
+
unmount(n1, parent, renderer, true);
|
|
3832
3704
|
}
|
|
3833
3705
|
}
|
|
3834
3706
|
else if (isVNode(n2)) {
|
|
3835
|
-
mount(n2, parent, anchor);
|
|
3707
|
+
mount(n2, parent, renderer, anchor);
|
|
3836
3708
|
anchor = n2.elm;
|
|
3837
3709
|
}
|
|
3838
3710
|
}
|
|
@@ -4261,7 +4133,7 @@ function createInlineStyleVNode(content) {
|
|
|
4261
4133
|
}, [api.t(content)]);
|
|
4262
4134
|
}
|
|
4263
4135
|
function updateStylesheetToken(vm, template) {
|
|
4264
|
-
const { elm, context, renderMode, shadowMode } = vm;
|
|
4136
|
+
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
4265
4137
|
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
4266
4138
|
const isSyntheticShadow = renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */;
|
|
4267
4139
|
const { hasScopedStyles } = context;
|
|
@@ -4378,7 +4250,7 @@ function getNearestNativeShadowComponent(vm) {
|
|
|
4378
4250
|
return owner;
|
|
4379
4251
|
}
|
|
4380
4252
|
function createStylesheet(vm, stylesheets) {
|
|
4381
|
-
const { renderMode, shadowMode } = vm;
|
|
4253
|
+
const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
|
|
4382
4254
|
if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
|
|
4383
4255
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
4384
4256
|
insertStylesheet(stylesheets[i]);
|
|
@@ -4953,7 +4825,7 @@ function getNearestShadowAncestor(vm) {
|
|
|
4953
4825
|
return ancestor;
|
|
4954
4826
|
}
|
|
4955
4827
|
|
|
4956
|
-
function createVM(elm, ctor, options) {
|
|
4828
|
+
function createVM(elm, ctor, renderer, options) {
|
|
4957
4829
|
const {
|
|
4958
4830
|
mode,
|
|
4959
4831
|
owner,
|
|
@@ -5002,9 +4874,10 @@ function createVM(elm, ctor, options) {
|
|
|
5002
4874
|
renderRoot: null,
|
|
5003
4875
|
callHook,
|
|
5004
4876
|
setHook,
|
|
5005
|
-
getHook
|
|
4877
|
+
getHook,
|
|
4878
|
+
renderer
|
|
5006
4879
|
};
|
|
5007
|
-
vm.shadowMode = computeShadowMode(vm);
|
|
4880
|
+
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5008
4881
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
5009
4882
|
|
|
5010
4883
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5029,10 +4902,14 @@ function createVM(elm, ctor, options) {
|
|
|
5029
4902
|
return vm;
|
|
5030
4903
|
}
|
|
5031
4904
|
|
|
5032
|
-
function computeShadowMode(vm) {
|
|
4905
|
+
function computeShadowMode(vm, renderer) {
|
|
5033
4906
|
const {
|
|
5034
4907
|
def
|
|
5035
4908
|
} = vm;
|
|
4909
|
+
const {
|
|
4910
|
+
isSyntheticShadowDefined,
|
|
4911
|
+
isNativeShadowDefined
|
|
4912
|
+
} = renderer;
|
|
5036
4913
|
let shadowMode;
|
|
5037
4914
|
|
|
5038
4915
|
if (isSyntheticShadowDefined) {
|
|
@@ -5134,7 +5011,8 @@ function rehydrate(vm) {
|
|
|
5134
5011
|
function patchShadowRoot(vm, newCh) {
|
|
5135
5012
|
const {
|
|
5136
5013
|
renderRoot,
|
|
5137
|
-
children: oldCh
|
|
5014
|
+
children: oldCh,
|
|
5015
|
+
renderer
|
|
5138
5016
|
} = vm; // caching the new children collection
|
|
5139
5017
|
|
|
5140
5018
|
vm.children = newCh;
|
|
@@ -5150,7 +5028,7 @@ function patchShadowRoot(vm, newCh) {
|
|
|
5150
5028
|
, vm);
|
|
5151
5029
|
}, () => {
|
|
5152
5030
|
// job
|
|
5153
|
-
patchChildren(oldCh, newCh, renderRoot);
|
|
5031
|
+
patchChildren(oldCh, newCh, renderRoot, renderer);
|
|
5154
5032
|
}, () => {
|
|
5155
5033
|
// post
|
|
5156
5034
|
logOperationEnd(2
|
|
@@ -5175,6 +5053,9 @@ function runRenderedCallback(vm) {
|
|
|
5175
5053
|
const {
|
|
5176
5054
|
def: {
|
|
5177
5055
|
renderedCallback
|
|
5056
|
+
},
|
|
5057
|
+
renderer: {
|
|
5058
|
+
ssr
|
|
5178
5059
|
}
|
|
5179
5060
|
} = vm;
|
|
5180
5061
|
|
|
@@ -5412,7 +5293,10 @@ function recursivelyDisconnectChildren(vnodes) {
|
|
|
5412
5293
|
function resetComponentRoot(vm) {
|
|
5413
5294
|
const {
|
|
5414
5295
|
children,
|
|
5415
|
-
renderRoot
|
|
5296
|
+
renderRoot,
|
|
5297
|
+
renderer: {
|
|
5298
|
+
remove
|
|
5299
|
+
}
|
|
5416
5300
|
} = vm;
|
|
5417
5301
|
|
|
5418
5302
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
@@ -5428,6 +5312,12 @@ function resetComponentRoot(vm) {
|
|
|
5428
5312
|
vm.velements = EmptyArray;
|
|
5429
5313
|
}
|
|
5430
5314
|
function scheduleRehydration(vm) {
|
|
5315
|
+
const {
|
|
5316
|
+
renderer: {
|
|
5317
|
+
ssr
|
|
5318
|
+
}
|
|
5319
|
+
} = vm;
|
|
5320
|
+
|
|
5431
5321
|
if (isTrue(ssr) || isTrue(vm.isScheduled)) {
|
|
5432
5322
|
return;
|
|
5433
5323
|
}
|
|
@@ -5604,6 +5494,9 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
|
5604
5494
|
context: {
|
|
5605
5495
|
wiredConnecting,
|
|
5606
5496
|
wiredDisconnecting
|
|
5497
|
+
},
|
|
5498
|
+
renderer: {
|
|
5499
|
+
dispatchEvent
|
|
5607
5500
|
}
|
|
5608
5501
|
} = vm; // waiting for the component to be connected to formally request the context via the token
|
|
5609
5502
|
|
|
@@ -5875,70 +5768,79 @@ function hydrateRoot(vm) {
|
|
|
5875
5768
|
function hydrateVM(vm) {
|
|
5876
5769
|
const children = renderComponent(vm);
|
|
5877
5770
|
vm.children = children;
|
|
5878
|
-
const parentNode = vm
|
|
5771
|
+
const { renderRoot: parentNode, renderer: { getFirstChild }, } = vm;
|
|
5879
5772
|
hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
|
|
5880
5773
|
runRenderedCallback(vm);
|
|
5881
5774
|
}
|
|
5882
|
-
function hydrateNode(node, vnode) {
|
|
5775
|
+
function hydrateNode(node, vnode, renderer) {
|
|
5776
|
+
var _a, _b;
|
|
5883
5777
|
let hydratedNode;
|
|
5884
5778
|
switch (vnode.type) {
|
|
5885
5779
|
case 0 /* Text */:
|
|
5886
|
-
|
|
5780
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
5781
|
+
hydratedNode = hydrateText(node, vnode, renderer);
|
|
5887
5782
|
break;
|
|
5888
5783
|
case 1 /* Comment */:
|
|
5889
|
-
|
|
5784
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
5785
|
+
hydratedNode = hydrateComment(node, vnode, renderer);
|
|
5890
5786
|
break;
|
|
5891
5787
|
case 2 /* Element */:
|
|
5892
|
-
hydratedNode = hydrateElement(node, vnode);
|
|
5788
|
+
hydratedNode = hydrateElement(node, vnode, (_a = vnode.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
5893
5789
|
break;
|
|
5894
5790
|
case 3 /* CustomElement */:
|
|
5895
|
-
hydratedNode = hydrateCustomElement(node, vnode);
|
|
5791
|
+
hydratedNode = hydrateCustomElement(node, vnode, (_b = vnode.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
5896
5792
|
break;
|
|
5897
5793
|
}
|
|
5898
|
-
return nextSibling(hydratedNode);
|
|
5794
|
+
return renderer.nextSibling(hydratedNode);
|
|
5899
5795
|
}
|
|
5900
|
-
function hydrateText(node, vnode) {
|
|
5796
|
+
function hydrateText(node, vnode, renderer) {
|
|
5901
5797
|
var _a;
|
|
5902
|
-
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT
|
|
5903
|
-
return handleMismatch(node, vnode);
|
|
5798
|
+
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */, renderer)) {
|
|
5799
|
+
return handleMismatch(node, vnode, renderer);
|
|
5904
5800
|
}
|
|
5905
5801
|
if (process.env.NODE_ENV !== 'production') {
|
|
5802
|
+
const { getProperty } = renderer;
|
|
5906
5803
|
const nodeValue = getProperty(node, 'nodeValue');
|
|
5907
5804
|
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
5908
5805
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
5909
5806
|
}
|
|
5910
5807
|
}
|
|
5808
|
+
const { setText } = renderer;
|
|
5911
5809
|
setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5912
5810
|
vnode.elm = node;
|
|
5913
5811
|
return node;
|
|
5914
5812
|
}
|
|
5915
|
-
function hydrateComment(node, vnode) {
|
|
5813
|
+
function hydrateComment(node, vnode, renderer) {
|
|
5916
5814
|
var _a;
|
|
5917
|
-
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT
|
|
5918
|
-
return handleMismatch(node, vnode);
|
|
5815
|
+
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */, renderer)) {
|
|
5816
|
+
return handleMismatch(node, vnode, renderer);
|
|
5919
5817
|
}
|
|
5920
5818
|
if (process.env.NODE_ENV !== 'production') {
|
|
5819
|
+
const { getProperty } = renderer;
|
|
5921
5820
|
const nodeValue = getProperty(node, 'nodeValue');
|
|
5922
5821
|
if (nodeValue !== vnode.text) {
|
|
5923
5822
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
5924
5823
|
}
|
|
5925
5824
|
}
|
|
5825
|
+
const { setProperty } = renderer;
|
|
5926
5826
|
setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5927
5827
|
vnode.elm = node;
|
|
5928
5828
|
return node;
|
|
5929
5829
|
}
|
|
5930
|
-
function hydrateElement(elm, vnode) {
|
|
5931
|
-
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT
|
|
5932
|
-
!isMatchingElement(vnode, elm)) {
|
|
5933
|
-
return handleMismatch(elm, vnode);
|
|
5830
|
+
function hydrateElement(elm, vnode, renderer) {
|
|
5831
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
|
|
5832
|
+
!isMatchingElement(vnode, elm, renderer)) {
|
|
5833
|
+
return handleMismatch(elm, vnode, renderer);
|
|
5934
5834
|
}
|
|
5935
5835
|
vnode.elm = elm;
|
|
5836
|
+
const { owner } = vnode;
|
|
5936
5837
|
const { context } = vnode.data;
|
|
5937
5838
|
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual" /* Manual */);
|
|
5938
5839
|
if (isDomManual) {
|
|
5939
5840
|
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
5940
5841
|
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
5941
|
-
const { props } = vnode
|
|
5842
|
+
const { data: { props }, } = vnode;
|
|
5843
|
+
const { getProperty } = renderer;
|
|
5942
5844
|
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
5943
5845
|
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
5944
5846
|
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
@@ -5946,24 +5848,25 @@ function hydrateElement(elm, vnode) {
|
|
|
5946
5848
|
}
|
|
5947
5849
|
else {
|
|
5948
5850
|
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`,
|
|
5851
|
+
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, owner);
|
|
5950
5852
|
}
|
|
5951
5853
|
}
|
|
5952
5854
|
}
|
|
5953
5855
|
}
|
|
5954
|
-
patchElementPropsAndAttrs(vnode);
|
|
5856
|
+
patchElementPropsAndAttrs(vnode, renderer);
|
|
5955
5857
|
if (!isDomManual) {
|
|
5956
|
-
|
|
5858
|
+
const { getFirstChild } = renderer;
|
|
5859
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, owner);
|
|
5957
5860
|
}
|
|
5958
5861
|
return elm;
|
|
5959
5862
|
}
|
|
5960
|
-
function hydrateCustomElement(elm, vnode) {
|
|
5961
|
-
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT
|
|
5962
|
-
!isMatchingElement(vnode, elm)) {
|
|
5963
|
-
return handleMismatch(elm, vnode);
|
|
5863
|
+
function hydrateCustomElement(elm, vnode, renderer) {
|
|
5864
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
|
|
5865
|
+
!isMatchingElement(vnode, elm, renderer)) {
|
|
5866
|
+
return handleMismatch(elm, vnode, renderer);
|
|
5964
5867
|
}
|
|
5965
5868
|
const { sel, mode, ctor, owner } = vnode;
|
|
5966
|
-
const vm = createVM(elm, ctor, {
|
|
5869
|
+
const vm = createVM(elm, ctor, renderer, {
|
|
5967
5870
|
mode,
|
|
5968
5871
|
owner,
|
|
5969
5872
|
tagName: sel,
|
|
@@ -5972,13 +5875,14 @@ function hydrateCustomElement(elm, vnode) {
|
|
|
5972
5875
|
vnode.elm = elm;
|
|
5973
5876
|
vnode.vm = vm;
|
|
5974
5877
|
allocateChildren(vnode, vm);
|
|
5975
|
-
patchElementPropsAndAttrs(vnode);
|
|
5878
|
+
patchElementPropsAndAttrs(vnode, renderer);
|
|
5976
5879
|
// Insert hook section:
|
|
5977
5880
|
if (process.env.NODE_ENV !== 'production') {
|
|
5978
5881
|
assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
5979
5882
|
}
|
|
5980
5883
|
runConnectedCallback(vm);
|
|
5981
5884
|
if (vm.renderMode !== 0 /* Light */) {
|
|
5885
|
+
const { getFirstChild } = renderer;
|
|
5982
5886
|
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
5983
5887
|
// Note: for Light DOM, this is handled while hydrating the VM
|
|
5984
5888
|
hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
|
|
@@ -5990,11 +5894,12 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
5990
5894
|
let hasWarned = false;
|
|
5991
5895
|
let nextNode = node;
|
|
5992
5896
|
let anchor = null;
|
|
5897
|
+
const { renderer } = owner;
|
|
5993
5898
|
for (let i = 0; i < children.length; i++) {
|
|
5994
5899
|
const childVnode = children[i];
|
|
5995
5900
|
if (!isNull(childVnode)) {
|
|
5996
5901
|
if (nextNode) {
|
|
5997
|
-
nextNode = hydrateNode(nextNode, childVnode);
|
|
5902
|
+
nextNode = hydrateNode(nextNode, childVnode, renderer);
|
|
5998
5903
|
anchor = childVnode.elm;
|
|
5999
5904
|
}
|
|
6000
5905
|
else {
|
|
@@ -6005,7 +5910,7 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
6005
5910
|
logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
|
|
6006
5911
|
}
|
|
6007
5912
|
}
|
|
6008
|
-
mount(childVnode, parentNode, anchor);
|
|
5913
|
+
mount(childVnode, parentNode, renderer, anchor);
|
|
6009
5914
|
anchor = childVnode.elm;
|
|
6010
5915
|
}
|
|
6011
5916
|
}
|
|
@@ -6017,30 +5922,32 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
6017
5922
|
logError(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
|
|
6018
5923
|
}
|
|
6019
5924
|
}
|
|
5925
|
+
// nextSibling is mostly harmless, and since we don't have
|
|
5926
|
+
// a good reference to what element to act upon, we instead
|
|
5927
|
+
// rely on the vm's associated renderer for navigating to the
|
|
5928
|
+
// next node in the list to be hydrated.
|
|
5929
|
+
const { nextSibling } = renderer;
|
|
6020
5930
|
do {
|
|
6021
5931
|
const current = nextNode;
|
|
6022
5932
|
nextNode = nextSibling(nextNode);
|
|
6023
|
-
removeNode(current, parentNode);
|
|
5933
|
+
removeNode(current, parentNode, renderer);
|
|
6024
5934
|
} while (nextNode);
|
|
6025
5935
|
}
|
|
6026
5936
|
}
|
|
6027
|
-
function handleMismatch(node, vnode,
|
|
5937
|
+
function handleMismatch(node, vnode, renderer) {
|
|
6028
5938
|
hasMismatch = true;
|
|
6029
|
-
|
|
6030
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6031
|
-
logError(msg, vnode.owner);
|
|
6032
|
-
}
|
|
6033
|
-
}
|
|
5939
|
+
const { getProperty } = renderer;
|
|
6034
5940
|
const parentNode = getProperty(node, 'parentNode');
|
|
6035
|
-
mount(vnode, parentNode, node);
|
|
6036
|
-
removeNode(node, parentNode);
|
|
5941
|
+
mount(vnode, parentNode, renderer, node);
|
|
5942
|
+
removeNode(node, parentNode, renderer);
|
|
6037
5943
|
return vnode.elm;
|
|
6038
5944
|
}
|
|
6039
|
-
function patchElementPropsAndAttrs(vnode) {
|
|
6040
|
-
applyEventListeners(vnode);
|
|
6041
|
-
patchProps(null, vnode);
|
|
5945
|
+
function patchElementPropsAndAttrs(vnode, renderer) {
|
|
5946
|
+
applyEventListeners(vnode, renderer);
|
|
5947
|
+
patchProps(null, vnode, renderer);
|
|
6042
5948
|
}
|
|
6043
|
-
function hasCorrectNodeType(vnode, node, nodeType) {
|
|
5949
|
+
function hasCorrectNodeType(vnode, node, nodeType, renderer) {
|
|
5950
|
+
const { getProperty } = renderer;
|
|
6044
5951
|
if (getProperty(node, 'nodeType') !== nodeType) {
|
|
6045
5952
|
if (process.env.NODE_ENV !== 'production') {
|
|
6046
5953
|
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
@@ -6049,36 +5956,41 @@ function hasCorrectNodeType(vnode, node, nodeType) {
|
|
|
6049
5956
|
}
|
|
6050
5957
|
return true;
|
|
6051
5958
|
}
|
|
6052
|
-
function isMatchingElement(vnode, elm) {
|
|
5959
|
+
function isMatchingElement(vnode, elm, renderer) {
|
|
5960
|
+
const { getProperty } = renderer;
|
|
6053
5961
|
if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
|
|
6054
5962
|
if (process.env.NODE_ENV !== 'production') {
|
|
6055
5963
|
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
6056
5964
|
}
|
|
6057
5965
|
return false;
|
|
6058
5966
|
}
|
|
6059
|
-
const hasIncompatibleAttrs = validateAttrs(vnode, elm);
|
|
6060
|
-
const hasIncompatibleClass = validateClassAttr(vnode, elm);
|
|
6061
|
-
const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
|
|
5967
|
+
const hasIncompatibleAttrs = validateAttrs(vnode, elm, renderer);
|
|
5968
|
+
const hasIncompatibleClass = validateClassAttr(vnode, elm, renderer);
|
|
5969
|
+
const hasIncompatibleStyle = validateStyleAttr(vnode, elm, renderer);
|
|
6062
5970
|
return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
6063
5971
|
}
|
|
6064
|
-
function validateAttrs(vnode, elm) {
|
|
5972
|
+
function validateAttrs(vnode, elm, renderer) {
|
|
6065
5973
|
const { data: { attrs = {} }, } = vnode;
|
|
6066
5974
|
let nodesAreCompatible = true;
|
|
6067
5975
|
// Validate attributes, though we could always recovery from those by running the update mods.
|
|
6068
5976
|
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
6069
5977
|
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
5978
|
+
const { owner } = vnode;
|
|
5979
|
+
const { getAttribute } = renderer;
|
|
6070
5980
|
const elmAttrValue = getAttribute(elm, attrName);
|
|
6071
5981
|
if (String(attrValue) !== elmAttrValue) {
|
|
6072
5982
|
if (process.env.NODE_ENV !== 'production') {
|
|
6073
|
-
|
|
5983
|
+
const { getProperty } = renderer;
|
|
5984
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, owner);
|
|
6074
5985
|
}
|
|
6075
5986
|
nodesAreCompatible = false;
|
|
6076
5987
|
}
|
|
6077
5988
|
}
|
|
6078
5989
|
return nodesAreCompatible;
|
|
6079
5990
|
}
|
|
6080
|
-
function validateClassAttr(vnode, elm) {
|
|
5991
|
+
function validateClassAttr(vnode, elm, renderer) {
|
|
6081
5992
|
const { data: { className, classMap }, } = vnode;
|
|
5993
|
+
const { getProperty, getClassList } = renderer;
|
|
6082
5994
|
let nodesAreCompatible = true;
|
|
6083
5995
|
let vnodeClassName;
|
|
6084
5996
|
if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
|
|
@@ -6109,8 +6021,9 @@ function validateClassAttr(vnode, elm) {
|
|
|
6109
6021
|
}
|
|
6110
6022
|
return nodesAreCompatible;
|
|
6111
6023
|
}
|
|
6112
|
-
function validateStyleAttr(vnode, elm) {
|
|
6024
|
+
function validateStyleAttr(vnode, elm, renderer) {
|
|
6113
6025
|
const { data: { style, styleDecls }, } = vnode;
|
|
6026
|
+
const { getAttribute } = renderer;
|
|
6114
6027
|
const elmStyle = getAttribute(elm, 'style') || '';
|
|
6115
6028
|
let vnodeStyle;
|
|
6116
6029
|
let nodesAreCompatible = true;
|
|
@@ -6143,6 +6056,7 @@ function validateStyleAttr(vnode, elm) {
|
|
|
6143
6056
|
}
|
|
6144
6057
|
if (!nodesAreCompatible) {
|
|
6145
6058
|
if (process.env.NODE_ENV !== 'production') {
|
|
6059
|
+
const { getProperty } = renderer;
|
|
6146
6060
|
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
6147
6061
|
}
|
|
6148
6062
|
}
|
|
@@ -6284,5 +6198,5 @@ function getComponentConstructor(elm) {
|
|
|
6284
6198
|
return ctor;
|
|
6285
6199
|
}
|
|
6286
6200
|
|
|
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,
|
|
6288
|
-
/* version: 2.14.
|
|
6201
|
+
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, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6202
|
+
/* version: 2.14.2 */
|