@lwc/engine-core 2.13.4 → 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 +344 -443
- package/dist/engine-core.js +345 -405
- 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 +6 -6
- 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,
|
|
@@ -2316,7 +2162,8 @@ function getDecoratorsMeta(Ctor) {
|
|
|
2316
2162
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2317
2163
|
*/
|
|
2318
2164
|
let warned = false;
|
|
2319
|
-
|
|
2165
|
+
// @ts-ignore
|
|
2166
|
+
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
2320
2167
|
// @ts-ignore
|
|
2321
2168
|
window.__lwcResetWarnedOnVersionMismatch = () => {
|
|
2322
2169
|
warned = false;
|
|
@@ -3034,7 +2881,8 @@ function getComponentDef(Ctor) {
|
|
|
3034
2881
|
* SPDX-License-Identifier: MIT
|
|
3035
2882
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3036
2883
|
*/
|
|
3037
|
-
function getUpgradableConstructor(tagName) {
|
|
2884
|
+
function getUpgradableConstructor(tagName, renderer) {
|
|
2885
|
+
const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
|
|
3038
2886
|
// Should never get a tag with upper case letter at this point, the compiler should
|
|
3039
2887
|
// produce only tags with lowercase letters
|
|
3040
2888
|
// But, for backwards compatibility, we will lower case the tagName
|
|
@@ -3047,7 +2895,7 @@ function getUpgradableConstructor(tagName) {
|
|
|
3047
2895
|
* LWC Upgradable Element reference to an element that was created
|
|
3048
2896
|
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3049
2897
|
*/
|
|
3050
|
-
CE = class LWCUpgradableElement extends
|
|
2898
|
+
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
3051
2899
|
constructor(upgradeCallback) {
|
|
3052
2900
|
super();
|
|
3053
2901
|
if (isFunction$1(upgradeCallback)) {
|
|
@@ -3080,7 +2928,7 @@ function isSameVnode(vnode1, vnode2) {
|
|
|
3080
2928
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3081
2929
|
*/
|
|
3082
2930
|
const ColonCharCode = 58;
|
|
3083
|
-
function patchAttributes(oldVnode, vnode) {
|
|
2931
|
+
function patchAttributes(oldVnode, vnode, renderer) {
|
|
3084
2932
|
const { attrs } = vnode.data;
|
|
3085
2933
|
if (isUndefined$1(attrs)) {
|
|
3086
2934
|
return;
|
|
@@ -3090,6 +2938,7 @@ function patchAttributes(oldVnode, vnode) {
|
|
|
3090
2938
|
return;
|
|
3091
2939
|
}
|
|
3092
2940
|
const { elm } = vnode;
|
|
2941
|
+
const { setAttribute, removeAttribute } = renderer;
|
|
3093
2942
|
for (const key in attrs) {
|
|
3094
2943
|
const cur = attrs[key];
|
|
3095
2944
|
const old = oldAttrs[key];
|
|
@@ -3125,7 +2974,7 @@ function isLiveBindingProp(sel, key) {
|
|
|
3125
2974
|
// instead of relying on internally tracked values.
|
|
3126
2975
|
return sel === 'input' && (key === 'value' || key === 'checked');
|
|
3127
2976
|
}
|
|
3128
|
-
function patchProps(oldVnode, vnode) {
|
|
2977
|
+
function patchProps(oldVnode, vnode, renderer) {
|
|
3129
2978
|
const { props } = vnode.data;
|
|
3130
2979
|
if (isUndefined$1(props)) {
|
|
3131
2980
|
return;
|
|
@@ -3136,6 +2985,7 @@ function patchProps(oldVnode, vnode) {
|
|
|
3136
2985
|
}
|
|
3137
2986
|
const isFirstPatch = isNull(oldVnode);
|
|
3138
2987
|
const { elm, sel } = vnode;
|
|
2988
|
+
const { getProperty, setProperty } = renderer;
|
|
3139
2989
|
for (const key in props) {
|
|
3140
2990
|
const cur = props[key];
|
|
3141
2991
|
// Set the property if it's the first time is is patched or if the previous property is
|
|
@@ -3187,12 +3037,13 @@ function getMapFromClassName(className) {
|
|
|
3187
3037
|
}
|
|
3188
3038
|
return map;
|
|
3189
3039
|
}
|
|
3190
|
-
function patchClassAttribute(oldVnode, vnode) {
|
|
3040
|
+
function patchClassAttribute(oldVnode, vnode, renderer) {
|
|
3191
3041
|
const { elm, data: { className: newClass }, } = vnode;
|
|
3192
3042
|
const oldClass = isNull(oldVnode) ? undefined : oldVnode.data.className;
|
|
3193
3043
|
if (oldClass === newClass) {
|
|
3194
3044
|
return;
|
|
3195
3045
|
}
|
|
3046
|
+
const { getClassList } = renderer;
|
|
3196
3047
|
const classList = getClassList(elm);
|
|
3197
3048
|
const newClassMap = getMapFromClassName(newClass);
|
|
3198
3049
|
const oldClassMap = getMapFromClassName(oldClass);
|
|
@@ -3217,12 +3068,13 @@ function patchClassAttribute(oldVnode, vnode) {
|
|
|
3217
3068
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3218
3069
|
*/
|
|
3219
3070
|
// The style property is a string when defined via an expression in the template.
|
|
3220
|
-
function patchStyleAttribute(oldVnode, vnode) {
|
|
3071
|
+
function patchStyleAttribute(oldVnode, vnode, renderer) {
|
|
3221
3072
|
const { elm, data: { style: newStyle }, } = vnode;
|
|
3222
3073
|
const oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
|
|
3223
3074
|
if (oldStyle === newStyle) {
|
|
3224
3075
|
return;
|
|
3225
3076
|
}
|
|
3077
|
+
const { setAttribute, removeAttribute } = renderer;
|
|
3226
3078
|
if (!isString(newStyle) || newStyle === '') {
|
|
3227
3079
|
removeAttribute(elm, 'style');
|
|
3228
3080
|
}
|
|
@@ -3237,11 +3089,12 @@ function patchStyleAttribute(oldVnode, vnode) {
|
|
|
3237
3089
|
* SPDX-License-Identifier: MIT
|
|
3238
3090
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3239
3091
|
*/
|
|
3240
|
-
function applyEventListeners(vnode) {
|
|
3092
|
+
function applyEventListeners(vnode, renderer) {
|
|
3241
3093
|
const { elm, data: { on }, } = vnode;
|
|
3242
3094
|
if (isUndefined$1(on)) {
|
|
3243
3095
|
return;
|
|
3244
3096
|
}
|
|
3097
|
+
const { addEventListener } = renderer;
|
|
3245
3098
|
for (const name in on) {
|
|
3246
3099
|
const handler = on[name];
|
|
3247
3100
|
addEventListener(elm, name, handler);
|
|
@@ -3257,11 +3110,12 @@ function applyEventListeners(vnode) {
|
|
|
3257
3110
|
// The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
|
|
3258
3111
|
// The compiler takes care of transforming the inline classnames into an object. It's faster to set the
|
|
3259
3112
|
// different classnames properties individually instead of via a string.
|
|
3260
|
-
function applyStaticClassAttribute(vnode) {
|
|
3113
|
+
function applyStaticClassAttribute(vnode, renderer) {
|
|
3261
3114
|
const { elm, data: { classMap }, } = vnode;
|
|
3262
3115
|
if (isUndefined$1(classMap)) {
|
|
3263
3116
|
return;
|
|
3264
3117
|
}
|
|
3118
|
+
const { getClassList } = renderer;
|
|
3265
3119
|
const classList = getClassList(elm);
|
|
3266
3120
|
for (const name in classMap) {
|
|
3267
3121
|
classList.add(name);
|
|
@@ -3277,11 +3131,12 @@ function applyStaticClassAttribute(vnode) {
|
|
|
3277
3131
|
// The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
|
|
3278
3132
|
// The compiler takes care of transforming the inline style into an object. It's faster to set the
|
|
3279
3133
|
// different style properties individually instead of via a string.
|
|
3280
|
-
function applyStaticStyleAttribute(vnode) {
|
|
3134
|
+
function applyStaticStyleAttribute(vnode, renderer) {
|
|
3281
3135
|
const { elm, data: { styleDecls }, } = vnode;
|
|
3282
3136
|
if (isUndefined$1(styleDecls)) {
|
|
3283
3137
|
return;
|
|
3284
3138
|
}
|
|
3139
|
+
const { setCSSStyleProperty } = renderer;
|
|
3285
3140
|
for (let i = 0; i < styleDecls.length; i++) {
|
|
3286
3141
|
const [prop, value, important] = styleDecls[i];
|
|
3287
3142
|
setCSSStyleProperty(elm, prop, value, important);
|
|
@@ -3294,15 +3149,16 @@ function applyStaticStyleAttribute(vnode) {
|
|
|
3294
3149
|
* SPDX-License-Identifier: MIT
|
|
3295
3150
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3296
3151
|
*/
|
|
3297
|
-
function patchChildren(c1, c2, parent) {
|
|
3152
|
+
function patchChildren(c1, c2, parent, renderer) {
|
|
3298
3153
|
if (hasDynamicChildren(c2)) {
|
|
3299
|
-
updateDynamicChildren(c1, c2, parent);
|
|
3154
|
+
updateDynamicChildren(c1, c2, parent, renderer);
|
|
3300
3155
|
}
|
|
3301
3156
|
else {
|
|
3302
|
-
updateStaticChildren(c1, c2, parent);
|
|
3157
|
+
updateStaticChildren(c1, c2, parent, renderer);
|
|
3303
3158
|
}
|
|
3304
3159
|
}
|
|
3305
|
-
function patch(n1, n2) {
|
|
3160
|
+
function patch(n1, n2, renderer) {
|
|
3161
|
+
var _a, _b;
|
|
3306
3162
|
if (n1 === n2) {
|
|
3307
3163
|
return;
|
|
3308
3164
|
}
|
|
@@ -3316,80 +3172,90 @@ function patch(n1, n2) {
|
|
|
3316
3172
|
}
|
|
3317
3173
|
switch (n2.type) {
|
|
3318
3174
|
case 0 /* Text */:
|
|
3319
|
-
|
|
3175
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3176
|
+
patchText(n1, n2, renderer);
|
|
3320
3177
|
break;
|
|
3321
3178
|
case 1 /* Comment */:
|
|
3322
|
-
|
|
3179
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3180
|
+
patchComment(n1, n2, renderer);
|
|
3323
3181
|
break;
|
|
3324
3182
|
case 2 /* Element */:
|
|
3325
|
-
patchElement(n1, n2);
|
|
3183
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3326
3184
|
break;
|
|
3327
3185
|
case 3 /* CustomElement */:
|
|
3328
|
-
patchCustomElement(n1, n2);
|
|
3186
|
+
patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3329
3187
|
break;
|
|
3330
3188
|
}
|
|
3331
3189
|
}
|
|
3332
|
-
function mount(node, parent, anchor) {
|
|
3190
|
+
function mount(node, parent, renderer, anchor) {
|
|
3191
|
+
var _a, _b;
|
|
3333
3192
|
switch (node.type) {
|
|
3334
3193
|
case 0 /* Text */:
|
|
3335
|
-
|
|
3194
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3195
|
+
mountText(node, parent, anchor, renderer);
|
|
3336
3196
|
break;
|
|
3337
3197
|
case 1 /* Comment */:
|
|
3338
|
-
|
|
3198
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3199
|
+
mountComment(node, parent, anchor, renderer);
|
|
3339
3200
|
break;
|
|
3340
3201
|
case 2 /* Element */:
|
|
3341
|
-
|
|
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);
|
|
3342
3204
|
break;
|
|
3343
3205
|
case 3 /* CustomElement */:
|
|
3344
|
-
|
|
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);
|
|
3345
3208
|
break;
|
|
3346
3209
|
}
|
|
3347
3210
|
}
|
|
3348
|
-
function patchText(n1, n2) {
|
|
3211
|
+
function patchText(n1, n2, renderer) {
|
|
3349
3212
|
n2.elm = n1.elm;
|
|
3350
3213
|
if (n2.text !== n1.text) {
|
|
3351
|
-
updateTextContent(n2);
|
|
3214
|
+
updateTextContent(n2, renderer);
|
|
3352
3215
|
}
|
|
3353
3216
|
}
|
|
3354
|
-
function mountText(
|
|
3355
|
-
const { owner } =
|
|
3356
|
-
const
|
|
3357
|
-
|
|
3358
|
-
|
|
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);
|
|
3359
3223
|
}
|
|
3360
|
-
function patchComment(n1, n2) {
|
|
3224
|
+
function patchComment(n1, n2, renderer) {
|
|
3361
3225
|
n2.elm = n1.elm;
|
|
3362
3226
|
// FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3363
3227
|
// it is the case today.
|
|
3364
3228
|
if (n2.text !== n1.text) {
|
|
3365
|
-
updateTextContent(n2);
|
|
3229
|
+
updateTextContent(n2, renderer);
|
|
3366
3230
|
}
|
|
3367
3231
|
}
|
|
3368
|
-
function mountComment(
|
|
3369
|
-
const { owner } =
|
|
3370
|
-
const
|
|
3371
|
-
|
|
3372
|
-
|
|
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);
|
|
3373
3238
|
}
|
|
3374
|
-
function mountElement(vnode, parent, anchor) {
|
|
3239
|
+
function mountElement(vnode, parent, anchor, renderer) {
|
|
3375
3240
|
const { sel, owner, data: { svg }, } = vnode;
|
|
3241
|
+
const { createElement } = renderer;
|
|
3376
3242
|
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
3377
3243
|
const elm = createElement(sel, namespace);
|
|
3378
|
-
linkNodeToShadow(elm, owner);
|
|
3379
|
-
fallbackElmHook(elm, vnode);
|
|
3244
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3245
|
+
fallbackElmHook(elm, vnode, renderer);
|
|
3380
3246
|
vnode.elm = elm;
|
|
3381
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
3382
|
-
insertNode(elm, parent, anchor);
|
|
3383
|
-
mountVNodes(vnode.children, elm, null);
|
|
3247
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3248
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3249
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3384
3250
|
}
|
|
3385
|
-
function patchElement(n1, n2) {
|
|
3251
|
+
function patchElement(n1, n2, renderer) {
|
|
3386
3252
|
const elm = (n2.elm = n1.elm);
|
|
3387
|
-
patchElementPropsAndAttrs$1(n1, n2);
|
|
3388
|
-
patchChildren(n1.children, n2.children, elm);
|
|
3253
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3254
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3389
3255
|
}
|
|
3390
|
-
function mountCustomElement(vnode, parent, anchor) {
|
|
3256
|
+
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3391
3257
|
const { sel, owner } = vnode;
|
|
3392
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
3258
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
3393
3259
|
/**
|
|
3394
3260
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3395
3261
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -3399,9 +3265,9 @@ function mountCustomElement(vnode, parent, anchor) {
|
|
|
3399
3265
|
let vm;
|
|
3400
3266
|
const elm = new UpgradableConstructor((elm) => {
|
|
3401
3267
|
// the custom element from the registry is expecting an upgrade callback
|
|
3402
|
-
vm = createViewModelHook(elm, vnode);
|
|
3268
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
3403
3269
|
});
|
|
3404
|
-
linkNodeToShadow(elm, owner);
|
|
3270
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3405
3271
|
vnode.elm = elm;
|
|
3406
3272
|
vnode.vm = vm;
|
|
3407
3273
|
if (vm) {
|
|
@@ -3410,23 +3276,23 @@ function mountCustomElement(vnode, parent, anchor) {
|
|
|
3410
3276
|
else if (vnode.ctor !== UpgradableConstructor) {
|
|
3411
3277
|
throw new TypeError(`Incorrect Component Constructor`);
|
|
3412
3278
|
}
|
|
3413
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
3414
|
-
insertNode(elm, parent, anchor);
|
|
3279
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3280
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3415
3281
|
if (vm) {
|
|
3416
3282
|
if (process.env.NODE_ENV !== 'production') {
|
|
3417
3283
|
assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
3418
3284
|
}
|
|
3419
3285
|
runConnectedCallback(vm);
|
|
3420
3286
|
}
|
|
3421
|
-
mountVNodes(vnode.children, elm, null);
|
|
3287
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3422
3288
|
if (vm) {
|
|
3423
3289
|
appendVM(vm);
|
|
3424
3290
|
}
|
|
3425
3291
|
}
|
|
3426
|
-
function patchCustomElement(n1, n2) {
|
|
3292
|
+
function patchCustomElement(n1, n2, renderer) {
|
|
3427
3293
|
const elm = (n2.elm = n1.elm);
|
|
3428
3294
|
const vm = (n2.vm = n1.vm);
|
|
3429
|
-
patchElementPropsAndAttrs$1(n1, n2);
|
|
3295
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3430
3296
|
if (!isUndefined$1(vm)) {
|
|
3431
3297
|
// in fallback mode, the allocation will always set children to
|
|
3432
3298
|
// empty and delegate the real allocation to the slot elements
|
|
@@ -3434,33 +3300,38 @@ function patchCustomElement(n1, n2) {
|
|
|
3434
3300
|
}
|
|
3435
3301
|
// in fallback mode, the children will be always empty, so, nothing
|
|
3436
3302
|
// will happen, but in native, it does allocate the light dom
|
|
3437
|
-
patchChildren(n1.children, n2.children, elm);
|
|
3303
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3438
3304
|
if (!isUndefined$1(vm)) {
|
|
3439
3305
|
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
3440
3306
|
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
3441
3307
|
rerenderVM(vm);
|
|
3442
3308
|
}
|
|
3443
3309
|
}
|
|
3444
|
-
function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
|
|
3310
|
+
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
3445
3311
|
for (; start < end; ++start) {
|
|
3446
3312
|
const vnode = vnodes[start];
|
|
3447
3313
|
if (isVNode(vnode)) {
|
|
3448
|
-
mount(vnode, parent, anchor);
|
|
3314
|
+
mount(vnode, parent, renderer, anchor);
|
|
3449
3315
|
}
|
|
3450
3316
|
}
|
|
3451
3317
|
}
|
|
3452
|
-
function unmount(vnode, parent, doRemove = false) {
|
|
3318
|
+
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
3453
3319
|
const { type, elm, sel } = vnode;
|
|
3454
3320
|
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
3455
3321
|
// subtree root, is the only element worth unmounting from the subtree.
|
|
3456
3322
|
if (doRemove) {
|
|
3457
|
-
|
|
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);
|
|
3458
3326
|
}
|
|
3459
|
-
const removeChildren = sel === 'slot'; // slot content is removed to trigger slotchange event when removing slot
|
|
3460
3327
|
switch (type) {
|
|
3461
|
-
case 2 /* Element */:
|
|
3462
|
-
|
|
3328
|
+
case 2 /* Element */: {
|
|
3329
|
+
// Slot content is removed to trigger slotchange event when removing slot.
|
|
3330
|
+
// Only required for synthetic shadow.
|
|
3331
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
|
|
3332
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
3463
3333
|
break;
|
|
3334
|
+
}
|
|
3464
3335
|
case 3 /* CustomElement */: {
|
|
3465
3336
|
const { vm } = vnode;
|
|
3466
3337
|
// No need to unmount the children here, `removeVM` will take care of removing the
|
|
@@ -3471,11 +3342,11 @@ function unmount(vnode, parent, doRemove = false) {
|
|
|
3471
3342
|
}
|
|
3472
3343
|
}
|
|
3473
3344
|
}
|
|
3474
|
-
function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
|
|
3345
|
+
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
3475
3346
|
for (; start < end; ++start) {
|
|
3476
3347
|
const ch = vnodes[start];
|
|
3477
3348
|
if (isVNode(ch)) {
|
|
3478
|
-
unmount(ch, parent, doRemove);
|
|
3349
|
+
unmount(ch, parent, renderer, doRemove);
|
|
3479
3350
|
}
|
|
3480
3351
|
}
|
|
3481
3352
|
}
|
|
@@ -3489,15 +3360,19 @@ function setElementShadowToken(elm, token) {
|
|
|
3489
3360
|
elm.$shadowToken$ = token;
|
|
3490
3361
|
}
|
|
3491
3362
|
// Set the scope token class for *.scoped.css styles
|
|
3492
|
-
function setScopeTokenClassIfNecessary(elm, owner) {
|
|
3363
|
+
function setScopeTokenClassIfNecessary(elm, owner, renderer) {
|
|
3493
3364
|
const { cmpTemplate, context } = owner;
|
|
3365
|
+
const { getClassList } = renderer;
|
|
3494
3366
|
const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
|
|
3495
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
|
|
3496
3370
|
getClassList(elm).add(token);
|
|
3497
3371
|
}
|
|
3498
3372
|
}
|
|
3499
|
-
function linkNodeToShadow(elm, owner) {
|
|
3373
|
+
function linkNodeToShadow(elm, owner, renderer) {
|
|
3500
3374
|
const { renderRoot, renderMode, shadowMode } = owner;
|
|
3375
|
+
const { isSyntheticShadowDefined } = renderer;
|
|
3501
3376
|
// TODO [#1164]: this should eventually be done by the polyfill directly
|
|
3502
3377
|
if (isSyntheticShadowDefined) {
|
|
3503
3378
|
if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
|
|
@@ -3505,8 +3380,9 @@ function linkNodeToShadow(elm, owner) {
|
|
|
3505
3380
|
}
|
|
3506
3381
|
}
|
|
3507
3382
|
}
|
|
3508
|
-
function updateTextContent(vnode) {
|
|
3383
|
+
function updateTextContent(vnode, renderer) {
|
|
3509
3384
|
const { elm, text } = vnode;
|
|
3385
|
+
const { setText } = renderer;
|
|
3510
3386
|
if (process.env.NODE_ENV !== 'production') {
|
|
3511
3387
|
unlockDomMutation();
|
|
3512
3388
|
}
|
|
@@ -3515,40 +3391,40 @@ function updateTextContent(vnode) {
|
|
|
3515
3391
|
lockDomMutation();
|
|
3516
3392
|
}
|
|
3517
3393
|
}
|
|
3518
|
-
function insertNode(node, parent, anchor) {
|
|
3394
|
+
function insertNode(node, parent, anchor, renderer) {
|
|
3519
3395
|
if (process.env.NODE_ENV !== 'production') {
|
|
3520
3396
|
unlockDomMutation();
|
|
3521
3397
|
}
|
|
3522
|
-
insert(node, parent, anchor);
|
|
3398
|
+
renderer.insert(node, parent, anchor);
|
|
3523
3399
|
if (process.env.NODE_ENV !== 'production') {
|
|
3524
3400
|
lockDomMutation();
|
|
3525
3401
|
}
|
|
3526
3402
|
}
|
|
3527
|
-
function removeNode(node, parent) {
|
|
3403
|
+
function removeNode(node, parent, renderer) {
|
|
3528
3404
|
if (process.env.NODE_ENV !== 'production') {
|
|
3529
3405
|
unlockDomMutation();
|
|
3530
3406
|
}
|
|
3531
|
-
remove(node, parent);
|
|
3407
|
+
renderer.remove(node, parent);
|
|
3532
3408
|
if (process.env.NODE_ENV !== 'production') {
|
|
3533
3409
|
lockDomMutation();
|
|
3534
3410
|
}
|
|
3535
3411
|
}
|
|
3536
|
-
function patchElementPropsAndAttrs$1(oldVnode, vnode) {
|
|
3412
|
+
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
3537
3413
|
if (isNull(oldVnode)) {
|
|
3538
|
-
applyEventListeners(vnode);
|
|
3539
|
-
applyStaticClassAttribute(vnode);
|
|
3540
|
-
applyStaticStyleAttribute(vnode);
|
|
3414
|
+
applyEventListeners(vnode, renderer);
|
|
3415
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
3416
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
3541
3417
|
}
|
|
3542
3418
|
// Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
3543
3419
|
// value is set before type=radio.
|
|
3544
|
-
patchClassAttribute(oldVnode, vnode);
|
|
3545
|
-
patchStyleAttribute(oldVnode, vnode);
|
|
3546
|
-
patchAttributes(oldVnode, vnode);
|
|
3547
|
-
patchProps(oldVnode, vnode);
|
|
3420
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
3421
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
3422
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
3423
|
+
patchProps(oldVnode, vnode, renderer);
|
|
3548
3424
|
}
|
|
3549
|
-
function fallbackElmHook(elm, vnode) {
|
|
3425
|
+
function fallbackElmHook(elm, vnode, renderer) {
|
|
3550
3426
|
const { owner } = vnode;
|
|
3551
|
-
setScopeTokenClassIfNecessary(elm, owner);
|
|
3427
|
+
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
3552
3428
|
if (owner.shadowMode === 1 /* Synthetic */) {
|
|
3553
3429
|
const { data: { context }, } = vnode;
|
|
3554
3430
|
const { stylesheetToken } = owner.context;
|
|
@@ -3596,7 +3472,7 @@ function allocateChildren(vnode, vm) {
|
|
|
3596
3472
|
vnode.children = EmptyArray;
|
|
3597
3473
|
}
|
|
3598
3474
|
}
|
|
3599
|
-
function createViewModelHook(elm, vnode) {
|
|
3475
|
+
function createViewModelHook(elm, vnode, renderer) {
|
|
3600
3476
|
let vm = getAssociatedVMIfPresent(elm);
|
|
3601
3477
|
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
3602
3478
|
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
@@ -3605,7 +3481,7 @@ function createViewModelHook(elm, vnode) {
|
|
|
3605
3481
|
return vm;
|
|
3606
3482
|
}
|
|
3607
3483
|
const { sel, mode, ctor, owner } = vnode;
|
|
3608
|
-
setScopeTokenClassIfNecessary(elm, owner);
|
|
3484
|
+
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
3609
3485
|
if (owner.shadowMode === 1 /* Synthetic */) {
|
|
3610
3486
|
const { stylesheetToken } = owner.context;
|
|
3611
3487
|
// when running in synthetic shadow mode, we need to set the shadowToken value
|
|
@@ -3614,7 +3490,7 @@ function createViewModelHook(elm, vnode) {
|
|
|
3614
3490
|
setElementShadowToken(elm, stylesheetToken);
|
|
3615
3491
|
}
|
|
3616
3492
|
}
|
|
3617
|
-
vm = createVM(elm, ctor, {
|
|
3493
|
+
vm = createVM(elm, ctor, renderer, {
|
|
3618
3494
|
mode,
|
|
3619
3495
|
owner,
|
|
3620
3496
|
tagName: sel,
|
|
@@ -3689,7 +3565,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
|
3689
3565
|
}
|
|
3690
3566
|
return map;
|
|
3691
3567
|
}
|
|
3692
|
-
function updateDynamicChildren(oldCh, newCh, parent) {
|
|
3568
|
+
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
3693
3569
|
let oldStartIdx = 0;
|
|
3694
3570
|
let newStartIdx = 0;
|
|
3695
3571
|
let oldEndIdx = oldCh.length - 1;
|
|
@@ -3718,26 +3594,26 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3718
3594
|
newEndVnode = newCh[--newEndIdx];
|
|
3719
3595
|
}
|
|
3720
3596
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
3721
|
-
patch(oldStartVnode, newStartVnode);
|
|
3597
|
+
patch(oldStartVnode, newStartVnode, renderer);
|
|
3722
3598
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3723
3599
|
newStartVnode = newCh[++newStartIdx];
|
|
3724
3600
|
}
|
|
3725
3601
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
3726
|
-
patch(oldEndVnode, newEndVnode);
|
|
3602
|
+
patch(oldEndVnode, newEndVnode, renderer);
|
|
3727
3603
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3728
3604
|
newEndVnode = newCh[--newEndIdx];
|
|
3729
3605
|
}
|
|
3730
3606
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
3731
3607
|
// Vnode moved right
|
|
3732
|
-
patch(oldStartVnode, newEndVnode);
|
|
3733
|
-
insertNode(oldStartVnode.elm, parent, nextSibling(oldEndVnode.elm));
|
|
3608
|
+
patch(oldStartVnode, newEndVnode, renderer);
|
|
3609
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
3734
3610
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3735
3611
|
newEndVnode = newCh[--newEndIdx];
|
|
3736
3612
|
}
|
|
3737
3613
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
3738
3614
|
// Vnode moved left
|
|
3739
|
-
patch(oldEndVnode, newStartVnode);
|
|
3740
|
-
insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
|
|
3615
|
+
patch(oldEndVnode, newStartVnode, renderer);
|
|
3616
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
3741
3617
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3742
3618
|
newStartVnode = newCh[++newStartIdx];
|
|
3743
3619
|
}
|
|
@@ -3748,7 +3624,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3748
3624
|
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
3749
3625
|
if (isUndefined$1(idxInOld)) {
|
|
3750
3626
|
// New element
|
|
3751
|
-
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
3627
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3752
3628
|
newStartVnode = newCh[++newStartIdx];
|
|
3753
3629
|
}
|
|
3754
3630
|
else {
|
|
@@ -3756,10 +3632,10 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3756
3632
|
if (isVNode(elmToMove)) {
|
|
3757
3633
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
3758
3634
|
// New element
|
|
3759
|
-
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
3635
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3760
3636
|
}
|
|
3761
3637
|
else {
|
|
3762
|
-
patch(elmToMove, newStartVnode);
|
|
3638
|
+
patch(elmToMove, newStartVnode, renderer);
|
|
3763
3639
|
// Delete the old child, but copy the array since it is read-only.
|
|
3764
3640
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
3765
3641
|
// so we only care about the `oldCh` object inside this function.
|
|
@@ -3771,7 +3647,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3771
3647
|
}
|
|
3772
3648
|
// We've already cloned at least once, so it's no longer read-only
|
|
3773
3649
|
oldCh[idxInOld] = undefined;
|
|
3774
|
-
insertNode(elmToMove.elm, parent, oldStartVnode.elm);
|
|
3650
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
3775
3651
|
}
|
|
3776
3652
|
}
|
|
3777
3653
|
newStartVnode = newCh[++newStartIdx];
|
|
@@ -3788,25 +3664,25 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3788
3664
|
n = newCh[++i];
|
|
3789
3665
|
} while (!isVNode(n) && i < newChEnd);
|
|
3790
3666
|
before = isVNode(n) ? n.elm : null;
|
|
3791
|
-
mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
|
|
3667
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
3792
3668
|
}
|
|
3793
3669
|
else {
|
|
3794
|
-
unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
|
|
3670
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
3795
3671
|
}
|
|
3796
3672
|
}
|
|
3797
3673
|
}
|
|
3798
|
-
function updateStaticChildren(c1, c2, parent) {
|
|
3674
|
+
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
3799
3675
|
const c1Length = c1.length;
|
|
3800
3676
|
const c2Length = c2.length;
|
|
3801
3677
|
if (c1Length === 0) {
|
|
3802
3678
|
// the old list is empty, we can directly insert anything new
|
|
3803
|
-
mountVNodes(c2, parent, null);
|
|
3679
|
+
mountVNodes(c2, parent, renderer, null);
|
|
3804
3680
|
return;
|
|
3805
3681
|
}
|
|
3806
3682
|
if (c2Length === 0) {
|
|
3807
3683
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
3808
3684
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
3809
|
-
unmountVNodes(c1, parent, true);
|
|
3685
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
3810
3686
|
return;
|
|
3811
3687
|
}
|
|
3812
3688
|
// if the old list is not empty, the new list MUST have the same
|
|
@@ -3819,16 +3695,16 @@ function updateStaticChildren(c1, c2, parent) {
|
|
|
3819
3695
|
if (isVNode(n1)) {
|
|
3820
3696
|
if (isVNode(n2)) {
|
|
3821
3697
|
// both vnodes are equivalent, and we just need to patch them
|
|
3822
|
-
patch(n1, n2);
|
|
3698
|
+
patch(n1, n2, renderer);
|
|
3823
3699
|
anchor = n2.elm;
|
|
3824
3700
|
}
|
|
3825
3701
|
else {
|
|
3826
3702
|
// removing the old vnode since the new one is null
|
|
3827
|
-
unmount(n1, parent, true);
|
|
3703
|
+
unmount(n1, parent, renderer, true);
|
|
3828
3704
|
}
|
|
3829
3705
|
}
|
|
3830
3706
|
else if (isVNode(n2)) {
|
|
3831
|
-
mount(n2, parent, anchor);
|
|
3707
|
+
mount(n2, parent, renderer, anchor);
|
|
3832
3708
|
anchor = n2.elm;
|
|
3833
3709
|
}
|
|
3834
3710
|
}
|
|
@@ -4257,7 +4133,7 @@ function createInlineStyleVNode(content) {
|
|
|
4257
4133
|
}, [api.t(content)]);
|
|
4258
4134
|
}
|
|
4259
4135
|
function updateStylesheetToken(vm, template) {
|
|
4260
|
-
const { elm, context, renderMode, shadowMode } = vm;
|
|
4136
|
+
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
4261
4137
|
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
4262
4138
|
const isSyntheticShadow = renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */;
|
|
4263
4139
|
const { hasScopedStyles } = context;
|
|
@@ -4374,7 +4250,7 @@ function getNearestNativeShadowComponent(vm) {
|
|
|
4374
4250
|
return owner;
|
|
4375
4251
|
}
|
|
4376
4252
|
function createStylesheet(vm, stylesheets) {
|
|
4377
|
-
const { renderMode, shadowMode } = vm;
|
|
4253
|
+
const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
|
|
4378
4254
|
if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
|
|
4379
4255
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
4380
4256
|
insertStylesheet(stylesheets[i]);
|
|
@@ -4936,9 +4812,20 @@ function removeVM(vm) {
|
|
|
4936
4812
|
|
|
4937
4813
|
resetComponentStateWhenRemoved(vm);
|
|
4938
4814
|
}
|
|
4939
|
-
function createVM(elm, ctor, options) {
|
|
4940
|
-
var _a;
|
|
4941
4815
|
|
|
4816
|
+
function getNearestShadowAncestor(vm) {
|
|
4817
|
+
let ancestor = vm.owner;
|
|
4818
|
+
|
|
4819
|
+
while (!isNull(ancestor) && ancestor.renderMode === 0
|
|
4820
|
+
/* Light */
|
|
4821
|
+
) {
|
|
4822
|
+
ancestor = ancestor.owner;
|
|
4823
|
+
}
|
|
4824
|
+
|
|
4825
|
+
return ancestor;
|
|
4826
|
+
}
|
|
4827
|
+
|
|
4828
|
+
function createVM(elm, ctor, renderer, options) {
|
|
4942
4829
|
const {
|
|
4943
4830
|
mode,
|
|
4944
4831
|
owner,
|
|
@@ -4968,8 +4855,6 @@ function createVM(elm, ctor, options) {
|
|
|
4968
4855
|
cmpTemplate: null,
|
|
4969
4856
|
hydrated: Boolean(hydrated),
|
|
4970
4857
|
renderMode: def.renderMode,
|
|
4971
|
-
shadowMode: computeShadowMode(def, owner),
|
|
4972
|
-
nearestShadowMode: (owner === null || owner === void 0 ? void 0 : owner.shadowRoot) ? owner.shadowMode : (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : null,
|
|
4973
4858
|
context: {
|
|
4974
4859
|
stylesheetToken: undefined,
|
|
4975
4860
|
hasTokenInClass: undefined,
|
|
@@ -4982,14 +4867,17 @@ function createVM(elm, ctor, options) {
|
|
|
4982
4867
|
},
|
|
4983
4868
|
// Properties set right after VM creation.
|
|
4984
4869
|
tro: null,
|
|
4870
|
+
shadowMode: null,
|
|
4985
4871
|
// Properties set by the LightningElement constructor.
|
|
4986
4872
|
component: null,
|
|
4987
4873
|
shadowRoot: null,
|
|
4988
4874
|
renderRoot: null,
|
|
4989
4875
|
callHook,
|
|
4990
4876
|
setHook,
|
|
4991
|
-
getHook
|
|
4877
|
+
getHook,
|
|
4878
|
+
renderer
|
|
4992
4879
|
};
|
|
4880
|
+
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
4993
4881
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
4994
4882
|
|
|
4995
4883
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5014,9 +4902,14 @@ function createVM(elm, ctor, options) {
|
|
|
5014
4902
|
return vm;
|
|
5015
4903
|
}
|
|
5016
4904
|
|
|
5017
|
-
function computeShadowMode(
|
|
5018
|
-
|
|
5019
|
-
|
|
4905
|
+
function computeShadowMode(vm, renderer) {
|
|
4906
|
+
const {
|
|
4907
|
+
def
|
|
4908
|
+
} = vm;
|
|
4909
|
+
const {
|
|
4910
|
+
isSyntheticShadowDefined,
|
|
4911
|
+
isNativeShadowDefined
|
|
4912
|
+
} = renderer;
|
|
5020
4913
|
let shadowMode;
|
|
5021
4914
|
|
|
5022
4915
|
if (isSyntheticShadowDefined) {
|
|
@@ -5039,13 +4932,23 @@ function computeShadowMode(def, owner) {
|
|
|
5039
4932
|
/* Native */
|
|
5040
4933
|
;
|
|
5041
4934
|
} else {
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
4935
|
+
const shadowAncestor = getNearestShadowAncestor(vm);
|
|
4936
|
+
|
|
4937
|
+
if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
|
|
4938
|
+
/* Native */
|
|
4939
|
+
) {
|
|
4940
|
+
// Transitive support for native Shadow DOM. A component in native mode
|
|
4941
|
+
// transitively opts all of its descendants into native.
|
|
4942
|
+
shadowMode = 0
|
|
4943
|
+
/* Native */
|
|
4944
|
+
;
|
|
4945
|
+
} else {
|
|
4946
|
+
// Synthetic if neither this component nor any of its ancestors are configured
|
|
4947
|
+
// to be native.
|
|
4948
|
+
shadowMode = 1
|
|
4949
|
+
/* Synthetic */
|
|
4950
|
+
;
|
|
4951
|
+
}
|
|
5049
4952
|
}
|
|
5050
4953
|
} else {
|
|
5051
4954
|
shadowMode = 1
|
|
@@ -5108,7 +5011,8 @@ function rehydrate(vm) {
|
|
|
5108
5011
|
function patchShadowRoot(vm, newCh) {
|
|
5109
5012
|
const {
|
|
5110
5013
|
renderRoot,
|
|
5111
|
-
children: oldCh
|
|
5014
|
+
children: oldCh,
|
|
5015
|
+
renderer
|
|
5112
5016
|
} = vm; // caching the new children collection
|
|
5113
5017
|
|
|
5114
5018
|
vm.children = newCh;
|
|
@@ -5124,7 +5028,7 @@ function patchShadowRoot(vm, newCh) {
|
|
|
5124
5028
|
, vm);
|
|
5125
5029
|
}, () => {
|
|
5126
5030
|
// job
|
|
5127
|
-
patchChildren(oldCh, newCh, renderRoot);
|
|
5031
|
+
patchChildren(oldCh, newCh, renderRoot, renderer);
|
|
5128
5032
|
}, () => {
|
|
5129
5033
|
// post
|
|
5130
5034
|
logOperationEnd(2
|
|
@@ -5149,6 +5053,9 @@ function runRenderedCallback(vm) {
|
|
|
5149
5053
|
const {
|
|
5150
5054
|
def: {
|
|
5151
5055
|
renderedCallback
|
|
5056
|
+
},
|
|
5057
|
+
renderer: {
|
|
5058
|
+
ssr
|
|
5152
5059
|
}
|
|
5153
5060
|
} = vm;
|
|
5154
5061
|
|
|
@@ -5386,7 +5293,10 @@ function recursivelyDisconnectChildren(vnodes) {
|
|
|
5386
5293
|
function resetComponentRoot(vm) {
|
|
5387
5294
|
const {
|
|
5388
5295
|
children,
|
|
5389
|
-
renderRoot
|
|
5296
|
+
renderRoot,
|
|
5297
|
+
renderer: {
|
|
5298
|
+
remove
|
|
5299
|
+
}
|
|
5390
5300
|
} = vm;
|
|
5391
5301
|
|
|
5392
5302
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
@@ -5402,6 +5312,12 @@ function resetComponentRoot(vm) {
|
|
|
5402
5312
|
vm.velements = EmptyArray;
|
|
5403
5313
|
}
|
|
5404
5314
|
function scheduleRehydration(vm) {
|
|
5315
|
+
const {
|
|
5316
|
+
renderer: {
|
|
5317
|
+
ssr
|
|
5318
|
+
}
|
|
5319
|
+
} = vm;
|
|
5320
|
+
|
|
5405
5321
|
if (isTrue(ssr) || isTrue(vm.isScheduled)) {
|
|
5406
5322
|
return;
|
|
5407
5323
|
}
|
|
@@ -5578,6 +5494,9 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
|
5578
5494
|
context: {
|
|
5579
5495
|
wiredConnecting,
|
|
5580
5496
|
wiredDisconnecting
|
|
5497
|
+
},
|
|
5498
|
+
renderer: {
|
|
5499
|
+
dispatchEvent
|
|
5581
5500
|
}
|
|
5582
5501
|
} = vm; // waiting for the component to be connected to formally request the context via the token
|
|
5583
5502
|
|
|
@@ -5849,70 +5768,79 @@ function hydrateRoot(vm) {
|
|
|
5849
5768
|
function hydrateVM(vm) {
|
|
5850
5769
|
const children = renderComponent(vm);
|
|
5851
5770
|
vm.children = children;
|
|
5852
|
-
const parentNode = vm
|
|
5771
|
+
const { renderRoot: parentNode, renderer: { getFirstChild }, } = vm;
|
|
5853
5772
|
hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
|
|
5854
5773
|
runRenderedCallback(vm);
|
|
5855
5774
|
}
|
|
5856
|
-
function hydrateNode(node, vnode) {
|
|
5775
|
+
function hydrateNode(node, vnode, renderer) {
|
|
5776
|
+
var _a, _b;
|
|
5857
5777
|
let hydratedNode;
|
|
5858
5778
|
switch (vnode.type) {
|
|
5859
5779
|
case 0 /* Text */:
|
|
5860
|
-
|
|
5780
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
5781
|
+
hydratedNode = hydrateText(node, vnode, renderer);
|
|
5861
5782
|
break;
|
|
5862
5783
|
case 1 /* Comment */:
|
|
5863
|
-
|
|
5784
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
5785
|
+
hydratedNode = hydrateComment(node, vnode, renderer);
|
|
5864
5786
|
break;
|
|
5865
5787
|
case 2 /* Element */:
|
|
5866
|
-
hydratedNode = hydrateElement(node, vnode);
|
|
5788
|
+
hydratedNode = hydrateElement(node, vnode, (_a = vnode.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
5867
5789
|
break;
|
|
5868
5790
|
case 3 /* CustomElement */:
|
|
5869
|
-
hydratedNode = hydrateCustomElement(node, vnode);
|
|
5791
|
+
hydratedNode = hydrateCustomElement(node, vnode, (_b = vnode.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
5870
5792
|
break;
|
|
5871
5793
|
}
|
|
5872
|
-
return nextSibling(hydratedNode);
|
|
5794
|
+
return renderer.nextSibling(hydratedNode);
|
|
5873
5795
|
}
|
|
5874
|
-
function hydrateText(node, vnode) {
|
|
5796
|
+
function hydrateText(node, vnode, renderer) {
|
|
5875
5797
|
var _a;
|
|
5876
|
-
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT
|
|
5877
|
-
return handleMismatch(node, vnode);
|
|
5798
|
+
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */, renderer)) {
|
|
5799
|
+
return handleMismatch(node, vnode, renderer);
|
|
5878
5800
|
}
|
|
5879
5801
|
if (process.env.NODE_ENV !== 'production') {
|
|
5802
|
+
const { getProperty } = renderer;
|
|
5880
5803
|
const nodeValue = getProperty(node, 'nodeValue');
|
|
5881
5804
|
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
5882
5805
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
5883
5806
|
}
|
|
5884
5807
|
}
|
|
5808
|
+
const { setText } = renderer;
|
|
5885
5809
|
setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5886
5810
|
vnode.elm = node;
|
|
5887
5811
|
return node;
|
|
5888
5812
|
}
|
|
5889
|
-
function hydrateComment(node, vnode) {
|
|
5813
|
+
function hydrateComment(node, vnode, renderer) {
|
|
5890
5814
|
var _a;
|
|
5891
|
-
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT
|
|
5892
|
-
return handleMismatch(node, vnode);
|
|
5815
|
+
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */, renderer)) {
|
|
5816
|
+
return handleMismatch(node, vnode, renderer);
|
|
5893
5817
|
}
|
|
5894
5818
|
if (process.env.NODE_ENV !== 'production') {
|
|
5819
|
+
const { getProperty } = renderer;
|
|
5895
5820
|
const nodeValue = getProperty(node, 'nodeValue');
|
|
5896
5821
|
if (nodeValue !== vnode.text) {
|
|
5897
5822
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
5898
5823
|
}
|
|
5899
5824
|
}
|
|
5825
|
+
const { setProperty } = renderer;
|
|
5900
5826
|
setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5901
5827
|
vnode.elm = node;
|
|
5902
5828
|
return node;
|
|
5903
5829
|
}
|
|
5904
|
-
function hydrateElement(elm, vnode) {
|
|
5905
|
-
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT
|
|
5906
|
-
!isMatchingElement(vnode, elm)) {
|
|
5907
|
-
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);
|
|
5908
5834
|
}
|
|
5909
5835
|
vnode.elm = elm;
|
|
5836
|
+
const { owner } = vnode;
|
|
5910
5837
|
const { context } = vnode.data;
|
|
5911
5838
|
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual" /* Manual */);
|
|
5912
5839
|
if (isDomManual) {
|
|
5913
5840
|
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
5914
5841
|
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
5915
|
-
const { props } = vnode
|
|
5842
|
+
const { data: { props }, } = vnode;
|
|
5843
|
+
const { getProperty } = renderer;
|
|
5916
5844
|
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
5917
5845
|
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
5918
5846
|
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
@@ -5920,24 +5848,25 @@ function hydrateElement(elm, vnode) {
|
|
|
5920
5848
|
}
|
|
5921
5849
|
else {
|
|
5922
5850
|
if (process.env.NODE_ENV !== 'production') {
|
|
5923
|
-
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);
|
|
5924
5852
|
}
|
|
5925
5853
|
}
|
|
5926
5854
|
}
|
|
5927
5855
|
}
|
|
5928
|
-
patchElementPropsAndAttrs(vnode);
|
|
5856
|
+
patchElementPropsAndAttrs(vnode, renderer);
|
|
5929
5857
|
if (!isDomManual) {
|
|
5930
|
-
|
|
5858
|
+
const { getFirstChild } = renderer;
|
|
5859
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, owner);
|
|
5931
5860
|
}
|
|
5932
5861
|
return elm;
|
|
5933
5862
|
}
|
|
5934
|
-
function hydrateCustomElement(elm, vnode) {
|
|
5935
|
-
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT
|
|
5936
|
-
!isMatchingElement(vnode, elm)) {
|
|
5937
|
-
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);
|
|
5938
5867
|
}
|
|
5939
5868
|
const { sel, mode, ctor, owner } = vnode;
|
|
5940
|
-
const vm = createVM(elm, ctor, {
|
|
5869
|
+
const vm = createVM(elm, ctor, renderer, {
|
|
5941
5870
|
mode,
|
|
5942
5871
|
owner,
|
|
5943
5872
|
tagName: sel,
|
|
@@ -5946,13 +5875,14 @@ function hydrateCustomElement(elm, vnode) {
|
|
|
5946
5875
|
vnode.elm = elm;
|
|
5947
5876
|
vnode.vm = vm;
|
|
5948
5877
|
allocateChildren(vnode, vm);
|
|
5949
|
-
patchElementPropsAndAttrs(vnode);
|
|
5878
|
+
patchElementPropsAndAttrs(vnode, renderer);
|
|
5950
5879
|
// Insert hook section:
|
|
5951
5880
|
if (process.env.NODE_ENV !== 'production') {
|
|
5952
5881
|
assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
5953
5882
|
}
|
|
5954
5883
|
runConnectedCallback(vm);
|
|
5955
5884
|
if (vm.renderMode !== 0 /* Light */) {
|
|
5885
|
+
const { getFirstChild } = renderer;
|
|
5956
5886
|
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
5957
5887
|
// Note: for Light DOM, this is handled while hydrating the VM
|
|
5958
5888
|
hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
|
|
@@ -5964,11 +5894,12 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
5964
5894
|
let hasWarned = false;
|
|
5965
5895
|
let nextNode = node;
|
|
5966
5896
|
let anchor = null;
|
|
5897
|
+
const { renderer } = owner;
|
|
5967
5898
|
for (let i = 0; i < children.length; i++) {
|
|
5968
5899
|
const childVnode = children[i];
|
|
5969
5900
|
if (!isNull(childVnode)) {
|
|
5970
5901
|
if (nextNode) {
|
|
5971
|
-
nextNode = hydrateNode(nextNode, childVnode);
|
|
5902
|
+
nextNode = hydrateNode(nextNode, childVnode, renderer);
|
|
5972
5903
|
anchor = childVnode.elm;
|
|
5973
5904
|
}
|
|
5974
5905
|
else {
|
|
@@ -5979,7 +5910,7 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
5979
5910
|
logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
|
|
5980
5911
|
}
|
|
5981
5912
|
}
|
|
5982
|
-
mount(childVnode, parentNode, anchor);
|
|
5913
|
+
mount(childVnode, parentNode, renderer, anchor);
|
|
5983
5914
|
anchor = childVnode.elm;
|
|
5984
5915
|
}
|
|
5985
5916
|
}
|
|
@@ -5991,30 +5922,32 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
5991
5922
|
logError(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
|
|
5992
5923
|
}
|
|
5993
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;
|
|
5994
5930
|
do {
|
|
5995
5931
|
const current = nextNode;
|
|
5996
5932
|
nextNode = nextSibling(nextNode);
|
|
5997
|
-
removeNode(current, parentNode);
|
|
5933
|
+
removeNode(current, parentNode, renderer);
|
|
5998
5934
|
} while (nextNode);
|
|
5999
5935
|
}
|
|
6000
5936
|
}
|
|
6001
|
-
function handleMismatch(node, vnode,
|
|
5937
|
+
function handleMismatch(node, vnode, renderer) {
|
|
6002
5938
|
hasMismatch = true;
|
|
6003
|
-
|
|
6004
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6005
|
-
logError(msg, vnode.owner);
|
|
6006
|
-
}
|
|
6007
|
-
}
|
|
5939
|
+
const { getProperty } = renderer;
|
|
6008
5940
|
const parentNode = getProperty(node, 'parentNode');
|
|
6009
|
-
mount(vnode, parentNode, node);
|
|
6010
|
-
removeNode(node, parentNode);
|
|
5941
|
+
mount(vnode, parentNode, renderer, node);
|
|
5942
|
+
removeNode(node, parentNode, renderer);
|
|
6011
5943
|
return vnode.elm;
|
|
6012
5944
|
}
|
|
6013
|
-
function patchElementPropsAndAttrs(vnode) {
|
|
6014
|
-
applyEventListeners(vnode);
|
|
6015
|
-
patchProps(null, vnode);
|
|
5945
|
+
function patchElementPropsAndAttrs(vnode, renderer) {
|
|
5946
|
+
applyEventListeners(vnode, renderer);
|
|
5947
|
+
patchProps(null, vnode, renderer);
|
|
6016
5948
|
}
|
|
6017
|
-
function hasCorrectNodeType(vnode, node, nodeType) {
|
|
5949
|
+
function hasCorrectNodeType(vnode, node, nodeType, renderer) {
|
|
5950
|
+
const { getProperty } = renderer;
|
|
6018
5951
|
if (getProperty(node, 'nodeType') !== nodeType) {
|
|
6019
5952
|
if (process.env.NODE_ENV !== 'production') {
|
|
6020
5953
|
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
@@ -6023,36 +5956,41 @@ function hasCorrectNodeType(vnode, node, nodeType) {
|
|
|
6023
5956
|
}
|
|
6024
5957
|
return true;
|
|
6025
5958
|
}
|
|
6026
|
-
function isMatchingElement(vnode, elm) {
|
|
5959
|
+
function isMatchingElement(vnode, elm, renderer) {
|
|
5960
|
+
const { getProperty } = renderer;
|
|
6027
5961
|
if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
|
|
6028
5962
|
if (process.env.NODE_ENV !== 'production') {
|
|
6029
5963
|
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
6030
5964
|
}
|
|
6031
5965
|
return false;
|
|
6032
5966
|
}
|
|
6033
|
-
const hasIncompatibleAttrs = validateAttrs(vnode, elm);
|
|
6034
|
-
const hasIncompatibleClass = validateClassAttr(vnode, elm);
|
|
6035
|
-
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);
|
|
6036
5970
|
return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
6037
5971
|
}
|
|
6038
|
-
function validateAttrs(vnode, elm) {
|
|
5972
|
+
function validateAttrs(vnode, elm, renderer) {
|
|
6039
5973
|
const { data: { attrs = {} }, } = vnode;
|
|
6040
5974
|
let nodesAreCompatible = true;
|
|
6041
5975
|
// Validate attributes, though we could always recovery from those by running the update mods.
|
|
6042
5976
|
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
6043
5977
|
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
5978
|
+
const { owner } = vnode;
|
|
5979
|
+
const { getAttribute } = renderer;
|
|
6044
5980
|
const elmAttrValue = getAttribute(elm, attrName);
|
|
6045
5981
|
if (String(attrValue) !== elmAttrValue) {
|
|
6046
5982
|
if (process.env.NODE_ENV !== 'production') {
|
|
6047
|
-
|
|
5983
|
+
const { getProperty } = renderer;
|
|
5984
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, owner);
|
|
6048
5985
|
}
|
|
6049
5986
|
nodesAreCompatible = false;
|
|
6050
5987
|
}
|
|
6051
5988
|
}
|
|
6052
5989
|
return nodesAreCompatible;
|
|
6053
5990
|
}
|
|
6054
|
-
function validateClassAttr(vnode, elm) {
|
|
5991
|
+
function validateClassAttr(vnode, elm, renderer) {
|
|
6055
5992
|
const { data: { className, classMap }, } = vnode;
|
|
5993
|
+
const { getProperty, getClassList } = renderer;
|
|
6056
5994
|
let nodesAreCompatible = true;
|
|
6057
5995
|
let vnodeClassName;
|
|
6058
5996
|
if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
|
|
@@ -6083,8 +6021,9 @@ function validateClassAttr(vnode, elm) {
|
|
|
6083
6021
|
}
|
|
6084
6022
|
return nodesAreCompatible;
|
|
6085
6023
|
}
|
|
6086
|
-
function validateStyleAttr(vnode, elm) {
|
|
6024
|
+
function validateStyleAttr(vnode, elm, renderer) {
|
|
6087
6025
|
const { data: { style, styleDecls }, } = vnode;
|
|
6026
|
+
const { getAttribute } = renderer;
|
|
6088
6027
|
const elmStyle = getAttribute(elm, 'style') || '';
|
|
6089
6028
|
let vnodeStyle;
|
|
6090
6029
|
let nodesAreCompatible = true;
|
|
@@ -6117,6 +6056,7 @@ function validateStyleAttr(vnode, elm) {
|
|
|
6117
6056
|
}
|
|
6118
6057
|
if (!nodesAreCompatible) {
|
|
6119
6058
|
if (process.env.NODE_ENV !== 'production') {
|
|
6059
|
+
const { getProperty } = renderer;
|
|
6120
6060
|
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
6121
6061
|
}
|
|
6122
6062
|
}
|
|
@@ -6258,5 +6198,5 @@ function getComponentConstructor(elm) {
|
|
|
6258
6198
|
return ctor;
|
|
6259
6199
|
}
|
|
6260
6200
|
|
|
6261
|
-
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,
|
|
6262
|
-
/* version: 2.
|
|
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 */
|