@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.cjs.js
CHANGED
|
@@ -112,164 +112,6 @@ function flattenStylesheets(stylesheets) {
|
|
|
112
112
|
return list;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
//
|
|
116
|
-
// Primitives
|
|
117
|
-
//
|
|
118
|
-
let ssr;
|
|
119
|
-
function setSsr(ssrImpl) {
|
|
120
|
-
ssr = ssrImpl;
|
|
121
|
-
}
|
|
122
|
-
let isNativeShadowDefined;
|
|
123
|
-
function setIsNativeShadowDefined(isNativeShadowDefinedImpl) {
|
|
124
|
-
isNativeShadowDefined = isNativeShadowDefinedImpl;
|
|
125
|
-
}
|
|
126
|
-
let isSyntheticShadowDefined;
|
|
127
|
-
function setIsSyntheticShadowDefined(isSyntheticShadowDefinedImpl) {
|
|
128
|
-
isSyntheticShadowDefined = isSyntheticShadowDefinedImpl;
|
|
129
|
-
}
|
|
130
|
-
let HTMLElementExported;
|
|
131
|
-
function setHTMLElement(HTMLElementImpl) {
|
|
132
|
-
HTMLElementExported = HTMLElementImpl;
|
|
133
|
-
}
|
|
134
|
-
function setIsHydrating(isHydratingImpl) {
|
|
135
|
-
}
|
|
136
|
-
let insert;
|
|
137
|
-
function setInsert(insertImpl) {
|
|
138
|
-
insert = insertImpl;
|
|
139
|
-
}
|
|
140
|
-
let remove;
|
|
141
|
-
function setRemove(removeImpl) {
|
|
142
|
-
remove = removeImpl;
|
|
143
|
-
}
|
|
144
|
-
let createElement;
|
|
145
|
-
function setCreateElement(createElementImpl) {
|
|
146
|
-
createElement = createElementImpl;
|
|
147
|
-
}
|
|
148
|
-
let createText;
|
|
149
|
-
function setCreateText(createTextImpl) {
|
|
150
|
-
createText = createTextImpl;
|
|
151
|
-
}
|
|
152
|
-
let createComment;
|
|
153
|
-
function setCreateComment(createCommentImpl) {
|
|
154
|
-
createComment = createCommentImpl;
|
|
155
|
-
}
|
|
156
|
-
let nextSibling;
|
|
157
|
-
function setNextSibling(nextSiblingImpl) {
|
|
158
|
-
nextSibling = nextSiblingImpl;
|
|
159
|
-
}
|
|
160
|
-
let attachShadow;
|
|
161
|
-
function setAttachShadow(attachShadowImpl) {
|
|
162
|
-
attachShadow = attachShadowImpl;
|
|
163
|
-
}
|
|
164
|
-
let getProperty;
|
|
165
|
-
function setGetProperty(getPropertyImpl) {
|
|
166
|
-
getProperty = getPropertyImpl;
|
|
167
|
-
}
|
|
168
|
-
let setProperty;
|
|
169
|
-
function setSetProperty(setPropertyImpl) {
|
|
170
|
-
setProperty = setPropertyImpl;
|
|
171
|
-
}
|
|
172
|
-
let setText;
|
|
173
|
-
function setSetText(setTextImpl) {
|
|
174
|
-
setText = setTextImpl;
|
|
175
|
-
}
|
|
176
|
-
let getAttribute;
|
|
177
|
-
function setGetAttribute(getAttributeImpl) {
|
|
178
|
-
getAttribute = getAttributeImpl;
|
|
179
|
-
}
|
|
180
|
-
let setAttribute;
|
|
181
|
-
function setSetAttribute(setAttributeImpl) {
|
|
182
|
-
setAttribute = setAttributeImpl;
|
|
183
|
-
}
|
|
184
|
-
let removeAttribute;
|
|
185
|
-
function setRemoveAttribute(removeAttributeImpl) {
|
|
186
|
-
removeAttribute = removeAttributeImpl;
|
|
187
|
-
}
|
|
188
|
-
let addEventListener;
|
|
189
|
-
function setAddEventListener(addEventListenerImpl) {
|
|
190
|
-
addEventListener = addEventListenerImpl;
|
|
191
|
-
}
|
|
192
|
-
let removeEventListener;
|
|
193
|
-
function setRemoveEventListener(removeEventListenerImpl) {
|
|
194
|
-
removeEventListener = removeEventListenerImpl;
|
|
195
|
-
}
|
|
196
|
-
let dispatchEvent;
|
|
197
|
-
function setDispatchEvent(dispatchEventImpl) {
|
|
198
|
-
dispatchEvent = dispatchEventImpl;
|
|
199
|
-
}
|
|
200
|
-
let getClassList;
|
|
201
|
-
function setGetClassList(getClassListImpl) {
|
|
202
|
-
getClassList = getClassListImpl;
|
|
203
|
-
}
|
|
204
|
-
let setCSSStyleProperty;
|
|
205
|
-
function setSetCSSStyleProperty(setCSSStylePropertyImpl) {
|
|
206
|
-
setCSSStyleProperty = setCSSStylePropertyImpl;
|
|
207
|
-
}
|
|
208
|
-
let getBoundingClientRect;
|
|
209
|
-
function setGetBoundingClientRect(getBoundingClientRectImpl) {
|
|
210
|
-
getBoundingClientRect = getBoundingClientRectImpl;
|
|
211
|
-
}
|
|
212
|
-
let querySelector;
|
|
213
|
-
function setQuerySelector(querySelectorImpl) {
|
|
214
|
-
querySelector = querySelectorImpl;
|
|
215
|
-
}
|
|
216
|
-
let querySelectorAll;
|
|
217
|
-
function setQuerySelectorAll(querySelectorAllImpl) {
|
|
218
|
-
querySelectorAll = querySelectorAllImpl;
|
|
219
|
-
}
|
|
220
|
-
let getElementsByTagName;
|
|
221
|
-
function setGetElementsByTagName(getElementsByTagNameImpl) {
|
|
222
|
-
getElementsByTagName = getElementsByTagNameImpl;
|
|
223
|
-
}
|
|
224
|
-
let getElementsByClassName;
|
|
225
|
-
function setGetElementsByClassName(getElementsByClassNameImpl) {
|
|
226
|
-
getElementsByClassName = getElementsByClassNameImpl;
|
|
227
|
-
}
|
|
228
|
-
let getChildren;
|
|
229
|
-
function setGetChildren(getChildrenImpl) {
|
|
230
|
-
getChildren = getChildrenImpl;
|
|
231
|
-
}
|
|
232
|
-
let getChildNodes;
|
|
233
|
-
function setGetChildNodes(getChildNodesImpl) {
|
|
234
|
-
getChildNodes = getChildNodesImpl;
|
|
235
|
-
}
|
|
236
|
-
let getFirstChild;
|
|
237
|
-
function setGetFirstChild(getFirstChildImpl) {
|
|
238
|
-
getFirstChild = getFirstChildImpl;
|
|
239
|
-
}
|
|
240
|
-
let getFirstElementChild;
|
|
241
|
-
function setGetFirstElementChild(getFirstElementChildImpl) {
|
|
242
|
-
getFirstElementChild = getFirstElementChildImpl;
|
|
243
|
-
}
|
|
244
|
-
let getLastChild;
|
|
245
|
-
function setGetLastChild(getLastChildImpl) {
|
|
246
|
-
getLastChild = getLastChildImpl;
|
|
247
|
-
}
|
|
248
|
-
let getLastElementChild;
|
|
249
|
-
function setGetLastElementChild(getLastElementChildImpl) {
|
|
250
|
-
getLastElementChild = getLastElementChildImpl;
|
|
251
|
-
}
|
|
252
|
-
let isConnected;
|
|
253
|
-
function setIsConnected(isConnectedImpl) {
|
|
254
|
-
isConnected = isConnectedImpl;
|
|
255
|
-
}
|
|
256
|
-
let insertStylesheet;
|
|
257
|
-
function setInsertStylesheet(insertStylesheetImpl) {
|
|
258
|
-
insertStylesheet = insertStylesheetImpl;
|
|
259
|
-
}
|
|
260
|
-
let assertInstanceOfHTMLElement;
|
|
261
|
-
function setAssertInstanceOfHTMLElement(assertInstanceOfHTMLElementImpl) {
|
|
262
|
-
assertInstanceOfHTMLElement = assertInstanceOfHTMLElementImpl;
|
|
263
|
-
}
|
|
264
|
-
let defineCustomElement;
|
|
265
|
-
function setDefineCustomElement(defineCustomElementImpl) {
|
|
266
|
-
defineCustomElement = defineCustomElementImpl;
|
|
267
|
-
}
|
|
268
|
-
let getCustomElement;
|
|
269
|
-
function setGetCustomElement(getCustomElementImpl) {
|
|
270
|
-
getCustomElement = getCustomElementImpl;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
115
|
/*
|
|
274
116
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
275
117
|
* All rights reserved.
|
|
@@ -1574,6 +1416,7 @@ const LightningElement = function () {
|
|
|
1574
1416
|
const { def, elm } = vm;
|
|
1575
1417
|
const { bridge } = def;
|
|
1576
1418
|
if (process.env.NODE_ENV !== 'production') {
|
|
1419
|
+
const { assertInstanceOfHTMLElement } = vm.renderer;
|
|
1577
1420
|
assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
|
|
1578
1421
|
}
|
|
1579
1422
|
const component = this;
|
|
@@ -1608,7 +1451,7 @@ const LightningElement = function () {
|
|
|
1608
1451
|
return this;
|
|
1609
1452
|
};
|
|
1610
1453
|
function doAttachShadow(vm) {
|
|
1611
|
-
const { elm, mode, shadowMode, def: { ctor }, } = vm;
|
|
1454
|
+
const { elm, mode, shadowMode, def: { ctor }, renderer: { attachShadow }, } = vm;
|
|
1612
1455
|
const shadowRoot = attachShadow(elm, {
|
|
1613
1456
|
[shared.KEY__SYNTHETIC_MODE]: shadowMode === 1 /* Synthetic */,
|
|
1614
1457
|
delegatesFocus: Boolean(ctor.delegatesFocus),
|
|
@@ -1630,12 +1473,13 @@ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
|
1630
1473
|
LightningElement.prototype = {
|
|
1631
1474
|
constructor: LightningElement,
|
|
1632
1475
|
dispatchEvent(event) {
|
|
1633
|
-
const
|
|
1476
|
+
const vm = getAssociatedVM(this);
|
|
1477
|
+
const { elm, renderer: { dispatchEvent }, } = vm;
|
|
1634
1478
|
return dispatchEvent(elm, event);
|
|
1635
1479
|
},
|
|
1636
1480
|
addEventListener(type, listener, options) {
|
|
1637
1481
|
const vm = getAssociatedVM(this);
|
|
1638
|
-
const { elm } = vm;
|
|
1482
|
+
const { elm, renderer: { addEventListener }, } = vm;
|
|
1639
1483
|
if (process.env.NODE_ENV !== 'production') {
|
|
1640
1484
|
const vmBeingRendered = getVMBeingRendered();
|
|
1641
1485
|
shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
@@ -1647,41 +1491,48 @@ LightningElement.prototype = {
|
|
|
1647
1491
|
},
|
|
1648
1492
|
removeEventListener(type, listener, options) {
|
|
1649
1493
|
const vm = getAssociatedVM(this);
|
|
1650
|
-
const { elm } = vm;
|
|
1494
|
+
const { elm, renderer: { removeEventListener }, } = vm;
|
|
1651
1495
|
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
1652
1496
|
removeEventListener(elm, type, wrappedListener, options);
|
|
1653
1497
|
},
|
|
1654
1498
|
hasAttribute(name) {
|
|
1655
|
-
const
|
|
1499
|
+
const vm = getAssociatedVM(this);
|
|
1500
|
+
const { elm, renderer: { getAttribute }, } = vm;
|
|
1656
1501
|
return !shared.isNull(getAttribute(elm, name));
|
|
1657
1502
|
},
|
|
1658
1503
|
hasAttributeNS(namespace, name) {
|
|
1659
|
-
const
|
|
1504
|
+
const vm = getAssociatedVM(this);
|
|
1505
|
+
const { elm, renderer: { getAttribute }, } = vm;
|
|
1660
1506
|
return !shared.isNull(getAttribute(elm, name, namespace));
|
|
1661
1507
|
},
|
|
1662
1508
|
removeAttribute(name) {
|
|
1663
|
-
const
|
|
1509
|
+
const vm = getAssociatedVM(this);
|
|
1510
|
+
const { elm, renderer: { removeAttribute }, } = vm;
|
|
1664
1511
|
unlockAttribute(elm, name);
|
|
1665
1512
|
removeAttribute(elm, name);
|
|
1666
1513
|
lockAttribute();
|
|
1667
1514
|
},
|
|
1668
1515
|
removeAttributeNS(namespace, name) {
|
|
1669
|
-
const { elm } = getAssociatedVM(this);
|
|
1516
|
+
const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
|
|
1670
1517
|
unlockAttribute(elm, name);
|
|
1671
1518
|
removeAttribute(elm, name, namespace);
|
|
1672
1519
|
lockAttribute();
|
|
1673
1520
|
},
|
|
1674
1521
|
getAttribute(name) {
|
|
1675
|
-
const
|
|
1522
|
+
const vm = getAssociatedVM(this);
|
|
1523
|
+
const { elm } = vm;
|
|
1524
|
+
const { getAttribute } = vm.renderer;
|
|
1676
1525
|
return getAttribute(elm, name);
|
|
1677
1526
|
},
|
|
1678
1527
|
getAttributeNS(namespace, name) {
|
|
1679
|
-
const
|
|
1528
|
+
const vm = getAssociatedVM(this);
|
|
1529
|
+
const { elm } = vm;
|
|
1530
|
+
const { getAttribute } = vm.renderer;
|
|
1680
1531
|
return getAttribute(elm, name, namespace);
|
|
1681
1532
|
},
|
|
1682
1533
|
setAttribute(name, value) {
|
|
1683
1534
|
const vm = getAssociatedVM(this);
|
|
1684
|
-
const { elm } = vm;
|
|
1535
|
+
const { elm, renderer: { setAttribute }, } = vm;
|
|
1685
1536
|
if (process.env.NODE_ENV !== 'production') {
|
|
1686
1537
|
shared.assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1687
1538
|
}
|
|
@@ -1691,7 +1542,7 @@ LightningElement.prototype = {
|
|
|
1691
1542
|
},
|
|
1692
1543
|
setAttributeNS(namespace, name, value) {
|
|
1693
1544
|
const vm = getAssociatedVM(this);
|
|
1694
|
-
const { elm } = vm;
|
|
1545
|
+
const { elm, renderer: { setAttribute }, } = vm;
|
|
1695
1546
|
if (process.env.NODE_ENV !== 'production') {
|
|
1696
1547
|
shared.assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1697
1548
|
}
|
|
@@ -1701,19 +1552,20 @@ LightningElement.prototype = {
|
|
|
1701
1552
|
},
|
|
1702
1553
|
getBoundingClientRect() {
|
|
1703
1554
|
const vm = getAssociatedVM(this);
|
|
1704
|
-
const { elm } = vm;
|
|
1555
|
+
const { elm, renderer: { getBoundingClientRect }, } = vm;
|
|
1705
1556
|
if (process.env.NODE_ENV !== 'production') {
|
|
1706
1557
|
warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
|
|
1707
1558
|
}
|
|
1708
1559
|
return getBoundingClientRect(elm);
|
|
1709
1560
|
},
|
|
1710
1561
|
get isConnected() {
|
|
1711
|
-
const
|
|
1562
|
+
const vm = getAssociatedVM(this);
|
|
1563
|
+
const { elm, renderer: { isConnected }, } = vm;
|
|
1712
1564
|
return isConnected(elm);
|
|
1713
1565
|
},
|
|
1714
1566
|
get classList() {
|
|
1715
1567
|
const vm = getAssociatedVM(this);
|
|
1716
|
-
const { elm } = vm;
|
|
1568
|
+
const { elm, renderer: { getClassList }, } = vm;
|
|
1717
1569
|
if (process.env.NODE_ENV !== 'production') {
|
|
1718
1570
|
// TODO [#1290]: this still fails in dev but works in production, eventually, we should
|
|
1719
1571
|
// just throw in all modes
|
|
@@ -1735,6 +1587,54 @@ LightningElement.prototype = {
|
|
|
1735
1587
|
// Authors should rely on this.template instead.
|
|
1736
1588
|
return null;
|
|
1737
1589
|
},
|
|
1590
|
+
get children() {
|
|
1591
|
+
const vm = getAssociatedVM(this);
|
|
1592
|
+
const renderer = vm.renderer;
|
|
1593
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1594
|
+
warnIfInvokedDuringConstruction(vm, 'children');
|
|
1595
|
+
}
|
|
1596
|
+
return renderer.getChildren(vm.elm);
|
|
1597
|
+
},
|
|
1598
|
+
get childNodes() {
|
|
1599
|
+
const vm = getAssociatedVM(this);
|
|
1600
|
+
const renderer = vm.renderer;
|
|
1601
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1602
|
+
warnIfInvokedDuringConstruction(vm, 'childNodes');
|
|
1603
|
+
}
|
|
1604
|
+
return renderer.getChildNodes(vm.elm);
|
|
1605
|
+
},
|
|
1606
|
+
get firstChild() {
|
|
1607
|
+
const vm = getAssociatedVM(this);
|
|
1608
|
+
const renderer = vm.renderer;
|
|
1609
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1610
|
+
warnIfInvokedDuringConstruction(vm, 'firstChild');
|
|
1611
|
+
}
|
|
1612
|
+
return renderer.getFirstChild(vm.elm);
|
|
1613
|
+
},
|
|
1614
|
+
get firstElementChild() {
|
|
1615
|
+
const vm = getAssociatedVM(this);
|
|
1616
|
+
const renderer = vm.renderer;
|
|
1617
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1618
|
+
warnIfInvokedDuringConstruction(vm, 'firstElementChild');
|
|
1619
|
+
}
|
|
1620
|
+
return renderer.getFirstElementChild(vm.elm);
|
|
1621
|
+
},
|
|
1622
|
+
get lastChild() {
|
|
1623
|
+
const vm = getAssociatedVM(this);
|
|
1624
|
+
const renderer = vm.renderer;
|
|
1625
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1626
|
+
warnIfInvokedDuringConstruction(vm, 'lastChild');
|
|
1627
|
+
}
|
|
1628
|
+
return renderer.getLastChild(vm.elm);
|
|
1629
|
+
},
|
|
1630
|
+
get lastElementChild() {
|
|
1631
|
+
const vm = getAssociatedVM(this);
|
|
1632
|
+
const renderer = vm.renderer;
|
|
1633
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1634
|
+
warnIfInvokedDuringConstruction(vm, 'lastElementChild');
|
|
1635
|
+
}
|
|
1636
|
+
return renderer.getLastElementChild(vm.elm);
|
|
1637
|
+
},
|
|
1738
1638
|
render() {
|
|
1739
1639
|
const vm = getAssociatedVM(this);
|
|
1740
1640
|
return vm.def.template;
|
|
@@ -1745,76 +1645,22 @@ LightningElement.prototype = {
|
|
|
1745
1645
|
},
|
|
1746
1646
|
};
|
|
1747
1647
|
const queryAndChildGetterDescriptors = shared.create(null);
|
|
1748
|
-
// The reason we don't just call `import * as renderer from '../renderer'` here is that the bundle size
|
|
1749
|
-
// is smaller if we reference each function individually. Otherwise Rollup will create one big frozen
|
|
1750
|
-
// object representing the renderer, with a lot of methods we don't actually need.
|
|
1751
|
-
const childGetters = [
|
|
1752
|
-
'children',
|
|
1753
|
-
'childNodes',
|
|
1754
|
-
'firstChild',
|
|
1755
|
-
'firstElementChild',
|
|
1756
|
-
'lastChild',
|
|
1757
|
-
'lastElementChild',
|
|
1758
|
-
];
|
|
1759
|
-
function getChildGetter(methodName) {
|
|
1760
|
-
switch (methodName) {
|
|
1761
|
-
case 'children':
|
|
1762
|
-
return getChildren;
|
|
1763
|
-
case 'childNodes':
|
|
1764
|
-
return getChildNodes;
|
|
1765
|
-
case 'firstChild':
|
|
1766
|
-
return getFirstChild;
|
|
1767
|
-
case 'firstElementChild':
|
|
1768
|
-
return getFirstElementChild;
|
|
1769
|
-
case 'lastChild':
|
|
1770
|
-
return getLastChild;
|
|
1771
|
-
case 'lastElementChild':
|
|
1772
|
-
return getLastElementChild;
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
// Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
|
|
1776
|
-
for (const childGetter of childGetters) {
|
|
1777
|
-
queryAndChildGetterDescriptors[childGetter] = {
|
|
1778
|
-
get() {
|
|
1779
|
-
const vm = getAssociatedVM(this);
|
|
1780
|
-
const { elm } = vm;
|
|
1781
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1782
|
-
warnIfInvokedDuringConstruction(vm, childGetter);
|
|
1783
|
-
}
|
|
1784
|
-
return getChildGetter(childGetter)(elm);
|
|
1785
|
-
},
|
|
1786
|
-
configurable: true,
|
|
1787
|
-
enumerable: true,
|
|
1788
|
-
};
|
|
1789
|
-
}
|
|
1790
1648
|
const queryMethods = [
|
|
1791
1649
|
'getElementsByClassName',
|
|
1792
1650
|
'getElementsByTagName',
|
|
1793
1651
|
'querySelector',
|
|
1794
1652
|
'querySelectorAll',
|
|
1795
1653
|
];
|
|
1796
|
-
function getQueryMethod(methodName) {
|
|
1797
|
-
switch (methodName) {
|
|
1798
|
-
case 'getElementsByClassName':
|
|
1799
|
-
return getElementsByClassName;
|
|
1800
|
-
case 'getElementsByTagName':
|
|
1801
|
-
return getElementsByTagName;
|
|
1802
|
-
case 'querySelector':
|
|
1803
|
-
return querySelector;
|
|
1804
|
-
case 'querySelectorAll':
|
|
1805
|
-
return querySelectorAll;
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
1654
|
// Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
|
|
1809
1655
|
for (const queryMethod of queryMethods) {
|
|
1810
1656
|
queryAndChildGetterDescriptors[queryMethod] = {
|
|
1811
1657
|
value(arg) {
|
|
1812
1658
|
const vm = getAssociatedVM(this);
|
|
1813
|
-
const { elm } = vm;
|
|
1659
|
+
const { elm, renderer } = vm;
|
|
1814
1660
|
if (process.env.NODE_ENV !== 'production') {
|
|
1815
1661
|
warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
|
|
1816
1662
|
}
|
|
1817
|
-
return
|
|
1663
|
+
return renderer[queryMethod](elm, arg);
|
|
1818
1664
|
},
|
|
1819
1665
|
configurable: true,
|
|
1820
1666
|
enumerable: true,
|
|
@@ -3038,7 +2884,8 @@ function getComponentDef(Ctor) {
|
|
|
3038
2884
|
* SPDX-License-Identifier: MIT
|
|
3039
2885
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3040
2886
|
*/
|
|
3041
|
-
function getUpgradableConstructor(tagName) {
|
|
2887
|
+
function getUpgradableConstructor(tagName, renderer) {
|
|
2888
|
+
const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
|
|
3042
2889
|
// Should never get a tag with upper case letter at this point, the compiler should
|
|
3043
2890
|
// produce only tags with lowercase letters
|
|
3044
2891
|
// But, for backwards compatibility, we will lower case the tagName
|
|
@@ -3051,7 +2898,7 @@ function getUpgradableConstructor(tagName) {
|
|
|
3051
2898
|
* LWC Upgradable Element reference to an element that was created
|
|
3052
2899
|
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3053
2900
|
*/
|
|
3054
|
-
CE = class LWCUpgradableElement extends
|
|
2901
|
+
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
3055
2902
|
constructor(upgradeCallback) {
|
|
3056
2903
|
super();
|
|
3057
2904
|
if (shared.isFunction(upgradeCallback)) {
|
|
@@ -3084,7 +2931,7 @@ function isSameVnode(vnode1, vnode2) {
|
|
|
3084
2931
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3085
2932
|
*/
|
|
3086
2933
|
const ColonCharCode = 58;
|
|
3087
|
-
function patchAttributes(oldVnode, vnode) {
|
|
2934
|
+
function patchAttributes(oldVnode, vnode, renderer) {
|
|
3088
2935
|
const { attrs } = vnode.data;
|
|
3089
2936
|
if (shared.isUndefined(attrs)) {
|
|
3090
2937
|
return;
|
|
@@ -3094,6 +2941,7 @@ function patchAttributes(oldVnode, vnode) {
|
|
|
3094
2941
|
return;
|
|
3095
2942
|
}
|
|
3096
2943
|
const { elm } = vnode;
|
|
2944
|
+
const { setAttribute, removeAttribute } = renderer;
|
|
3097
2945
|
for (const key in attrs) {
|
|
3098
2946
|
const cur = attrs[key];
|
|
3099
2947
|
const old = oldAttrs[key];
|
|
@@ -3129,7 +2977,7 @@ function isLiveBindingProp(sel, key) {
|
|
|
3129
2977
|
// instead of relying on internally tracked values.
|
|
3130
2978
|
return sel === 'input' && (key === 'value' || key === 'checked');
|
|
3131
2979
|
}
|
|
3132
|
-
function patchProps(oldVnode, vnode) {
|
|
2980
|
+
function patchProps(oldVnode, vnode, renderer) {
|
|
3133
2981
|
const { props } = vnode.data;
|
|
3134
2982
|
if (shared.isUndefined(props)) {
|
|
3135
2983
|
return;
|
|
@@ -3140,6 +2988,7 @@ function patchProps(oldVnode, vnode) {
|
|
|
3140
2988
|
}
|
|
3141
2989
|
const isFirstPatch = shared.isNull(oldVnode);
|
|
3142
2990
|
const { elm, sel } = vnode;
|
|
2991
|
+
const { getProperty, setProperty } = renderer;
|
|
3143
2992
|
for (const key in props) {
|
|
3144
2993
|
const cur = props[key];
|
|
3145
2994
|
// Set the property if it's the first time is is patched or if the previous property is
|
|
@@ -3191,12 +3040,13 @@ function getMapFromClassName(className) {
|
|
|
3191
3040
|
}
|
|
3192
3041
|
return map;
|
|
3193
3042
|
}
|
|
3194
|
-
function patchClassAttribute(oldVnode, vnode) {
|
|
3043
|
+
function patchClassAttribute(oldVnode, vnode, renderer) {
|
|
3195
3044
|
const { elm, data: { className: newClass }, } = vnode;
|
|
3196
3045
|
const oldClass = shared.isNull(oldVnode) ? undefined : oldVnode.data.className;
|
|
3197
3046
|
if (oldClass === newClass) {
|
|
3198
3047
|
return;
|
|
3199
3048
|
}
|
|
3049
|
+
const { getClassList } = renderer;
|
|
3200
3050
|
const classList = getClassList(elm);
|
|
3201
3051
|
const newClassMap = getMapFromClassName(newClass);
|
|
3202
3052
|
const oldClassMap = getMapFromClassName(oldClass);
|
|
@@ -3221,12 +3071,13 @@ function patchClassAttribute(oldVnode, vnode) {
|
|
|
3221
3071
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3222
3072
|
*/
|
|
3223
3073
|
// The style property is a string when defined via an expression in the template.
|
|
3224
|
-
function patchStyleAttribute(oldVnode, vnode) {
|
|
3074
|
+
function patchStyleAttribute(oldVnode, vnode, renderer) {
|
|
3225
3075
|
const { elm, data: { style: newStyle }, } = vnode;
|
|
3226
3076
|
const oldStyle = shared.isNull(oldVnode) ? undefined : oldVnode.data.style;
|
|
3227
3077
|
if (oldStyle === newStyle) {
|
|
3228
3078
|
return;
|
|
3229
3079
|
}
|
|
3080
|
+
const { setAttribute, removeAttribute } = renderer;
|
|
3230
3081
|
if (!shared.isString(newStyle) || newStyle === '') {
|
|
3231
3082
|
removeAttribute(elm, 'style');
|
|
3232
3083
|
}
|
|
@@ -3241,11 +3092,12 @@ function patchStyleAttribute(oldVnode, vnode) {
|
|
|
3241
3092
|
* SPDX-License-Identifier: MIT
|
|
3242
3093
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3243
3094
|
*/
|
|
3244
|
-
function applyEventListeners(vnode) {
|
|
3095
|
+
function applyEventListeners(vnode, renderer) {
|
|
3245
3096
|
const { elm, data: { on }, } = vnode;
|
|
3246
3097
|
if (shared.isUndefined(on)) {
|
|
3247
3098
|
return;
|
|
3248
3099
|
}
|
|
3100
|
+
const { addEventListener } = renderer;
|
|
3249
3101
|
for (const name in on) {
|
|
3250
3102
|
const handler = on[name];
|
|
3251
3103
|
addEventListener(elm, name, handler);
|
|
@@ -3261,11 +3113,12 @@ function applyEventListeners(vnode) {
|
|
|
3261
3113
|
// The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
|
|
3262
3114
|
// The compiler takes care of transforming the inline classnames into an object. It's faster to set the
|
|
3263
3115
|
// different classnames properties individually instead of via a string.
|
|
3264
|
-
function applyStaticClassAttribute(vnode) {
|
|
3116
|
+
function applyStaticClassAttribute(vnode, renderer) {
|
|
3265
3117
|
const { elm, data: { classMap }, } = vnode;
|
|
3266
3118
|
if (shared.isUndefined(classMap)) {
|
|
3267
3119
|
return;
|
|
3268
3120
|
}
|
|
3121
|
+
const { getClassList } = renderer;
|
|
3269
3122
|
const classList = getClassList(elm);
|
|
3270
3123
|
for (const name in classMap) {
|
|
3271
3124
|
classList.add(name);
|
|
@@ -3281,11 +3134,12 @@ function applyStaticClassAttribute(vnode) {
|
|
|
3281
3134
|
// The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
|
|
3282
3135
|
// The compiler takes care of transforming the inline style into an object. It's faster to set the
|
|
3283
3136
|
// different style properties individually instead of via a string.
|
|
3284
|
-
function applyStaticStyleAttribute(vnode) {
|
|
3137
|
+
function applyStaticStyleAttribute(vnode, renderer) {
|
|
3285
3138
|
const { elm, data: { styleDecls }, } = vnode;
|
|
3286
3139
|
if (shared.isUndefined(styleDecls)) {
|
|
3287
3140
|
return;
|
|
3288
3141
|
}
|
|
3142
|
+
const { setCSSStyleProperty } = renderer;
|
|
3289
3143
|
for (let i = 0; i < styleDecls.length; i++) {
|
|
3290
3144
|
const [prop, value, important] = styleDecls[i];
|
|
3291
3145
|
setCSSStyleProperty(elm, prop, value, important);
|
|
@@ -3298,15 +3152,16 @@ function applyStaticStyleAttribute(vnode) {
|
|
|
3298
3152
|
* SPDX-License-Identifier: MIT
|
|
3299
3153
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3300
3154
|
*/
|
|
3301
|
-
function patchChildren(c1, c2, parent) {
|
|
3155
|
+
function patchChildren(c1, c2, parent, renderer) {
|
|
3302
3156
|
if (hasDynamicChildren(c2)) {
|
|
3303
|
-
updateDynamicChildren(c1, c2, parent);
|
|
3157
|
+
updateDynamicChildren(c1, c2, parent, renderer);
|
|
3304
3158
|
}
|
|
3305
3159
|
else {
|
|
3306
|
-
updateStaticChildren(c1, c2, parent);
|
|
3160
|
+
updateStaticChildren(c1, c2, parent, renderer);
|
|
3307
3161
|
}
|
|
3308
3162
|
}
|
|
3309
|
-
function patch(n1, n2) {
|
|
3163
|
+
function patch(n1, n2, renderer) {
|
|
3164
|
+
var _a, _b;
|
|
3310
3165
|
if (n1 === n2) {
|
|
3311
3166
|
return;
|
|
3312
3167
|
}
|
|
@@ -3320,80 +3175,90 @@ function patch(n1, n2) {
|
|
|
3320
3175
|
}
|
|
3321
3176
|
switch (n2.type) {
|
|
3322
3177
|
case 0 /* Text */:
|
|
3323
|
-
|
|
3178
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3179
|
+
patchText(n1, n2, renderer);
|
|
3324
3180
|
break;
|
|
3325
3181
|
case 1 /* Comment */:
|
|
3326
|
-
|
|
3182
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3183
|
+
patchComment(n1, n2, renderer);
|
|
3327
3184
|
break;
|
|
3328
3185
|
case 2 /* Element */:
|
|
3329
|
-
patchElement(n1, n2);
|
|
3186
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3330
3187
|
break;
|
|
3331
3188
|
case 3 /* CustomElement */:
|
|
3332
|
-
patchCustomElement(n1, n2);
|
|
3189
|
+
patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3333
3190
|
break;
|
|
3334
3191
|
}
|
|
3335
3192
|
}
|
|
3336
|
-
function mount(node, parent, anchor) {
|
|
3193
|
+
function mount(node, parent, renderer, anchor) {
|
|
3194
|
+
var _a, _b;
|
|
3337
3195
|
switch (node.type) {
|
|
3338
3196
|
case 0 /* Text */:
|
|
3339
|
-
|
|
3197
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3198
|
+
mountText(node, parent, anchor, renderer);
|
|
3340
3199
|
break;
|
|
3341
3200
|
case 1 /* Comment */:
|
|
3342
|
-
|
|
3201
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3202
|
+
mountComment(node, parent, anchor, renderer);
|
|
3343
3203
|
break;
|
|
3344
3204
|
case 2 /* Element */:
|
|
3345
|
-
|
|
3205
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3206
|
+
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3346
3207
|
break;
|
|
3347
3208
|
case 3 /* CustomElement */:
|
|
3348
|
-
|
|
3209
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3210
|
+
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3349
3211
|
break;
|
|
3350
3212
|
}
|
|
3351
3213
|
}
|
|
3352
|
-
function patchText(n1, n2) {
|
|
3214
|
+
function patchText(n1, n2, renderer) {
|
|
3353
3215
|
n2.elm = n1.elm;
|
|
3354
3216
|
if (n2.text !== n1.text) {
|
|
3355
|
-
updateTextContent(n2);
|
|
3217
|
+
updateTextContent(n2, renderer);
|
|
3356
3218
|
}
|
|
3357
3219
|
}
|
|
3358
|
-
function mountText(
|
|
3359
|
-
const { owner } =
|
|
3360
|
-
const
|
|
3361
|
-
|
|
3362
|
-
|
|
3220
|
+
function mountText(vnode, parent, anchor, renderer) {
|
|
3221
|
+
const { owner } = vnode;
|
|
3222
|
+
const { createText } = renderer;
|
|
3223
|
+
const textNode = (vnode.elm = createText(vnode.text));
|
|
3224
|
+
linkNodeToShadow(textNode, owner, renderer);
|
|
3225
|
+
insertNode(textNode, parent, anchor, renderer);
|
|
3363
3226
|
}
|
|
3364
|
-
function patchComment(n1, n2) {
|
|
3227
|
+
function patchComment(n1, n2, renderer) {
|
|
3365
3228
|
n2.elm = n1.elm;
|
|
3366
3229
|
// FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3367
3230
|
// it is the case today.
|
|
3368
3231
|
if (n2.text !== n1.text) {
|
|
3369
|
-
updateTextContent(n2);
|
|
3232
|
+
updateTextContent(n2, renderer);
|
|
3370
3233
|
}
|
|
3371
3234
|
}
|
|
3372
|
-
function mountComment(
|
|
3373
|
-
const { owner } =
|
|
3374
|
-
const
|
|
3375
|
-
|
|
3376
|
-
|
|
3235
|
+
function mountComment(vnode, parent, anchor, renderer) {
|
|
3236
|
+
const { owner } = vnode;
|
|
3237
|
+
const { createComment } = renderer;
|
|
3238
|
+
const commentNode = (vnode.elm = createComment(vnode.text));
|
|
3239
|
+
linkNodeToShadow(commentNode, owner, renderer);
|
|
3240
|
+
insertNode(commentNode, parent, anchor, renderer);
|
|
3377
3241
|
}
|
|
3378
|
-
function mountElement(vnode, parent, anchor) {
|
|
3242
|
+
function mountElement(vnode, parent, anchor, renderer) {
|
|
3379
3243
|
const { sel, owner, data: { svg }, } = vnode;
|
|
3244
|
+
const { createElement } = renderer;
|
|
3380
3245
|
const namespace = shared.isTrue(svg) ? shared.SVG_NAMESPACE : undefined;
|
|
3381
3246
|
const elm = createElement(sel, namespace);
|
|
3382
|
-
linkNodeToShadow(elm, owner);
|
|
3383
|
-
fallbackElmHook(elm, vnode);
|
|
3247
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3248
|
+
fallbackElmHook(elm, vnode, renderer);
|
|
3384
3249
|
vnode.elm = elm;
|
|
3385
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
3386
|
-
insertNode(elm, parent, anchor);
|
|
3387
|
-
mountVNodes(vnode.children, elm, null);
|
|
3250
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3251
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3252
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3388
3253
|
}
|
|
3389
|
-
function patchElement(n1, n2) {
|
|
3254
|
+
function patchElement(n1, n2, renderer) {
|
|
3390
3255
|
const elm = (n2.elm = n1.elm);
|
|
3391
|
-
patchElementPropsAndAttrs$1(n1, n2);
|
|
3392
|
-
patchChildren(n1.children, n2.children, elm);
|
|
3256
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3257
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3393
3258
|
}
|
|
3394
|
-
function mountCustomElement(vnode, parent, anchor) {
|
|
3259
|
+
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3395
3260
|
const { sel, owner } = vnode;
|
|
3396
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
3261
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
3397
3262
|
/**
|
|
3398
3263
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3399
3264
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -3403,9 +3268,9 @@ function mountCustomElement(vnode, parent, anchor) {
|
|
|
3403
3268
|
let vm;
|
|
3404
3269
|
const elm = new UpgradableConstructor((elm) => {
|
|
3405
3270
|
// the custom element from the registry is expecting an upgrade callback
|
|
3406
|
-
vm = createViewModelHook(elm, vnode);
|
|
3271
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
3407
3272
|
});
|
|
3408
|
-
linkNodeToShadow(elm, owner);
|
|
3273
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3409
3274
|
vnode.elm = elm;
|
|
3410
3275
|
vnode.vm = vm;
|
|
3411
3276
|
if (vm) {
|
|
@@ -3414,23 +3279,23 @@ function mountCustomElement(vnode, parent, anchor) {
|
|
|
3414
3279
|
else if (vnode.ctor !== UpgradableConstructor) {
|
|
3415
3280
|
throw new TypeError(`Incorrect Component Constructor`);
|
|
3416
3281
|
}
|
|
3417
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
3418
|
-
insertNode(elm, parent, anchor);
|
|
3282
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3283
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3419
3284
|
if (vm) {
|
|
3420
3285
|
if (process.env.NODE_ENV !== 'production') {
|
|
3421
3286
|
shared.assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
3422
3287
|
}
|
|
3423
3288
|
runConnectedCallback(vm);
|
|
3424
3289
|
}
|
|
3425
|
-
mountVNodes(vnode.children, elm, null);
|
|
3290
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3426
3291
|
if (vm) {
|
|
3427
3292
|
appendVM(vm);
|
|
3428
3293
|
}
|
|
3429
3294
|
}
|
|
3430
|
-
function patchCustomElement(n1, n2) {
|
|
3295
|
+
function patchCustomElement(n1, n2, renderer) {
|
|
3431
3296
|
const elm = (n2.elm = n1.elm);
|
|
3432
3297
|
const vm = (n2.vm = n1.vm);
|
|
3433
|
-
patchElementPropsAndAttrs$1(n1, n2);
|
|
3298
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3434
3299
|
if (!shared.isUndefined(vm)) {
|
|
3435
3300
|
// in fallback mode, the allocation will always set children to
|
|
3436
3301
|
// empty and delegate the real allocation to the slot elements
|
|
@@ -3438,34 +3303,36 @@ function patchCustomElement(n1, n2) {
|
|
|
3438
3303
|
}
|
|
3439
3304
|
// in fallback mode, the children will be always empty, so, nothing
|
|
3440
3305
|
// will happen, but in native, it does allocate the light dom
|
|
3441
|
-
patchChildren(n1.children, n2.children, elm);
|
|
3306
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3442
3307
|
if (!shared.isUndefined(vm)) {
|
|
3443
3308
|
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
3444
3309
|
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
3445
3310
|
rerenderVM(vm);
|
|
3446
3311
|
}
|
|
3447
3312
|
}
|
|
3448
|
-
function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
|
|
3313
|
+
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
3449
3314
|
for (; start < end; ++start) {
|
|
3450
3315
|
const vnode = vnodes[start];
|
|
3451
3316
|
if (isVNode(vnode)) {
|
|
3452
|
-
mount(vnode, parent, anchor);
|
|
3317
|
+
mount(vnode, parent, renderer, anchor);
|
|
3453
3318
|
}
|
|
3454
3319
|
}
|
|
3455
3320
|
}
|
|
3456
|
-
function unmount(vnode, parent, doRemove = false) {
|
|
3321
|
+
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
3457
3322
|
const { type, elm, sel } = vnode;
|
|
3458
3323
|
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
3459
3324
|
// subtree root, is the only element worth unmounting from the subtree.
|
|
3460
3325
|
if (doRemove) {
|
|
3461
|
-
|
|
3326
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
3327
|
+
// but the removal used here is from the owner instead.
|
|
3328
|
+
removeNode(elm, parent, renderer);
|
|
3462
3329
|
}
|
|
3463
3330
|
switch (type) {
|
|
3464
3331
|
case 2 /* Element */: {
|
|
3465
3332
|
// Slot content is removed to trigger slotchange event when removing slot.
|
|
3466
3333
|
// Only required for synthetic shadow.
|
|
3467
|
-
const
|
|
3468
|
-
unmountVNodes(vnode.children, elm,
|
|
3334
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
|
|
3335
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
3469
3336
|
break;
|
|
3470
3337
|
}
|
|
3471
3338
|
case 3 /* CustomElement */: {
|
|
@@ -3478,11 +3345,11 @@ function unmount(vnode, parent, doRemove = false) {
|
|
|
3478
3345
|
}
|
|
3479
3346
|
}
|
|
3480
3347
|
}
|
|
3481
|
-
function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
|
|
3348
|
+
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
3482
3349
|
for (; start < end; ++start) {
|
|
3483
3350
|
const ch = vnodes[start];
|
|
3484
3351
|
if (isVNode(ch)) {
|
|
3485
|
-
unmount(ch, parent, doRemove);
|
|
3352
|
+
unmount(ch, parent, renderer, doRemove);
|
|
3486
3353
|
}
|
|
3487
3354
|
}
|
|
3488
3355
|
}
|
|
@@ -3496,15 +3363,19 @@ function setElementShadowToken(elm, token) {
|
|
|
3496
3363
|
elm.$shadowToken$ = token;
|
|
3497
3364
|
}
|
|
3498
3365
|
// Set the scope token class for *.scoped.css styles
|
|
3499
|
-
function setScopeTokenClassIfNecessary(elm, owner) {
|
|
3366
|
+
function setScopeTokenClassIfNecessary(elm, owner, renderer) {
|
|
3500
3367
|
const { cmpTemplate, context } = owner;
|
|
3368
|
+
const { getClassList } = renderer;
|
|
3501
3369
|
const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
|
|
3502
3370
|
if (!shared.isUndefined(token) && context.hasScopedStyles) {
|
|
3371
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3372
|
+
// probably we should have a renderer api for just the add operation
|
|
3503
3373
|
getClassList(elm).add(token);
|
|
3504
3374
|
}
|
|
3505
3375
|
}
|
|
3506
|
-
function linkNodeToShadow(elm, owner) {
|
|
3376
|
+
function linkNodeToShadow(elm, owner, renderer) {
|
|
3507
3377
|
const { renderRoot, renderMode, shadowMode } = owner;
|
|
3378
|
+
const { isSyntheticShadowDefined } = renderer;
|
|
3508
3379
|
// TODO [#1164]: this should eventually be done by the polyfill directly
|
|
3509
3380
|
if (isSyntheticShadowDefined) {
|
|
3510
3381
|
if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
|
|
@@ -3512,8 +3383,9 @@ function linkNodeToShadow(elm, owner) {
|
|
|
3512
3383
|
}
|
|
3513
3384
|
}
|
|
3514
3385
|
}
|
|
3515
|
-
function updateTextContent(vnode) {
|
|
3386
|
+
function updateTextContent(vnode, renderer) {
|
|
3516
3387
|
const { elm, text } = vnode;
|
|
3388
|
+
const { setText } = renderer;
|
|
3517
3389
|
if (process.env.NODE_ENV !== 'production') {
|
|
3518
3390
|
unlockDomMutation();
|
|
3519
3391
|
}
|
|
@@ -3522,40 +3394,40 @@ function updateTextContent(vnode) {
|
|
|
3522
3394
|
lockDomMutation();
|
|
3523
3395
|
}
|
|
3524
3396
|
}
|
|
3525
|
-
function insertNode(node, parent, anchor) {
|
|
3397
|
+
function insertNode(node, parent, anchor, renderer) {
|
|
3526
3398
|
if (process.env.NODE_ENV !== 'production') {
|
|
3527
3399
|
unlockDomMutation();
|
|
3528
3400
|
}
|
|
3529
|
-
insert(node, parent, anchor);
|
|
3401
|
+
renderer.insert(node, parent, anchor);
|
|
3530
3402
|
if (process.env.NODE_ENV !== 'production') {
|
|
3531
3403
|
lockDomMutation();
|
|
3532
3404
|
}
|
|
3533
3405
|
}
|
|
3534
|
-
function removeNode(node, parent) {
|
|
3406
|
+
function removeNode(node, parent, renderer) {
|
|
3535
3407
|
if (process.env.NODE_ENV !== 'production') {
|
|
3536
3408
|
unlockDomMutation();
|
|
3537
3409
|
}
|
|
3538
|
-
remove(node, parent);
|
|
3410
|
+
renderer.remove(node, parent);
|
|
3539
3411
|
if (process.env.NODE_ENV !== 'production') {
|
|
3540
3412
|
lockDomMutation();
|
|
3541
3413
|
}
|
|
3542
3414
|
}
|
|
3543
|
-
function patchElementPropsAndAttrs$1(oldVnode, vnode) {
|
|
3415
|
+
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
3544
3416
|
if (shared.isNull(oldVnode)) {
|
|
3545
|
-
applyEventListeners(vnode);
|
|
3546
|
-
applyStaticClassAttribute(vnode);
|
|
3547
|
-
applyStaticStyleAttribute(vnode);
|
|
3417
|
+
applyEventListeners(vnode, renderer);
|
|
3418
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
3419
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
3548
3420
|
}
|
|
3549
3421
|
// Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
3550
3422
|
// value is set before type=radio.
|
|
3551
|
-
patchClassAttribute(oldVnode, vnode);
|
|
3552
|
-
patchStyleAttribute(oldVnode, vnode);
|
|
3553
|
-
patchAttributes(oldVnode, vnode);
|
|
3554
|
-
patchProps(oldVnode, vnode);
|
|
3423
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
3424
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
3425
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
3426
|
+
patchProps(oldVnode, vnode, renderer);
|
|
3555
3427
|
}
|
|
3556
|
-
function fallbackElmHook(elm, vnode) {
|
|
3428
|
+
function fallbackElmHook(elm, vnode, renderer) {
|
|
3557
3429
|
const { owner } = vnode;
|
|
3558
|
-
setScopeTokenClassIfNecessary(elm, owner);
|
|
3430
|
+
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
3559
3431
|
if (owner.shadowMode === 1 /* Synthetic */) {
|
|
3560
3432
|
const { data: { context }, } = vnode;
|
|
3561
3433
|
const { stylesheetToken } = owner.context;
|
|
@@ -3603,7 +3475,7 @@ function allocateChildren(vnode, vm) {
|
|
|
3603
3475
|
vnode.children = EmptyArray;
|
|
3604
3476
|
}
|
|
3605
3477
|
}
|
|
3606
|
-
function createViewModelHook(elm, vnode) {
|
|
3478
|
+
function createViewModelHook(elm, vnode, renderer) {
|
|
3607
3479
|
let vm = getAssociatedVMIfPresent(elm);
|
|
3608
3480
|
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
3609
3481
|
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
@@ -3612,7 +3484,7 @@ function createViewModelHook(elm, vnode) {
|
|
|
3612
3484
|
return vm;
|
|
3613
3485
|
}
|
|
3614
3486
|
const { sel, mode, ctor, owner } = vnode;
|
|
3615
|
-
setScopeTokenClassIfNecessary(elm, owner);
|
|
3487
|
+
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
3616
3488
|
if (owner.shadowMode === 1 /* Synthetic */) {
|
|
3617
3489
|
const { stylesheetToken } = owner.context;
|
|
3618
3490
|
// when running in synthetic shadow mode, we need to set the shadowToken value
|
|
@@ -3621,7 +3493,7 @@ function createViewModelHook(elm, vnode) {
|
|
|
3621
3493
|
setElementShadowToken(elm, stylesheetToken);
|
|
3622
3494
|
}
|
|
3623
3495
|
}
|
|
3624
|
-
vm = createVM(elm, ctor, {
|
|
3496
|
+
vm = createVM(elm, ctor, renderer, {
|
|
3625
3497
|
mode,
|
|
3626
3498
|
owner,
|
|
3627
3499
|
tagName: sel,
|
|
@@ -3696,7 +3568,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
|
3696
3568
|
}
|
|
3697
3569
|
return map;
|
|
3698
3570
|
}
|
|
3699
|
-
function updateDynamicChildren(oldCh, newCh, parent) {
|
|
3571
|
+
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
3700
3572
|
let oldStartIdx = 0;
|
|
3701
3573
|
let newStartIdx = 0;
|
|
3702
3574
|
let oldEndIdx = oldCh.length - 1;
|
|
@@ -3725,26 +3597,26 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3725
3597
|
newEndVnode = newCh[--newEndIdx];
|
|
3726
3598
|
}
|
|
3727
3599
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
3728
|
-
patch(oldStartVnode, newStartVnode);
|
|
3600
|
+
patch(oldStartVnode, newStartVnode, renderer);
|
|
3729
3601
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3730
3602
|
newStartVnode = newCh[++newStartIdx];
|
|
3731
3603
|
}
|
|
3732
3604
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
3733
|
-
patch(oldEndVnode, newEndVnode);
|
|
3605
|
+
patch(oldEndVnode, newEndVnode, renderer);
|
|
3734
3606
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3735
3607
|
newEndVnode = newCh[--newEndIdx];
|
|
3736
3608
|
}
|
|
3737
3609
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
3738
3610
|
// Vnode moved right
|
|
3739
|
-
patch(oldStartVnode, newEndVnode);
|
|
3740
|
-
insertNode(oldStartVnode.elm, parent, nextSibling(oldEndVnode.elm));
|
|
3611
|
+
patch(oldStartVnode, newEndVnode, renderer);
|
|
3612
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
3741
3613
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3742
3614
|
newEndVnode = newCh[--newEndIdx];
|
|
3743
3615
|
}
|
|
3744
3616
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
3745
3617
|
// Vnode moved left
|
|
3746
|
-
patch(oldEndVnode, newStartVnode);
|
|
3747
|
-
insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
|
|
3618
|
+
patch(oldEndVnode, newStartVnode, renderer);
|
|
3619
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
3748
3620
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3749
3621
|
newStartVnode = newCh[++newStartIdx];
|
|
3750
3622
|
}
|
|
@@ -3755,7 +3627,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3755
3627
|
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
3756
3628
|
if (shared.isUndefined(idxInOld)) {
|
|
3757
3629
|
// New element
|
|
3758
|
-
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
3630
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3759
3631
|
newStartVnode = newCh[++newStartIdx];
|
|
3760
3632
|
}
|
|
3761
3633
|
else {
|
|
@@ -3763,10 +3635,10 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3763
3635
|
if (isVNode(elmToMove)) {
|
|
3764
3636
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
3765
3637
|
// New element
|
|
3766
|
-
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
3638
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3767
3639
|
}
|
|
3768
3640
|
else {
|
|
3769
|
-
patch(elmToMove, newStartVnode);
|
|
3641
|
+
patch(elmToMove, newStartVnode, renderer);
|
|
3770
3642
|
// Delete the old child, but copy the array since it is read-only.
|
|
3771
3643
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
3772
3644
|
// so we only care about the `oldCh` object inside this function.
|
|
@@ -3778,7 +3650,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3778
3650
|
}
|
|
3779
3651
|
// We've already cloned at least once, so it's no longer read-only
|
|
3780
3652
|
oldCh[idxInOld] = undefined;
|
|
3781
|
-
insertNode(elmToMove.elm, parent, oldStartVnode.elm);
|
|
3653
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
3782
3654
|
}
|
|
3783
3655
|
}
|
|
3784
3656
|
newStartVnode = newCh[++newStartIdx];
|
|
@@ -3795,25 +3667,25 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3795
3667
|
n = newCh[++i];
|
|
3796
3668
|
} while (!isVNode(n) && i < newChEnd);
|
|
3797
3669
|
before = isVNode(n) ? n.elm : null;
|
|
3798
|
-
mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
|
|
3670
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
3799
3671
|
}
|
|
3800
3672
|
else {
|
|
3801
|
-
unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
|
|
3673
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
3802
3674
|
}
|
|
3803
3675
|
}
|
|
3804
3676
|
}
|
|
3805
|
-
function updateStaticChildren(c1, c2, parent) {
|
|
3677
|
+
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
3806
3678
|
const c1Length = c1.length;
|
|
3807
3679
|
const c2Length = c2.length;
|
|
3808
3680
|
if (c1Length === 0) {
|
|
3809
3681
|
// the old list is empty, we can directly insert anything new
|
|
3810
|
-
mountVNodes(c2, parent, null);
|
|
3682
|
+
mountVNodes(c2, parent, renderer, null);
|
|
3811
3683
|
return;
|
|
3812
3684
|
}
|
|
3813
3685
|
if (c2Length === 0) {
|
|
3814
3686
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
3815
3687
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
3816
|
-
unmountVNodes(c1, parent, true);
|
|
3688
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
3817
3689
|
return;
|
|
3818
3690
|
}
|
|
3819
3691
|
// if the old list is not empty, the new list MUST have the same
|
|
@@ -3826,16 +3698,16 @@ function updateStaticChildren(c1, c2, parent) {
|
|
|
3826
3698
|
if (isVNode(n1)) {
|
|
3827
3699
|
if (isVNode(n2)) {
|
|
3828
3700
|
// both vnodes are equivalent, and we just need to patch them
|
|
3829
|
-
patch(n1, n2);
|
|
3701
|
+
patch(n1, n2, renderer);
|
|
3830
3702
|
anchor = n2.elm;
|
|
3831
3703
|
}
|
|
3832
3704
|
else {
|
|
3833
3705
|
// removing the old vnode since the new one is null
|
|
3834
|
-
unmount(n1, parent, true);
|
|
3706
|
+
unmount(n1, parent, renderer, true);
|
|
3835
3707
|
}
|
|
3836
3708
|
}
|
|
3837
3709
|
else if (isVNode(n2)) {
|
|
3838
|
-
mount(n2, parent, anchor);
|
|
3710
|
+
mount(n2, parent, renderer, anchor);
|
|
3839
3711
|
anchor = n2.elm;
|
|
3840
3712
|
}
|
|
3841
3713
|
}
|
|
@@ -4264,7 +4136,7 @@ function createInlineStyleVNode(content) {
|
|
|
4264
4136
|
}, [api.t(content)]);
|
|
4265
4137
|
}
|
|
4266
4138
|
function updateStylesheetToken(vm, template) {
|
|
4267
|
-
const { elm, context, renderMode, shadowMode } = vm;
|
|
4139
|
+
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
4268
4140
|
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
4269
4141
|
const isSyntheticShadow = renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */;
|
|
4270
4142
|
const { hasScopedStyles } = context;
|
|
@@ -4381,7 +4253,7 @@ function getNearestNativeShadowComponent(vm) {
|
|
|
4381
4253
|
return owner;
|
|
4382
4254
|
}
|
|
4383
4255
|
function createStylesheet(vm, stylesheets) {
|
|
4384
|
-
const { renderMode, shadowMode } = vm;
|
|
4256
|
+
const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
|
|
4385
4257
|
if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
|
|
4386
4258
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
4387
4259
|
insertStylesheet(stylesheets[i]);
|
|
@@ -4956,7 +4828,7 @@ function getNearestShadowAncestor(vm) {
|
|
|
4956
4828
|
return ancestor;
|
|
4957
4829
|
}
|
|
4958
4830
|
|
|
4959
|
-
function createVM(elm, ctor, options) {
|
|
4831
|
+
function createVM(elm, ctor, renderer, options) {
|
|
4960
4832
|
const {
|
|
4961
4833
|
mode,
|
|
4962
4834
|
owner,
|
|
@@ -5005,9 +4877,10 @@ function createVM(elm, ctor, options) {
|
|
|
5005
4877
|
renderRoot: null,
|
|
5006
4878
|
callHook,
|
|
5007
4879
|
setHook,
|
|
5008
|
-
getHook
|
|
4880
|
+
getHook,
|
|
4881
|
+
renderer
|
|
5009
4882
|
};
|
|
5010
|
-
vm.shadowMode = computeShadowMode(vm);
|
|
4883
|
+
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5011
4884
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
5012
4885
|
|
|
5013
4886
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5032,10 +4905,14 @@ function createVM(elm, ctor, options) {
|
|
|
5032
4905
|
return vm;
|
|
5033
4906
|
}
|
|
5034
4907
|
|
|
5035
|
-
function computeShadowMode(vm) {
|
|
4908
|
+
function computeShadowMode(vm, renderer) {
|
|
5036
4909
|
const {
|
|
5037
4910
|
def
|
|
5038
4911
|
} = vm;
|
|
4912
|
+
const {
|
|
4913
|
+
isSyntheticShadowDefined,
|
|
4914
|
+
isNativeShadowDefined
|
|
4915
|
+
} = renderer;
|
|
5039
4916
|
let shadowMode;
|
|
5040
4917
|
|
|
5041
4918
|
if (isSyntheticShadowDefined) {
|
|
@@ -5137,7 +5014,8 @@ function rehydrate(vm) {
|
|
|
5137
5014
|
function patchShadowRoot(vm, newCh) {
|
|
5138
5015
|
const {
|
|
5139
5016
|
renderRoot,
|
|
5140
|
-
children: oldCh
|
|
5017
|
+
children: oldCh,
|
|
5018
|
+
renderer
|
|
5141
5019
|
} = vm; // caching the new children collection
|
|
5142
5020
|
|
|
5143
5021
|
vm.children = newCh;
|
|
@@ -5153,7 +5031,7 @@ function patchShadowRoot(vm, newCh) {
|
|
|
5153
5031
|
, vm);
|
|
5154
5032
|
}, () => {
|
|
5155
5033
|
// job
|
|
5156
|
-
patchChildren(oldCh, newCh, renderRoot);
|
|
5034
|
+
patchChildren(oldCh, newCh, renderRoot, renderer);
|
|
5157
5035
|
}, () => {
|
|
5158
5036
|
// post
|
|
5159
5037
|
logOperationEnd(2
|
|
@@ -5178,6 +5056,9 @@ function runRenderedCallback(vm) {
|
|
|
5178
5056
|
const {
|
|
5179
5057
|
def: {
|
|
5180
5058
|
renderedCallback
|
|
5059
|
+
},
|
|
5060
|
+
renderer: {
|
|
5061
|
+
ssr
|
|
5181
5062
|
}
|
|
5182
5063
|
} = vm;
|
|
5183
5064
|
|
|
@@ -5415,7 +5296,10 @@ function recursivelyDisconnectChildren(vnodes) {
|
|
|
5415
5296
|
function resetComponentRoot(vm) {
|
|
5416
5297
|
const {
|
|
5417
5298
|
children,
|
|
5418
|
-
renderRoot
|
|
5299
|
+
renderRoot,
|
|
5300
|
+
renderer: {
|
|
5301
|
+
remove
|
|
5302
|
+
}
|
|
5419
5303
|
} = vm;
|
|
5420
5304
|
|
|
5421
5305
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
@@ -5431,6 +5315,12 @@ function resetComponentRoot(vm) {
|
|
|
5431
5315
|
vm.velements = EmptyArray;
|
|
5432
5316
|
}
|
|
5433
5317
|
function scheduleRehydration(vm) {
|
|
5318
|
+
const {
|
|
5319
|
+
renderer: {
|
|
5320
|
+
ssr
|
|
5321
|
+
}
|
|
5322
|
+
} = vm;
|
|
5323
|
+
|
|
5434
5324
|
if (shared.isTrue(ssr) || shared.isTrue(vm.isScheduled)) {
|
|
5435
5325
|
return;
|
|
5436
5326
|
}
|
|
@@ -5607,6 +5497,9 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
|
5607
5497
|
context: {
|
|
5608
5498
|
wiredConnecting,
|
|
5609
5499
|
wiredDisconnecting
|
|
5500
|
+
},
|
|
5501
|
+
renderer: {
|
|
5502
|
+
dispatchEvent
|
|
5610
5503
|
}
|
|
5611
5504
|
} = vm; // waiting for the component to be connected to formally request the context via the token
|
|
5612
5505
|
|
|
@@ -5878,70 +5771,79 @@ function hydrateRoot(vm) {
|
|
|
5878
5771
|
function hydrateVM(vm) {
|
|
5879
5772
|
const children = renderComponent(vm);
|
|
5880
5773
|
vm.children = children;
|
|
5881
|
-
const parentNode = vm
|
|
5774
|
+
const { renderRoot: parentNode, renderer: { getFirstChild }, } = vm;
|
|
5882
5775
|
hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
|
|
5883
5776
|
runRenderedCallback(vm);
|
|
5884
5777
|
}
|
|
5885
|
-
function hydrateNode(node, vnode) {
|
|
5778
|
+
function hydrateNode(node, vnode, renderer) {
|
|
5779
|
+
var _a, _b;
|
|
5886
5780
|
let hydratedNode;
|
|
5887
5781
|
switch (vnode.type) {
|
|
5888
5782
|
case 0 /* Text */:
|
|
5889
|
-
|
|
5783
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
5784
|
+
hydratedNode = hydrateText(node, vnode, renderer);
|
|
5890
5785
|
break;
|
|
5891
5786
|
case 1 /* Comment */:
|
|
5892
|
-
|
|
5787
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
5788
|
+
hydratedNode = hydrateComment(node, vnode, renderer);
|
|
5893
5789
|
break;
|
|
5894
5790
|
case 2 /* Element */:
|
|
5895
|
-
hydratedNode = hydrateElement(node, vnode);
|
|
5791
|
+
hydratedNode = hydrateElement(node, vnode, (_a = vnode.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
5896
5792
|
break;
|
|
5897
5793
|
case 3 /* CustomElement */:
|
|
5898
|
-
hydratedNode = hydrateCustomElement(node, vnode);
|
|
5794
|
+
hydratedNode = hydrateCustomElement(node, vnode, (_b = vnode.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
5899
5795
|
break;
|
|
5900
5796
|
}
|
|
5901
|
-
return nextSibling(hydratedNode);
|
|
5797
|
+
return renderer.nextSibling(hydratedNode);
|
|
5902
5798
|
}
|
|
5903
|
-
function hydrateText(node, vnode) {
|
|
5799
|
+
function hydrateText(node, vnode, renderer) {
|
|
5904
5800
|
var _a;
|
|
5905
|
-
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT
|
|
5906
|
-
return handleMismatch(node, vnode);
|
|
5801
|
+
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */, renderer)) {
|
|
5802
|
+
return handleMismatch(node, vnode, renderer);
|
|
5907
5803
|
}
|
|
5908
5804
|
if (process.env.NODE_ENV !== 'production') {
|
|
5805
|
+
const { getProperty } = renderer;
|
|
5909
5806
|
const nodeValue = getProperty(node, 'nodeValue');
|
|
5910
5807
|
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
5911
5808
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
5912
5809
|
}
|
|
5913
5810
|
}
|
|
5811
|
+
const { setText } = renderer;
|
|
5914
5812
|
setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5915
5813
|
vnode.elm = node;
|
|
5916
5814
|
return node;
|
|
5917
5815
|
}
|
|
5918
|
-
function hydrateComment(node, vnode) {
|
|
5816
|
+
function hydrateComment(node, vnode, renderer) {
|
|
5919
5817
|
var _a;
|
|
5920
|
-
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT
|
|
5921
|
-
return handleMismatch(node, vnode);
|
|
5818
|
+
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */, renderer)) {
|
|
5819
|
+
return handleMismatch(node, vnode, renderer);
|
|
5922
5820
|
}
|
|
5923
5821
|
if (process.env.NODE_ENV !== 'production') {
|
|
5822
|
+
const { getProperty } = renderer;
|
|
5924
5823
|
const nodeValue = getProperty(node, 'nodeValue');
|
|
5925
5824
|
if (nodeValue !== vnode.text) {
|
|
5926
5825
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
5927
5826
|
}
|
|
5928
5827
|
}
|
|
5828
|
+
const { setProperty } = renderer;
|
|
5929
5829
|
setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5930
5830
|
vnode.elm = node;
|
|
5931
5831
|
return node;
|
|
5932
5832
|
}
|
|
5933
|
-
function hydrateElement(elm, vnode) {
|
|
5934
|
-
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT
|
|
5935
|
-
!isMatchingElement(vnode, elm)) {
|
|
5936
|
-
return handleMismatch(elm, vnode);
|
|
5833
|
+
function hydrateElement(elm, vnode, renderer) {
|
|
5834
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
|
|
5835
|
+
!isMatchingElement(vnode, elm, renderer)) {
|
|
5836
|
+
return handleMismatch(elm, vnode, renderer);
|
|
5937
5837
|
}
|
|
5938
5838
|
vnode.elm = elm;
|
|
5839
|
+
const { owner } = vnode;
|
|
5939
5840
|
const { context } = vnode.data;
|
|
5940
5841
|
const isDomManual = Boolean(!shared.isUndefined(context) && !shared.isUndefined(context.lwc) && context.lwc.dom === "manual" /* Manual */);
|
|
5941
5842
|
if (isDomManual) {
|
|
5942
5843
|
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
5943
5844
|
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
5944
|
-
const { props } = vnode
|
|
5845
|
+
const { data: { props }, } = vnode;
|
|
5846
|
+
const { getProperty } = renderer;
|
|
5945
5847
|
if (!shared.isUndefined(props) && !shared.isUndefined(props.innerHTML)) {
|
|
5946
5848
|
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
5947
5849
|
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
@@ -5949,24 +5851,25 @@ function hydrateElement(elm, vnode) {
|
|
|
5949
5851
|
}
|
|
5950
5852
|
else {
|
|
5951
5853
|
if (process.env.NODE_ENV !== 'production') {
|
|
5952
|
-
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`,
|
|
5854
|
+
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, owner);
|
|
5953
5855
|
}
|
|
5954
5856
|
}
|
|
5955
5857
|
}
|
|
5956
5858
|
}
|
|
5957
|
-
patchElementPropsAndAttrs(vnode);
|
|
5859
|
+
patchElementPropsAndAttrs(vnode, renderer);
|
|
5958
5860
|
if (!isDomManual) {
|
|
5959
|
-
|
|
5861
|
+
const { getFirstChild } = renderer;
|
|
5862
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, owner);
|
|
5960
5863
|
}
|
|
5961
5864
|
return elm;
|
|
5962
5865
|
}
|
|
5963
|
-
function hydrateCustomElement(elm, vnode) {
|
|
5964
|
-
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT
|
|
5965
|
-
!isMatchingElement(vnode, elm)) {
|
|
5966
|
-
return handleMismatch(elm, vnode);
|
|
5866
|
+
function hydrateCustomElement(elm, vnode, renderer) {
|
|
5867
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
|
|
5868
|
+
!isMatchingElement(vnode, elm, renderer)) {
|
|
5869
|
+
return handleMismatch(elm, vnode, renderer);
|
|
5967
5870
|
}
|
|
5968
5871
|
const { sel, mode, ctor, owner } = vnode;
|
|
5969
|
-
const vm = createVM(elm, ctor, {
|
|
5872
|
+
const vm = createVM(elm, ctor, renderer, {
|
|
5970
5873
|
mode,
|
|
5971
5874
|
owner,
|
|
5972
5875
|
tagName: sel,
|
|
@@ -5975,13 +5878,14 @@ function hydrateCustomElement(elm, vnode) {
|
|
|
5975
5878
|
vnode.elm = elm;
|
|
5976
5879
|
vnode.vm = vm;
|
|
5977
5880
|
allocateChildren(vnode, vm);
|
|
5978
|
-
patchElementPropsAndAttrs(vnode);
|
|
5881
|
+
patchElementPropsAndAttrs(vnode, renderer);
|
|
5979
5882
|
// Insert hook section:
|
|
5980
5883
|
if (process.env.NODE_ENV !== 'production') {
|
|
5981
5884
|
shared.assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
5982
5885
|
}
|
|
5983
5886
|
runConnectedCallback(vm);
|
|
5984
5887
|
if (vm.renderMode !== 0 /* Light */) {
|
|
5888
|
+
const { getFirstChild } = renderer;
|
|
5985
5889
|
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
5986
5890
|
// Note: for Light DOM, this is handled while hydrating the VM
|
|
5987
5891
|
hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
|
|
@@ -5993,11 +5897,12 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
5993
5897
|
let hasWarned = false;
|
|
5994
5898
|
let nextNode = node;
|
|
5995
5899
|
let anchor = null;
|
|
5900
|
+
const { renderer } = owner;
|
|
5996
5901
|
for (let i = 0; i < children.length; i++) {
|
|
5997
5902
|
const childVnode = children[i];
|
|
5998
5903
|
if (!shared.isNull(childVnode)) {
|
|
5999
5904
|
if (nextNode) {
|
|
6000
|
-
nextNode = hydrateNode(nextNode, childVnode);
|
|
5905
|
+
nextNode = hydrateNode(nextNode, childVnode, renderer);
|
|
6001
5906
|
anchor = childVnode.elm;
|
|
6002
5907
|
}
|
|
6003
5908
|
else {
|
|
@@ -6008,7 +5913,7 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
6008
5913
|
logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
|
|
6009
5914
|
}
|
|
6010
5915
|
}
|
|
6011
|
-
mount(childVnode, parentNode, anchor);
|
|
5916
|
+
mount(childVnode, parentNode, renderer, anchor);
|
|
6012
5917
|
anchor = childVnode.elm;
|
|
6013
5918
|
}
|
|
6014
5919
|
}
|
|
@@ -6020,30 +5925,32 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
6020
5925
|
logError(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
|
|
6021
5926
|
}
|
|
6022
5927
|
}
|
|
5928
|
+
// nextSibling is mostly harmless, and since we don't have
|
|
5929
|
+
// a good reference to what element to act upon, we instead
|
|
5930
|
+
// rely on the vm's associated renderer for navigating to the
|
|
5931
|
+
// next node in the list to be hydrated.
|
|
5932
|
+
const { nextSibling } = renderer;
|
|
6023
5933
|
do {
|
|
6024
5934
|
const current = nextNode;
|
|
6025
5935
|
nextNode = nextSibling(nextNode);
|
|
6026
|
-
removeNode(current, parentNode);
|
|
5936
|
+
removeNode(current, parentNode, renderer);
|
|
6027
5937
|
} while (nextNode);
|
|
6028
5938
|
}
|
|
6029
5939
|
}
|
|
6030
|
-
function handleMismatch(node, vnode,
|
|
5940
|
+
function handleMismatch(node, vnode, renderer) {
|
|
6031
5941
|
hasMismatch = true;
|
|
6032
|
-
|
|
6033
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6034
|
-
logError(msg, vnode.owner);
|
|
6035
|
-
}
|
|
6036
|
-
}
|
|
5942
|
+
const { getProperty } = renderer;
|
|
6037
5943
|
const parentNode = getProperty(node, 'parentNode');
|
|
6038
|
-
mount(vnode, parentNode, node);
|
|
6039
|
-
removeNode(node, parentNode);
|
|
5944
|
+
mount(vnode, parentNode, renderer, node);
|
|
5945
|
+
removeNode(node, parentNode, renderer);
|
|
6040
5946
|
return vnode.elm;
|
|
6041
5947
|
}
|
|
6042
|
-
function patchElementPropsAndAttrs(vnode) {
|
|
6043
|
-
applyEventListeners(vnode);
|
|
6044
|
-
patchProps(null, vnode);
|
|
5948
|
+
function patchElementPropsAndAttrs(vnode, renderer) {
|
|
5949
|
+
applyEventListeners(vnode, renderer);
|
|
5950
|
+
patchProps(null, vnode, renderer);
|
|
6045
5951
|
}
|
|
6046
|
-
function hasCorrectNodeType(vnode, node, nodeType) {
|
|
5952
|
+
function hasCorrectNodeType(vnode, node, nodeType, renderer) {
|
|
5953
|
+
const { getProperty } = renderer;
|
|
6047
5954
|
if (getProperty(node, 'nodeType') !== nodeType) {
|
|
6048
5955
|
if (process.env.NODE_ENV !== 'production') {
|
|
6049
5956
|
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
@@ -6052,36 +5959,41 @@ function hasCorrectNodeType(vnode, node, nodeType) {
|
|
|
6052
5959
|
}
|
|
6053
5960
|
return true;
|
|
6054
5961
|
}
|
|
6055
|
-
function isMatchingElement(vnode, elm) {
|
|
5962
|
+
function isMatchingElement(vnode, elm, renderer) {
|
|
5963
|
+
const { getProperty } = renderer;
|
|
6056
5964
|
if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
|
|
6057
5965
|
if (process.env.NODE_ENV !== 'production') {
|
|
6058
5966
|
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
6059
5967
|
}
|
|
6060
5968
|
return false;
|
|
6061
5969
|
}
|
|
6062
|
-
const hasIncompatibleAttrs = validateAttrs(vnode, elm);
|
|
6063
|
-
const hasIncompatibleClass = validateClassAttr(vnode, elm);
|
|
6064
|
-
const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
|
|
5970
|
+
const hasIncompatibleAttrs = validateAttrs(vnode, elm, renderer);
|
|
5971
|
+
const hasIncompatibleClass = validateClassAttr(vnode, elm, renderer);
|
|
5972
|
+
const hasIncompatibleStyle = validateStyleAttr(vnode, elm, renderer);
|
|
6065
5973
|
return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
6066
5974
|
}
|
|
6067
|
-
function validateAttrs(vnode, elm) {
|
|
5975
|
+
function validateAttrs(vnode, elm, renderer) {
|
|
6068
5976
|
const { data: { attrs = {} }, } = vnode;
|
|
6069
5977
|
let nodesAreCompatible = true;
|
|
6070
5978
|
// Validate attributes, though we could always recovery from those by running the update mods.
|
|
6071
5979
|
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
6072
5980
|
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
5981
|
+
const { owner } = vnode;
|
|
5982
|
+
const { getAttribute } = renderer;
|
|
6073
5983
|
const elmAttrValue = getAttribute(elm, attrName);
|
|
6074
5984
|
if (String(attrValue) !== elmAttrValue) {
|
|
6075
5985
|
if (process.env.NODE_ENV !== 'production') {
|
|
6076
|
-
|
|
5986
|
+
const { getProperty } = renderer;
|
|
5987
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, owner);
|
|
6077
5988
|
}
|
|
6078
5989
|
nodesAreCompatible = false;
|
|
6079
5990
|
}
|
|
6080
5991
|
}
|
|
6081
5992
|
return nodesAreCompatible;
|
|
6082
5993
|
}
|
|
6083
|
-
function validateClassAttr(vnode, elm) {
|
|
5994
|
+
function validateClassAttr(vnode, elm, renderer) {
|
|
6084
5995
|
const { data: { className, classMap }, } = vnode;
|
|
5996
|
+
const { getProperty, getClassList } = renderer;
|
|
6085
5997
|
let nodesAreCompatible = true;
|
|
6086
5998
|
let vnodeClassName;
|
|
6087
5999
|
if (!shared.isUndefined(className) && String(className) !== getProperty(elm, 'className')) {
|
|
@@ -6112,8 +6024,9 @@ function validateClassAttr(vnode, elm) {
|
|
|
6112
6024
|
}
|
|
6113
6025
|
return nodesAreCompatible;
|
|
6114
6026
|
}
|
|
6115
|
-
function validateStyleAttr(vnode, elm) {
|
|
6027
|
+
function validateStyleAttr(vnode, elm, renderer) {
|
|
6116
6028
|
const { data: { style, styleDecls }, } = vnode;
|
|
6029
|
+
const { getAttribute } = renderer;
|
|
6117
6030
|
const elmStyle = getAttribute(elm, 'style') || '';
|
|
6118
6031
|
let vnodeStyle;
|
|
6119
6032
|
let nodesAreCompatible = true;
|
|
@@ -6146,6 +6059,7 @@ function validateStyleAttr(vnode, elm) {
|
|
|
6146
6059
|
}
|
|
6147
6060
|
if (!nodesAreCompatible) {
|
|
6148
6061
|
if (process.env.NODE_ENV !== 'production') {
|
|
6062
|
+
const { getProperty } = renderer;
|
|
6149
6063
|
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
6150
6064
|
}
|
|
6151
6065
|
}
|
|
@@ -6316,50 +6230,11 @@ exports.registerComponent = registerComponent;
|
|
|
6316
6230
|
exports.registerDecorators = registerDecorators;
|
|
6317
6231
|
exports.registerTemplate = registerTemplate;
|
|
6318
6232
|
exports.sanitizeAttribute = sanitizeAttribute;
|
|
6319
|
-
exports.setAddEventListener = setAddEventListener;
|
|
6320
|
-
exports.setAssertInstanceOfHTMLElement = setAssertInstanceOfHTMLElement;
|
|
6321
|
-
exports.setAttachShadow = setAttachShadow;
|
|
6322
|
-
exports.setCreateComment = setCreateComment;
|
|
6323
|
-
exports.setCreateElement = setCreateElement;
|
|
6324
|
-
exports.setCreateText = setCreateText;
|
|
6325
|
-
exports.setDefineCustomElement = setDefineCustomElement;
|
|
6326
|
-
exports.setDispatchEvent = setDispatchEvent;
|
|
6327
|
-
exports.setGetAttribute = setGetAttribute;
|
|
6328
|
-
exports.setGetBoundingClientRect = setGetBoundingClientRect;
|
|
6329
|
-
exports.setGetChildNodes = setGetChildNodes;
|
|
6330
|
-
exports.setGetChildren = setGetChildren;
|
|
6331
|
-
exports.setGetClassList = setGetClassList;
|
|
6332
|
-
exports.setGetCustomElement = setGetCustomElement;
|
|
6333
|
-
exports.setGetElementsByClassName = setGetElementsByClassName;
|
|
6334
|
-
exports.setGetElementsByTagName = setGetElementsByTagName;
|
|
6335
|
-
exports.setGetFirstChild = setGetFirstChild;
|
|
6336
|
-
exports.setGetFirstElementChild = setGetFirstElementChild;
|
|
6337
|
-
exports.setGetLastChild = setGetLastChild;
|
|
6338
|
-
exports.setGetLastElementChild = setGetLastElementChild;
|
|
6339
|
-
exports.setGetProperty = setGetProperty;
|
|
6340
|
-
exports.setHTMLElement = setHTMLElement;
|
|
6341
6233
|
exports.setHooks = setHooks;
|
|
6342
|
-
exports.setInsert = setInsert;
|
|
6343
|
-
exports.setInsertStylesheet = setInsertStylesheet;
|
|
6344
|
-
exports.setIsConnected = setIsConnected;
|
|
6345
|
-
exports.setIsHydrating = setIsHydrating;
|
|
6346
|
-
exports.setIsNativeShadowDefined = setIsNativeShadowDefined;
|
|
6347
|
-
exports.setIsSyntheticShadowDefined = setIsSyntheticShadowDefined;
|
|
6348
|
-
exports.setNextSibling = setNextSibling;
|
|
6349
|
-
exports.setQuerySelector = setQuerySelector;
|
|
6350
|
-
exports.setQuerySelectorAll = setQuerySelectorAll;
|
|
6351
|
-
exports.setRemove = setRemove;
|
|
6352
|
-
exports.setRemoveAttribute = setRemoveAttribute;
|
|
6353
|
-
exports.setRemoveEventListener = setRemoveEventListener;
|
|
6354
|
-
exports.setSetAttribute = setSetAttribute;
|
|
6355
|
-
exports.setSetCSSStyleProperty = setSetCSSStyleProperty;
|
|
6356
|
-
exports.setSetProperty = setSetProperty;
|
|
6357
|
-
exports.setSetText = setSetText;
|
|
6358
|
-
exports.setSsr = setSsr;
|
|
6359
6234
|
exports.swapComponent = swapComponent;
|
|
6360
6235
|
exports.swapStyle = swapStyle;
|
|
6361
6236
|
exports.swapTemplate = swapTemplate;
|
|
6362
6237
|
exports.track = track;
|
|
6363
6238
|
exports.unwrap = unwrap;
|
|
6364
6239
|
exports.wire = wire;
|
|
6365
|
-
/* version: 2.14.
|
|
6240
|
+
/* version: 2.14.2 */
|