@lwc/engine-core 2.14.0 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-core.cjs.js +486 -450
- package/dist/engine-core.js +486 -413
- package/package.json +3 -3
- package/types/framework/api.d.ts +3 -1
- package/types/framework/main.d.ts +1 -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 +48 -0
- package/types/framework/rendering.d.ts +4 -3
- package/types/framework/stylesheet.d.ts +1 -1
- package/types/framework/template.d.ts +2 -0
- package/types/framework/upgradable-element.d.ts +2 -1
- package/types/framework/vm.d.ts +8 -8
- package/types/framework/vnodes.d.ts +12 -3
- package/types/renderer.d.ts +0 -119
package/dist/engine-core.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* proxy-compat-disable */
|
|
2
2
|
import { runtimeFlags } from '@lwc/features';
|
|
3
3
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
4
|
-
import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_RESOLVER, isArray as isArray$1, isNumber, StringReplace, KEY__SCOPED_CSS, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
|
|
4
|
+
import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, isArray as isArray$1, isNumber, StringReplace, ArrayMap, KEY__SCOPED_CSS, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -109,164 +109,6 @@ function flattenStylesheets(stylesheets) {
|
|
|
109
109
|
return list;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
//
|
|
113
|
-
// Primitives
|
|
114
|
-
//
|
|
115
|
-
let ssr;
|
|
116
|
-
function setSsr(ssrImpl) {
|
|
117
|
-
ssr = ssrImpl;
|
|
118
|
-
}
|
|
119
|
-
let isNativeShadowDefined;
|
|
120
|
-
function setIsNativeShadowDefined(isNativeShadowDefinedImpl) {
|
|
121
|
-
isNativeShadowDefined = isNativeShadowDefinedImpl;
|
|
122
|
-
}
|
|
123
|
-
let isSyntheticShadowDefined;
|
|
124
|
-
function setIsSyntheticShadowDefined(isSyntheticShadowDefinedImpl) {
|
|
125
|
-
isSyntheticShadowDefined = isSyntheticShadowDefinedImpl;
|
|
126
|
-
}
|
|
127
|
-
let HTMLElementExported;
|
|
128
|
-
function setHTMLElement(HTMLElementImpl) {
|
|
129
|
-
HTMLElementExported = HTMLElementImpl;
|
|
130
|
-
}
|
|
131
|
-
function setIsHydrating(isHydratingImpl) {
|
|
132
|
-
}
|
|
133
|
-
let insert;
|
|
134
|
-
function setInsert(insertImpl) {
|
|
135
|
-
insert = insertImpl;
|
|
136
|
-
}
|
|
137
|
-
let remove;
|
|
138
|
-
function setRemove(removeImpl) {
|
|
139
|
-
remove = removeImpl;
|
|
140
|
-
}
|
|
141
|
-
let createElement;
|
|
142
|
-
function setCreateElement(createElementImpl) {
|
|
143
|
-
createElement = createElementImpl;
|
|
144
|
-
}
|
|
145
|
-
let createText;
|
|
146
|
-
function setCreateText(createTextImpl) {
|
|
147
|
-
createText = createTextImpl;
|
|
148
|
-
}
|
|
149
|
-
let createComment;
|
|
150
|
-
function setCreateComment(createCommentImpl) {
|
|
151
|
-
createComment = createCommentImpl;
|
|
152
|
-
}
|
|
153
|
-
let nextSibling;
|
|
154
|
-
function setNextSibling(nextSiblingImpl) {
|
|
155
|
-
nextSibling = nextSiblingImpl;
|
|
156
|
-
}
|
|
157
|
-
let attachShadow;
|
|
158
|
-
function setAttachShadow(attachShadowImpl) {
|
|
159
|
-
attachShadow = attachShadowImpl;
|
|
160
|
-
}
|
|
161
|
-
let getProperty;
|
|
162
|
-
function setGetProperty(getPropertyImpl) {
|
|
163
|
-
getProperty = getPropertyImpl;
|
|
164
|
-
}
|
|
165
|
-
let setProperty;
|
|
166
|
-
function setSetProperty(setPropertyImpl) {
|
|
167
|
-
setProperty = setPropertyImpl;
|
|
168
|
-
}
|
|
169
|
-
let setText;
|
|
170
|
-
function setSetText(setTextImpl) {
|
|
171
|
-
setText = setTextImpl;
|
|
172
|
-
}
|
|
173
|
-
let getAttribute;
|
|
174
|
-
function setGetAttribute(getAttributeImpl) {
|
|
175
|
-
getAttribute = getAttributeImpl;
|
|
176
|
-
}
|
|
177
|
-
let setAttribute;
|
|
178
|
-
function setSetAttribute(setAttributeImpl) {
|
|
179
|
-
setAttribute = setAttributeImpl;
|
|
180
|
-
}
|
|
181
|
-
let removeAttribute;
|
|
182
|
-
function setRemoveAttribute(removeAttributeImpl) {
|
|
183
|
-
removeAttribute = removeAttributeImpl;
|
|
184
|
-
}
|
|
185
|
-
let addEventListener;
|
|
186
|
-
function setAddEventListener(addEventListenerImpl) {
|
|
187
|
-
addEventListener = addEventListenerImpl;
|
|
188
|
-
}
|
|
189
|
-
let removeEventListener;
|
|
190
|
-
function setRemoveEventListener(removeEventListenerImpl) {
|
|
191
|
-
removeEventListener = removeEventListenerImpl;
|
|
192
|
-
}
|
|
193
|
-
let dispatchEvent;
|
|
194
|
-
function setDispatchEvent(dispatchEventImpl) {
|
|
195
|
-
dispatchEvent = dispatchEventImpl;
|
|
196
|
-
}
|
|
197
|
-
let getClassList;
|
|
198
|
-
function setGetClassList(getClassListImpl) {
|
|
199
|
-
getClassList = getClassListImpl;
|
|
200
|
-
}
|
|
201
|
-
let setCSSStyleProperty;
|
|
202
|
-
function setSetCSSStyleProperty(setCSSStylePropertyImpl) {
|
|
203
|
-
setCSSStyleProperty = setCSSStylePropertyImpl;
|
|
204
|
-
}
|
|
205
|
-
let getBoundingClientRect;
|
|
206
|
-
function setGetBoundingClientRect(getBoundingClientRectImpl) {
|
|
207
|
-
getBoundingClientRect = getBoundingClientRectImpl;
|
|
208
|
-
}
|
|
209
|
-
let querySelector;
|
|
210
|
-
function setQuerySelector(querySelectorImpl) {
|
|
211
|
-
querySelector = querySelectorImpl;
|
|
212
|
-
}
|
|
213
|
-
let querySelectorAll;
|
|
214
|
-
function setQuerySelectorAll(querySelectorAllImpl) {
|
|
215
|
-
querySelectorAll = querySelectorAllImpl;
|
|
216
|
-
}
|
|
217
|
-
let getElementsByTagName;
|
|
218
|
-
function setGetElementsByTagName(getElementsByTagNameImpl) {
|
|
219
|
-
getElementsByTagName = getElementsByTagNameImpl;
|
|
220
|
-
}
|
|
221
|
-
let getElementsByClassName;
|
|
222
|
-
function setGetElementsByClassName(getElementsByClassNameImpl) {
|
|
223
|
-
getElementsByClassName = getElementsByClassNameImpl;
|
|
224
|
-
}
|
|
225
|
-
let getChildren;
|
|
226
|
-
function setGetChildren(getChildrenImpl) {
|
|
227
|
-
getChildren = getChildrenImpl;
|
|
228
|
-
}
|
|
229
|
-
let getChildNodes;
|
|
230
|
-
function setGetChildNodes(getChildNodesImpl) {
|
|
231
|
-
getChildNodes = getChildNodesImpl;
|
|
232
|
-
}
|
|
233
|
-
let getFirstChild;
|
|
234
|
-
function setGetFirstChild(getFirstChildImpl) {
|
|
235
|
-
getFirstChild = getFirstChildImpl;
|
|
236
|
-
}
|
|
237
|
-
let getFirstElementChild;
|
|
238
|
-
function setGetFirstElementChild(getFirstElementChildImpl) {
|
|
239
|
-
getFirstElementChild = getFirstElementChildImpl;
|
|
240
|
-
}
|
|
241
|
-
let getLastChild;
|
|
242
|
-
function setGetLastChild(getLastChildImpl) {
|
|
243
|
-
getLastChild = getLastChildImpl;
|
|
244
|
-
}
|
|
245
|
-
let getLastElementChild;
|
|
246
|
-
function setGetLastElementChild(getLastElementChildImpl) {
|
|
247
|
-
getLastElementChild = getLastElementChildImpl;
|
|
248
|
-
}
|
|
249
|
-
let isConnected;
|
|
250
|
-
function setIsConnected(isConnectedImpl) {
|
|
251
|
-
isConnected = isConnectedImpl;
|
|
252
|
-
}
|
|
253
|
-
let insertStylesheet;
|
|
254
|
-
function setInsertStylesheet(insertStylesheetImpl) {
|
|
255
|
-
insertStylesheet = insertStylesheetImpl;
|
|
256
|
-
}
|
|
257
|
-
let assertInstanceOfHTMLElement;
|
|
258
|
-
function setAssertInstanceOfHTMLElement(assertInstanceOfHTMLElementImpl) {
|
|
259
|
-
assertInstanceOfHTMLElement = assertInstanceOfHTMLElementImpl;
|
|
260
|
-
}
|
|
261
|
-
let defineCustomElement;
|
|
262
|
-
function setDefineCustomElement(defineCustomElementImpl) {
|
|
263
|
-
defineCustomElement = defineCustomElementImpl;
|
|
264
|
-
}
|
|
265
|
-
let getCustomElement;
|
|
266
|
-
function setGetCustomElement(getCustomElementImpl) {
|
|
267
|
-
getCustomElement = getCustomElementImpl;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
112
|
/*
|
|
271
113
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
272
114
|
* All rights reserved.
|
|
@@ -1571,6 +1413,7 @@ const LightningElement = function () {
|
|
|
1571
1413
|
const { def, elm } = vm;
|
|
1572
1414
|
const { bridge } = def;
|
|
1573
1415
|
if (process.env.NODE_ENV !== 'production') {
|
|
1416
|
+
const { assertInstanceOfHTMLElement } = vm.renderer;
|
|
1574
1417
|
assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
|
|
1575
1418
|
}
|
|
1576
1419
|
const component = this;
|
|
@@ -1605,7 +1448,7 @@ const LightningElement = function () {
|
|
|
1605
1448
|
return this;
|
|
1606
1449
|
};
|
|
1607
1450
|
function doAttachShadow(vm) {
|
|
1608
|
-
const { elm, mode, shadowMode, def: { ctor }, } = vm;
|
|
1451
|
+
const { elm, mode, shadowMode, def: { ctor }, renderer: { attachShadow }, } = vm;
|
|
1609
1452
|
const shadowRoot = attachShadow(elm, {
|
|
1610
1453
|
[KEY__SYNTHETIC_MODE]: shadowMode === 1 /* Synthetic */,
|
|
1611
1454
|
delegatesFocus: Boolean(ctor.delegatesFocus),
|
|
@@ -1627,12 +1470,13 @@ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
|
1627
1470
|
LightningElement.prototype = {
|
|
1628
1471
|
constructor: LightningElement,
|
|
1629
1472
|
dispatchEvent(event) {
|
|
1630
|
-
const
|
|
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,115 @@ 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);
|
|
3181
|
+
break;
|
|
3182
|
+
case 4 /* Static */:
|
|
3183
|
+
n2.elm = n1.elm;
|
|
3323
3184
|
break;
|
|
3324
3185
|
case 2 /* Element */:
|
|
3325
|
-
patchElement(n1, n2);
|
|
3186
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3326
3187
|
break;
|
|
3327
3188
|
case 3 /* CustomElement */:
|
|
3328
|
-
patchCustomElement(n1, n2);
|
|
3189
|
+
patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3329
3190
|
break;
|
|
3330
3191
|
}
|
|
3331
3192
|
}
|
|
3332
|
-
function mount(node, parent, anchor) {
|
|
3193
|
+
function mount(node, parent, renderer, anchor) {
|
|
3194
|
+
var _a, _b;
|
|
3333
3195
|
switch (node.type) {
|
|
3334
3196
|
case 0 /* Text */:
|
|
3335
|
-
|
|
3197
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3198
|
+
mountText(node, parent, anchor, renderer);
|
|
3336
3199
|
break;
|
|
3337
3200
|
case 1 /* Comment */:
|
|
3338
|
-
|
|
3201
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3202
|
+
mountComment(node, parent, anchor, renderer);
|
|
3203
|
+
break;
|
|
3204
|
+
case 4 /* Static */:
|
|
3205
|
+
// VStatic cannot have a custom renderer associated to them, using owner's renderer
|
|
3206
|
+
mountStatic(node, parent, anchor, renderer);
|
|
3339
3207
|
break;
|
|
3340
3208
|
case 2 /* Element */:
|
|
3341
|
-
|
|
3209
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3210
|
+
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3342
3211
|
break;
|
|
3343
3212
|
case 3 /* CustomElement */:
|
|
3344
|
-
|
|
3213
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3214
|
+
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3345
3215
|
break;
|
|
3346
3216
|
}
|
|
3347
3217
|
}
|
|
3348
|
-
function patchText(n1, n2) {
|
|
3218
|
+
function patchText(n1, n2, renderer) {
|
|
3349
3219
|
n2.elm = n1.elm;
|
|
3350
3220
|
if (n2.text !== n1.text) {
|
|
3351
|
-
updateTextContent(n2);
|
|
3221
|
+
updateTextContent(n2, renderer);
|
|
3352
3222
|
}
|
|
3353
3223
|
}
|
|
3354
|
-
function mountText(
|
|
3355
|
-
const { owner } =
|
|
3356
|
-
const
|
|
3357
|
-
|
|
3358
|
-
|
|
3224
|
+
function mountText(vnode, parent, anchor, renderer) {
|
|
3225
|
+
const { owner } = vnode;
|
|
3226
|
+
const { createText } = renderer;
|
|
3227
|
+
const textNode = (vnode.elm = createText(vnode.text));
|
|
3228
|
+
linkNodeToShadow(textNode, owner, renderer);
|
|
3229
|
+
insertNode(textNode, parent, anchor, renderer);
|
|
3359
3230
|
}
|
|
3360
|
-
function patchComment(n1, n2) {
|
|
3231
|
+
function patchComment(n1, n2, renderer) {
|
|
3361
3232
|
n2.elm = n1.elm;
|
|
3362
3233
|
// FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3363
3234
|
// it is the case today.
|
|
3364
3235
|
if (n2.text !== n1.text) {
|
|
3365
|
-
updateTextContent(n2);
|
|
3236
|
+
updateTextContent(n2, renderer);
|
|
3366
3237
|
}
|
|
3367
3238
|
}
|
|
3368
|
-
function mountComment(
|
|
3369
|
-
const { owner } =
|
|
3370
|
-
const
|
|
3371
|
-
|
|
3372
|
-
|
|
3239
|
+
function mountComment(vnode, parent, anchor, renderer) {
|
|
3240
|
+
const { owner } = vnode;
|
|
3241
|
+
const { createComment } = renderer;
|
|
3242
|
+
const commentNode = (vnode.elm = createComment(vnode.text));
|
|
3243
|
+
linkNodeToShadow(commentNode, owner, renderer);
|
|
3244
|
+
insertNode(commentNode, parent, anchor, renderer);
|
|
3373
3245
|
}
|
|
3374
|
-
function mountElement(vnode, parent, anchor) {
|
|
3246
|
+
function mountElement(vnode, parent, anchor, renderer) {
|
|
3375
3247
|
const { sel, owner, data: { svg }, } = vnode;
|
|
3248
|
+
const { createElement } = renderer;
|
|
3376
3249
|
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
3377
3250
|
const elm = createElement(sel, namespace);
|
|
3378
|
-
linkNodeToShadow(elm, owner);
|
|
3379
|
-
fallbackElmHook(elm, vnode);
|
|
3251
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3252
|
+
fallbackElmHook(elm, vnode, renderer);
|
|
3380
3253
|
vnode.elm = elm;
|
|
3381
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
3382
|
-
insertNode(elm, parent, anchor);
|
|
3383
|
-
mountVNodes(vnode.children, elm, null);
|
|
3254
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3255
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3256
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3384
3257
|
}
|
|
3385
|
-
function patchElement(n1, n2) {
|
|
3258
|
+
function patchElement(n1, n2, renderer) {
|
|
3386
3259
|
const elm = (n2.elm = n1.elm);
|
|
3387
|
-
patchElementPropsAndAttrs$1(n1, n2);
|
|
3388
|
-
patchChildren(n1.children, n2.children, elm);
|
|
3260
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3261
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3262
|
+
}
|
|
3263
|
+
function mountStatic(vnode, parent, anchor, renderer) {
|
|
3264
|
+
const { owner } = vnode;
|
|
3265
|
+
const { cloneNode, isSyntheticShadowDefined } = renderer;
|
|
3266
|
+
const elm = (vnode.elm = cloneNode(vnode.fragment, true));
|
|
3267
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3268
|
+
// Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
3269
|
+
const { renderMode, shadowMode } = owner;
|
|
3270
|
+
if (isSyntheticShadowDefined) {
|
|
3271
|
+
if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
|
|
3272
|
+
elm[KEY__SHADOW_STATIC] = true;
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3276
|
+
const isLight = renderMode === 0 /* Light */;
|
|
3277
|
+
patchElementWithRestrictions(elm, { isPortal: false, isLight });
|
|
3278
|
+
}
|
|
3279
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3389
3280
|
}
|
|
3390
|
-
function mountCustomElement(vnode, parent, anchor) {
|
|
3281
|
+
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3391
3282
|
const { sel, owner } = vnode;
|
|
3392
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
3283
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
3393
3284
|
/**
|
|
3394
3285
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3395
3286
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -3399,9 +3290,9 @@ function mountCustomElement(vnode, parent, anchor) {
|
|
|
3399
3290
|
let vm;
|
|
3400
3291
|
const elm = new UpgradableConstructor((elm) => {
|
|
3401
3292
|
// the custom element from the registry is expecting an upgrade callback
|
|
3402
|
-
vm = createViewModelHook(elm, vnode);
|
|
3293
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
3403
3294
|
});
|
|
3404
|
-
linkNodeToShadow(elm, owner);
|
|
3295
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3405
3296
|
vnode.elm = elm;
|
|
3406
3297
|
vnode.vm = vm;
|
|
3407
3298
|
if (vm) {
|
|
@@ -3410,23 +3301,23 @@ function mountCustomElement(vnode, parent, anchor) {
|
|
|
3410
3301
|
else if (vnode.ctor !== UpgradableConstructor) {
|
|
3411
3302
|
throw new TypeError(`Incorrect Component Constructor`);
|
|
3412
3303
|
}
|
|
3413
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
3414
|
-
insertNode(elm, parent, anchor);
|
|
3304
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3305
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3415
3306
|
if (vm) {
|
|
3416
3307
|
if (process.env.NODE_ENV !== 'production') {
|
|
3417
3308
|
assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
3418
3309
|
}
|
|
3419
3310
|
runConnectedCallback(vm);
|
|
3420
3311
|
}
|
|
3421
|
-
mountVNodes(vnode.children, elm, null);
|
|
3312
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3422
3313
|
if (vm) {
|
|
3423
3314
|
appendVM(vm);
|
|
3424
3315
|
}
|
|
3425
3316
|
}
|
|
3426
|
-
function patchCustomElement(n1, n2) {
|
|
3317
|
+
function patchCustomElement(n1, n2, renderer) {
|
|
3427
3318
|
const elm = (n2.elm = n1.elm);
|
|
3428
3319
|
const vm = (n2.vm = n1.vm);
|
|
3429
|
-
patchElementPropsAndAttrs$1(n1, n2);
|
|
3320
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3430
3321
|
if (!isUndefined$1(vm)) {
|
|
3431
3322
|
// in fallback mode, the allocation will always set children to
|
|
3432
3323
|
// empty and delegate the real allocation to the slot elements
|
|
@@ -3434,33 +3325,38 @@ function patchCustomElement(n1, n2) {
|
|
|
3434
3325
|
}
|
|
3435
3326
|
// in fallback mode, the children will be always empty, so, nothing
|
|
3436
3327
|
// will happen, but in native, it does allocate the light dom
|
|
3437
|
-
patchChildren(n1.children, n2.children, elm);
|
|
3328
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3438
3329
|
if (!isUndefined$1(vm)) {
|
|
3439
3330
|
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
3440
3331
|
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
3441
3332
|
rerenderVM(vm);
|
|
3442
3333
|
}
|
|
3443
3334
|
}
|
|
3444
|
-
function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
|
|
3335
|
+
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
3445
3336
|
for (; start < end; ++start) {
|
|
3446
3337
|
const vnode = vnodes[start];
|
|
3447
3338
|
if (isVNode(vnode)) {
|
|
3448
|
-
mount(vnode, parent, anchor);
|
|
3339
|
+
mount(vnode, parent, renderer, anchor);
|
|
3449
3340
|
}
|
|
3450
3341
|
}
|
|
3451
3342
|
}
|
|
3452
|
-
function unmount(vnode, parent, doRemove = false) {
|
|
3343
|
+
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
3453
3344
|
const { type, elm, sel } = vnode;
|
|
3454
3345
|
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
3455
3346
|
// subtree root, is the only element worth unmounting from the subtree.
|
|
3456
3347
|
if (doRemove) {
|
|
3457
|
-
|
|
3348
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
3349
|
+
// but the removal used here is from the owner instead.
|
|
3350
|
+
removeNode(elm, parent, renderer);
|
|
3458
3351
|
}
|
|
3459
|
-
const removeChildren = sel === 'slot'; // slot content is removed to trigger slotchange event when removing slot
|
|
3460
3352
|
switch (type) {
|
|
3461
|
-
case 2 /* Element */:
|
|
3462
|
-
|
|
3353
|
+
case 2 /* Element */: {
|
|
3354
|
+
// Slot content is removed to trigger slotchange event when removing slot.
|
|
3355
|
+
// Only required for synthetic shadow.
|
|
3356
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
|
|
3357
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
3463
3358
|
break;
|
|
3359
|
+
}
|
|
3464
3360
|
case 3 /* CustomElement */: {
|
|
3465
3361
|
const { vm } = vnode;
|
|
3466
3362
|
// No need to unmount the children here, `removeVM` will take care of removing the
|
|
@@ -3471,11 +3367,11 @@ function unmount(vnode, parent, doRemove = false) {
|
|
|
3471
3367
|
}
|
|
3472
3368
|
}
|
|
3473
3369
|
}
|
|
3474
|
-
function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
|
|
3370
|
+
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
3475
3371
|
for (; start < end; ++start) {
|
|
3476
3372
|
const ch = vnodes[start];
|
|
3477
3373
|
if (isVNode(ch)) {
|
|
3478
|
-
unmount(ch, parent, doRemove);
|
|
3374
|
+
unmount(ch, parent, renderer, doRemove);
|
|
3479
3375
|
}
|
|
3480
3376
|
}
|
|
3481
3377
|
}
|
|
@@ -3489,15 +3385,19 @@ function setElementShadowToken(elm, token) {
|
|
|
3489
3385
|
elm.$shadowToken$ = token;
|
|
3490
3386
|
}
|
|
3491
3387
|
// Set the scope token class for *.scoped.css styles
|
|
3492
|
-
function setScopeTokenClassIfNecessary(elm, owner) {
|
|
3388
|
+
function setScopeTokenClassIfNecessary(elm, owner, renderer) {
|
|
3493
3389
|
const { cmpTemplate, context } = owner;
|
|
3390
|
+
const { getClassList } = renderer;
|
|
3494
3391
|
const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
|
|
3495
3392
|
if (!isUndefined$1(token) && context.hasScopedStyles) {
|
|
3393
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3394
|
+
// probably we should have a renderer api for just the add operation
|
|
3496
3395
|
getClassList(elm).add(token);
|
|
3497
3396
|
}
|
|
3498
3397
|
}
|
|
3499
|
-
function linkNodeToShadow(elm, owner) {
|
|
3398
|
+
function linkNodeToShadow(elm, owner, renderer) {
|
|
3500
3399
|
const { renderRoot, renderMode, shadowMode } = owner;
|
|
3400
|
+
const { isSyntheticShadowDefined } = renderer;
|
|
3501
3401
|
// TODO [#1164]: this should eventually be done by the polyfill directly
|
|
3502
3402
|
if (isSyntheticShadowDefined) {
|
|
3503
3403
|
if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
|
|
@@ -3505,8 +3405,9 @@ function linkNodeToShadow(elm, owner) {
|
|
|
3505
3405
|
}
|
|
3506
3406
|
}
|
|
3507
3407
|
}
|
|
3508
|
-
function updateTextContent(vnode) {
|
|
3408
|
+
function updateTextContent(vnode, renderer) {
|
|
3509
3409
|
const { elm, text } = vnode;
|
|
3410
|
+
const { setText } = renderer;
|
|
3510
3411
|
if (process.env.NODE_ENV !== 'production') {
|
|
3511
3412
|
unlockDomMutation();
|
|
3512
3413
|
}
|
|
@@ -3515,40 +3416,40 @@ function updateTextContent(vnode) {
|
|
|
3515
3416
|
lockDomMutation();
|
|
3516
3417
|
}
|
|
3517
3418
|
}
|
|
3518
|
-
function insertNode(node, parent, anchor) {
|
|
3419
|
+
function insertNode(node, parent, anchor, renderer) {
|
|
3519
3420
|
if (process.env.NODE_ENV !== 'production') {
|
|
3520
3421
|
unlockDomMutation();
|
|
3521
3422
|
}
|
|
3522
|
-
insert(node, parent, anchor);
|
|
3423
|
+
renderer.insert(node, parent, anchor);
|
|
3523
3424
|
if (process.env.NODE_ENV !== 'production') {
|
|
3524
3425
|
lockDomMutation();
|
|
3525
3426
|
}
|
|
3526
3427
|
}
|
|
3527
|
-
function removeNode(node, parent) {
|
|
3428
|
+
function removeNode(node, parent, renderer) {
|
|
3528
3429
|
if (process.env.NODE_ENV !== 'production') {
|
|
3529
3430
|
unlockDomMutation();
|
|
3530
3431
|
}
|
|
3531
|
-
remove(node, parent);
|
|
3432
|
+
renderer.remove(node, parent);
|
|
3532
3433
|
if (process.env.NODE_ENV !== 'production') {
|
|
3533
3434
|
lockDomMutation();
|
|
3534
3435
|
}
|
|
3535
3436
|
}
|
|
3536
|
-
function patchElementPropsAndAttrs$1(oldVnode, vnode) {
|
|
3437
|
+
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
3537
3438
|
if (isNull(oldVnode)) {
|
|
3538
|
-
applyEventListeners(vnode);
|
|
3539
|
-
applyStaticClassAttribute(vnode);
|
|
3540
|
-
applyStaticStyleAttribute(vnode);
|
|
3439
|
+
applyEventListeners(vnode, renderer);
|
|
3440
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
3441
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
3541
3442
|
}
|
|
3542
3443
|
// Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
3543
3444
|
// value is set before type=radio.
|
|
3544
|
-
patchClassAttribute(oldVnode, vnode);
|
|
3545
|
-
patchStyleAttribute(oldVnode, vnode);
|
|
3546
|
-
patchAttributes(oldVnode, vnode);
|
|
3547
|
-
patchProps(oldVnode, vnode);
|
|
3445
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
3446
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
3447
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
3448
|
+
patchProps(oldVnode, vnode, renderer);
|
|
3548
3449
|
}
|
|
3549
|
-
function fallbackElmHook(elm, vnode) {
|
|
3450
|
+
function fallbackElmHook(elm, vnode, renderer) {
|
|
3550
3451
|
const { owner } = vnode;
|
|
3551
|
-
setScopeTokenClassIfNecessary(elm, owner);
|
|
3452
|
+
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
3552
3453
|
if (owner.shadowMode === 1 /* Synthetic */) {
|
|
3553
3454
|
const { data: { context }, } = vnode;
|
|
3554
3455
|
const { stylesheetToken } = owner.context;
|
|
@@ -3596,7 +3497,7 @@ function allocateChildren(vnode, vm) {
|
|
|
3596
3497
|
vnode.children = EmptyArray;
|
|
3597
3498
|
}
|
|
3598
3499
|
}
|
|
3599
|
-
function createViewModelHook(elm, vnode) {
|
|
3500
|
+
function createViewModelHook(elm, vnode, renderer) {
|
|
3600
3501
|
let vm = getAssociatedVMIfPresent(elm);
|
|
3601
3502
|
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
3602
3503
|
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
@@ -3605,7 +3506,7 @@ function createViewModelHook(elm, vnode) {
|
|
|
3605
3506
|
return vm;
|
|
3606
3507
|
}
|
|
3607
3508
|
const { sel, mode, ctor, owner } = vnode;
|
|
3608
|
-
setScopeTokenClassIfNecessary(elm, owner);
|
|
3509
|
+
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
3609
3510
|
if (owner.shadowMode === 1 /* Synthetic */) {
|
|
3610
3511
|
const { stylesheetToken } = owner.context;
|
|
3611
3512
|
// when running in synthetic shadow mode, we need to set the shadowToken value
|
|
@@ -3614,7 +3515,7 @@ function createViewModelHook(elm, vnode) {
|
|
|
3614
3515
|
setElementShadowToken(elm, stylesheetToken);
|
|
3615
3516
|
}
|
|
3616
3517
|
}
|
|
3617
|
-
vm = createVM(elm, ctor, {
|
|
3518
|
+
vm = createVM(elm, ctor, renderer, {
|
|
3618
3519
|
mode,
|
|
3619
3520
|
owner,
|
|
3620
3521
|
tagName: sel,
|
|
@@ -3689,7 +3590,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
|
3689
3590
|
}
|
|
3690
3591
|
return map;
|
|
3691
3592
|
}
|
|
3692
|
-
function updateDynamicChildren(oldCh, newCh, parent) {
|
|
3593
|
+
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
3693
3594
|
let oldStartIdx = 0;
|
|
3694
3595
|
let newStartIdx = 0;
|
|
3695
3596
|
let oldEndIdx = oldCh.length - 1;
|
|
@@ -3718,26 +3619,26 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3718
3619
|
newEndVnode = newCh[--newEndIdx];
|
|
3719
3620
|
}
|
|
3720
3621
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
3721
|
-
patch(oldStartVnode, newStartVnode);
|
|
3622
|
+
patch(oldStartVnode, newStartVnode, renderer);
|
|
3722
3623
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3723
3624
|
newStartVnode = newCh[++newStartIdx];
|
|
3724
3625
|
}
|
|
3725
3626
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
3726
|
-
patch(oldEndVnode, newEndVnode);
|
|
3627
|
+
patch(oldEndVnode, newEndVnode, renderer);
|
|
3727
3628
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3728
3629
|
newEndVnode = newCh[--newEndIdx];
|
|
3729
3630
|
}
|
|
3730
3631
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
3731
3632
|
// Vnode moved right
|
|
3732
|
-
patch(oldStartVnode, newEndVnode);
|
|
3733
|
-
insertNode(oldStartVnode.elm, parent, nextSibling(oldEndVnode.elm));
|
|
3633
|
+
patch(oldStartVnode, newEndVnode, renderer);
|
|
3634
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
3734
3635
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3735
3636
|
newEndVnode = newCh[--newEndIdx];
|
|
3736
3637
|
}
|
|
3737
3638
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
3738
3639
|
// Vnode moved left
|
|
3739
|
-
patch(oldEndVnode, newStartVnode);
|
|
3740
|
-
insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
|
|
3640
|
+
patch(oldEndVnode, newStartVnode, renderer);
|
|
3641
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
3741
3642
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3742
3643
|
newStartVnode = newCh[++newStartIdx];
|
|
3743
3644
|
}
|
|
@@ -3748,7 +3649,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3748
3649
|
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
3749
3650
|
if (isUndefined$1(idxInOld)) {
|
|
3750
3651
|
// New element
|
|
3751
|
-
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
3652
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3752
3653
|
newStartVnode = newCh[++newStartIdx];
|
|
3753
3654
|
}
|
|
3754
3655
|
else {
|
|
@@ -3756,10 +3657,10 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3756
3657
|
if (isVNode(elmToMove)) {
|
|
3757
3658
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
3758
3659
|
// New element
|
|
3759
|
-
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
3660
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3760
3661
|
}
|
|
3761
3662
|
else {
|
|
3762
|
-
patch(elmToMove, newStartVnode);
|
|
3663
|
+
patch(elmToMove, newStartVnode, renderer);
|
|
3763
3664
|
// Delete the old child, but copy the array since it is read-only.
|
|
3764
3665
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
3765
3666
|
// so we only care about the `oldCh` object inside this function.
|
|
@@ -3771,7 +3672,7 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3771
3672
|
}
|
|
3772
3673
|
// We've already cloned at least once, so it's no longer read-only
|
|
3773
3674
|
oldCh[idxInOld] = undefined;
|
|
3774
|
-
insertNode(elmToMove.elm, parent, oldStartVnode.elm);
|
|
3675
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
3775
3676
|
}
|
|
3776
3677
|
}
|
|
3777
3678
|
newStartVnode = newCh[++newStartIdx];
|
|
@@ -3788,25 +3689,25 @@ function updateDynamicChildren(oldCh, newCh, parent) {
|
|
|
3788
3689
|
n = newCh[++i];
|
|
3789
3690
|
} while (!isVNode(n) && i < newChEnd);
|
|
3790
3691
|
before = isVNode(n) ? n.elm : null;
|
|
3791
|
-
mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
|
|
3692
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
3792
3693
|
}
|
|
3793
3694
|
else {
|
|
3794
|
-
unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
|
|
3695
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
3795
3696
|
}
|
|
3796
3697
|
}
|
|
3797
3698
|
}
|
|
3798
|
-
function updateStaticChildren(c1, c2, parent) {
|
|
3699
|
+
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
3799
3700
|
const c1Length = c1.length;
|
|
3800
3701
|
const c2Length = c2.length;
|
|
3801
3702
|
if (c1Length === 0) {
|
|
3802
3703
|
// the old list is empty, we can directly insert anything new
|
|
3803
|
-
mountVNodes(c2, parent, null);
|
|
3704
|
+
mountVNodes(c2, parent, renderer, null);
|
|
3804
3705
|
return;
|
|
3805
3706
|
}
|
|
3806
3707
|
if (c2Length === 0) {
|
|
3807
3708
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
3808
3709
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
3809
|
-
unmountVNodes(c1, parent, true);
|
|
3710
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
3810
3711
|
return;
|
|
3811
3712
|
}
|
|
3812
3713
|
// if the old list is not empty, the new list MUST have the same
|
|
@@ -3819,16 +3720,16 @@ function updateStaticChildren(c1, c2, parent) {
|
|
|
3819
3720
|
if (isVNode(n1)) {
|
|
3820
3721
|
if (isVNode(n2)) {
|
|
3821
3722
|
// both vnodes are equivalent, and we just need to patch them
|
|
3822
|
-
patch(n1, n2);
|
|
3723
|
+
patch(n1, n2, renderer);
|
|
3823
3724
|
anchor = n2.elm;
|
|
3824
3725
|
}
|
|
3825
3726
|
else {
|
|
3826
3727
|
// removing the old vnode since the new one is null
|
|
3827
|
-
unmount(n1, parent, true);
|
|
3728
|
+
unmount(n1, parent, renderer, true);
|
|
3828
3729
|
}
|
|
3829
3730
|
}
|
|
3830
3731
|
else if (isVNode(n2)) {
|
|
3831
|
-
mount(n2, parent, anchor);
|
|
3732
|
+
mount(n2, parent, renderer, anchor);
|
|
3832
3733
|
anchor = n2.elm;
|
|
3833
3734
|
}
|
|
3834
3735
|
}
|
|
@@ -3845,6 +3746,17 @@ const SymbolIterator = Symbol.iterator;
|
|
|
3845
3746
|
function addVNodeToChildLWC(vnode) {
|
|
3846
3747
|
ArrayPush$1.call(getVMBeingRendered().velements, vnode);
|
|
3847
3748
|
}
|
|
3749
|
+
// [st]atic node
|
|
3750
|
+
function st(fragment, key) {
|
|
3751
|
+
return {
|
|
3752
|
+
type: 4 /* Static */,
|
|
3753
|
+
sel: undefined,
|
|
3754
|
+
key,
|
|
3755
|
+
elm: undefined,
|
|
3756
|
+
fragment,
|
|
3757
|
+
owner: getVMBeingRendered(),
|
|
3758
|
+
};
|
|
3759
|
+
}
|
|
3848
3760
|
// [h]tml node
|
|
3849
3761
|
function h(sel, data, children = EmptyArray) {
|
|
3850
3762
|
const vmBeingRendered = getVMBeingRendered();
|
|
@@ -4234,6 +4146,7 @@ const api = freeze({
|
|
|
4234
4146
|
co,
|
|
4235
4147
|
dc,
|
|
4236
4148
|
ti,
|
|
4149
|
+
st,
|
|
4237
4150
|
gid,
|
|
4238
4151
|
fid,
|
|
4239
4152
|
shc,
|
|
@@ -4257,7 +4170,7 @@ function createInlineStyleVNode(content) {
|
|
|
4257
4170
|
}, [api.t(content)]);
|
|
4258
4171
|
}
|
|
4259
4172
|
function updateStylesheetToken(vm, template) {
|
|
4260
|
-
const { elm, context, renderMode, shadowMode } = vm;
|
|
4173
|
+
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
4261
4174
|
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
4262
4175
|
const isSyntheticShadow = renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */;
|
|
4263
4176
|
const { hasScopedStyles } = context;
|
|
@@ -4374,7 +4287,7 @@ function getNearestNativeShadowComponent(vm) {
|
|
|
4374
4287
|
return owner;
|
|
4375
4288
|
}
|
|
4376
4289
|
function createStylesheet(vm, stylesheets) {
|
|
4377
|
-
const { renderMode, shadowMode } = vm;
|
|
4290
|
+
const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
|
|
4378
4291
|
if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
|
|
4379
4292
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
4380
4293
|
insertStylesheet(stylesheets[i]);
|
|
@@ -4385,8 +4298,7 @@ function createStylesheet(vm, stylesheets) {
|
|
|
4385
4298
|
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
4386
4299
|
// the first time the VM renders.
|
|
4387
4300
|
// native shadow or light DOM, SSR
|
|
4388
|
-
|
|
4389
|
-
return createInlineStyleVNode(combinedStylesheetContent);
|
|
4301
|
+
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
4390
4302
|
}
|
|
4391
4303
|
else {
|
|
4392
4304
|
// native shadow or light DOM, DOM renderer
|
|
@@ -4554,6 +4466,59 @@ function validateLightDomTemplate(template, vm) {
|
|
|
4554
4466
|
assert.isTrue(isUndefined$1(template.renderMode), `Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${getComponentTag(vm)} or set it to 'lwc:render-mode="shadow"`);
|
|
4555
4467
|
}
|
|
4556
4468
|
}
|
|
4469
|
+
function buildParseFragmentFn(createFragmentFn) {
|
|
4470
|
+
return (strings, ...keys) => {
|
|
4471
|
+
const cache = create(null);
|
|
4472
|
+
return function () {
|
|
4473
|
+
const { context: { hasScopedStyles, stylesheetToken }, shadowMode, renderer, } = getVMBeingRendered();
|
|
4474
|
+
const hasStyleToken = !isUndefined$1(stylesheetToken);
|
|
4475
|
+
const isSyntheticShadow = shadowMode === 1 /* Synthetic */;
|
|
4476
|
+
let cacheKey = 0;
|
|
4477
|
+
if (hasStyleToken && hasScopedStyles) {
|
|
4478
|
+
cacheKey |= 1 /* HAS_SCOPED_STYLE */;
|
|
4479
|
+
}
|
|
4480
|
+
if (hasStyleToken && isSyntheticShadow) {
|
|
4481
|
+
cacheKey |= 2 /* SHADOW_MODE_SYNTHETIC */;
|
|
4482
|
+
}
|
|
4483
|
+
if (!isUndefined$1(cache[cacheKey])) {
|
|
4484
|
+
return cache[cacheKey];
|
|
4485
|
+
}
|
|
4486
|
+
const classToken = hasScopedStyles && hasStyleToken ? ' ' + stylesheetToken : '';
|
|
4487
|
+
const classAttrToken = hasScopedStyles && hasStyleToken ? ` class="${stylesheetToken}"` : '';
|
|
4488
|
+
const attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetToken : '';
|
|
4489
|
+
let htmlFragment = '';
|
|
4490
|
+
for (let i = 0, n = keys.length; i < n; i++) {
|
|
4491
|
+
switch (keys[i]) {
|
|
4492
|
+
case 0: // styleToken in existing class attr
|
|
4493
|
+
htmlFragment += strings[i] + classToken;
|
|
4494
|
+
break;
|
|
4495
|
+
case 1: // styleToken for added class attr
|
|
4496
|
+
htmlFragment += strings[i] + classAttrToken;
|
|
4497
|
+
break;
|
|
4498
|
+
case 2: // styleToken as attr
|
|
4499
|
+
htmlFragment += strings[i] + attrToken;
|
|
4500
|
+
break;
|
|
4501
|
+
case 3: // ${1}${2}
|
|
4502
|
+
htmlFragment += strings[i] + classAttrToken + attrToken;
|
|
4503
|
+
break;
|
|
4504
|
+
}
|
|
4505
|
+
}
|
|
4506
|
+
htmlFragment += strings[strings.length - 1];
|
|
4507
|
+
cache[cacheKey] = createFragmentFn(htmlFragment, renderer);
|
|
4508
|
+
return cache[cacheKey];
|
|
4509
|
+
};
|
|
4510
|
+
};
|
|
4511
|
+
}
|
|
4512
|
+
// Note: at the moment this code executes, we don't have a renderer yet.
|
|
4513
|
+
const parseFragment = buildParseFragmentFn((html, renderer) => {
|
|
4514
|
+
const { createFragment } = renderer;
|
|
4515
|
+
return createFragment(html);
|
|
4516
|
+
});
|
|
4517
|
+
const parseSVGFragment = buildParseFragmentFn((html, renderer) => {
|
|
4518
|
+
const { createFragment, getFirstChild } = renderer;
|
|
4519
|
+
const fragment = createFragment('<svg>' + html + '</svg>');
|
|
4520
|
+
return getFirstChild(fragment);
|
|
4521
|
+
});
|
|
4557
4522
|
function evaluateTemplate(vm, html) {
|
|
4558
4523
|
if (process.env.NODE_ENV !== 'production') {
|
|
4559
4524
|
assert.isTrue(isFunction$1(html), `evaluateTemplate() second argument must be an imported template instead of ${toString$1(html)}`);
|
|
@@ -4600,7 +4565,7 @@ function evaluateTemplate(vm, html) {
|
|
|
4600
4565
|
// Evaluate, create stylesheet and cache the produced VNode for future
|
|
4601
4566
|
// re-rendering.
|
|
4602
4567
|
const stylesheetsContent = getStylesheetsContent(vm, html);
|
|
4603
|
-
context.
|
|
4568
|
+
context.styleVNodes =
|
|
4604
4569
|
stylesheetsContent.length === 0
|
|
4605
4570
|
? null
|
|
4606
4571
|
: createStylesheet(vm, stylesheetsContent);
|
|
@@ -4617,9 +4582,9 @@ function evaluateTemplate(vm, html) {
|
|
|
4617
4582
|
// Set the global flag that template is being updated
|
|
4618
4583
|
isUpdatingTemplate = true;
|
|
4619
4584
|
vnodes = html.call(undefined, api, component, cmpSlots, context.tplCache);
|
|
4620
|
-
const {
|
|
4621
|
-
if (!isNull(
|
|
4622
|
-
ArrayUnshift.
|
|
4585
|
+
const { styleVNodes } = context;
|
|
4586
|
+
if (!isNull(styleVNodes)) {
|
|
4587
|
+
ArrayUnshift.apply(vnodes, styleVNodes);
|
|
4623
4588
|
}
|
|
4624
4589
|
});
|
|
4625
4590
|
}, () => {
|
|
@@ -4936,9 +4901,20 @@ function removeVM(vm) {
|
|
|
4936
4901
|
|
|
4937
4902
|
resetComponentStateWhenRemoved(vm);
|
|
4938
4903
|
}
|
|
4939
|
-
function createVM(elm, ctor, options) {
|
|
4940
|
-
var _a;
|
|
4941
4904
|
|
|
4905
|
+
function getNearestShadowAncestor(vm) {
|
|
4906
|
+
let ancestor = vm.owner;
|
|
4907
|
+
|
|
4908
|
+
while (!isNull(ancestor) && ancestor.renderMode === 0
|
|
4909
|
+
/* Light */
|
|
4910
|
+
) {
|
|
4911
|
+
ancestor = ancestor.owner;
|
|
4912
|
+
}
|
|
4913
|
+
|
|
4914
|
+
return ancestor;
|
|
4915
|
+
}
|
|
4916
|
+
|
|
4917
|
+
function createVM(elm, ctor, renderer, options) {
|
|
4942
4918
|
const {
|
|
4943
4919
|
mode,
|
|
4944
4920
|
owner,
|
|
@@ -4968,28 +4944,29 @@ function createVM(elm, ctor, options) {
|
|
|
4968
4944
|
cmpTemplate: null,
|
|
4969
4945
|
hydrated: Boolean(hydrated),
|
|
4970
4946
|
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
4947
|
context: {
|
|
4974
4948
|
stylesheetToken: undefined,
|
|
4975
4949
|
hasTokenInClass: undefined,
|
|
4976
4950
|
hasTokenInAttribute: undefined,
|
|
4977
4951
|
hasScopedStyles: undefined,
|
|
4978
|
-
|
|
4952
|
+
styleVNodes: null,
|
|
4979
4953
|
tplCache: EmptyObject,
|
|
4980
4954
|
wiredConnecting: EmptyArray,
|
|
4981
4955
|
wiredDisconnecting: EmptyArray
|
|
4982
4956
|
},
|
|
4983
4957
|
// Properties set right after VM creation.
|
|
4984
4958
|
tro: null,
|
|
4959
|
+
shadowMode: null,
|
|
4985
4960
|
// Properties set by the LightningElement constructor.
|
|
4986
4961
|
component: null,
|
|
4987
4962
|
shadowRoot: null,
|
|
4988
4963
|
renderRoot: null,
|
|
4989
4964
|
callHook,
|
|
4990
4965
|
setHook,
|
|
4991
|
-
getHook
|
|
4966
|
+
getHook,
|
|
4967
|
+
renderer
|
|
4992
4968
|
};
|
|
4969
|
+
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
4993
4970
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
4994
4971
|
|
|
4995
4972
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5014,9 +4991,14 @@ function createVM(elm, ctor, options) {
|
|
|
5014
4991
|
return vm;
|
|
5015
4992
|
}
|
|
5016
4993
|
|
|
5017
|
-
function computeShadowMode(
|
|
5018
|
-
|
|
5019
|
-
|
|
4994
|
+
function computeShadowMode(vm, renderer) {
|
|
4995
|
+
const {
|
|
4996
|
+
def
|
|
4997
|
+
} = vm;
|
|
4998
|
+
const {
|
|
4999
|
+
isSyntheticShadowDefined,
|
|
5000
|
+
isNativeShadowDefined
|
|
5001
|
+
} = renderer;
|
|
5020
5002
|
let shadowMode;
|
|
5021
5003
|
|
|
5022
5004
|
if (isSyntheticShadowDefined) {
|
|
@@ -5039,13 +5021,23 @@ function computeShadowMode(def, owner) {
|
|
|
5039
5021
|
/* Native */
|
|
5040
5022
|
;
|
|
5041
5023
|
} else {
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5024
|
+
const shadowAncestor = getNearestShadowAncestor(vm);
|
|
5025
|
+
|
|
5026
|
+
if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
|
|
5027
|
+
/* Native */
|
|
5028
|
+
) {
|
|
5029
|
+
// Transitive support for native Shadow DOM. A component in native mode
|
|
5030
|
+
// transitively opts all of its descendants into native.
|
|
5031
|
+
shadowMode = 0
|
|
5032
|
+
/* Native */
|
|
5033
|
+
;
|
|
5034
|
+
} else {
|
|
5035
|
+
// Synthetic if neither this component nor any of its ancestors are configured
|
|
5036
|
+
// to be native.
|
|
5037
|
+
shadowMode = 1
|
|
5038
|
+
/* Synthetic */
|
|
5039
|
+
;
|
|
5040
|
+
}
|
|
5049
5041
|
}
|
|
5050
5042
|
} else {
|
|
5051
5043
|
shadowMode = 1
|
|
@@ -5108,7 +5100,8 @@ function rehydrate(vm) {
|
|
|
5108
5100
|
function patchShadowRoot(vm, newCh) {
|
|
5109
5101
|
const {
|
|
5110
5102
|
renderRoot,
|
|
5111
|
-
children: oldCh
|
|
5103
|
+
children: oldCh,
|
|
5104
|
+
renderer
|
|
5112
5105
|
} = vm; // caching the new children collection
|
|
5113
5106
|
|
|
5114
5107
|
vm.children = newCh;
|
|
@@ -5124,7 +5117,7 @@ function patchShadowRoot(vm, newCh) {
|
|
|
5124
5117
|
, vm);
|
|
5125
5118
|
}, () => {
|
|
5126
5119
|
// job
|
|
5127
|
-
patchChildren(oldCh, newCh, renderRoot);
|
|
5120
|
+
patchChildren(oldCh, newCh, renderRoot, renderer);
|
|
5128
5121
|
}, () => {
|
|
5129
5122
|
// post
|
|
5130
5123
|
logOperationEnd(2
|
|
@@ -5149,6 +5142,9 @@ function runRenderedCallback(vm) {
|
|
|
5149
5142
|
const {
|
|
5150
5143
|
def: {
|
|
5151
5144
|
renderedCallback
|
|
5145
|
+
},
|
|
5146
|
+
renderer: {
|
|
5147
|
+
ssr
|
|
5152
5148
|
}
|
|
5153
5149
|
} = vm;
|
|
5154
5150
|
|
|
@@ -5386,7 +5382,10 @@ function recursivelyDisconnectChildren(vnodes) {
|
|
|
5386
5382
|
function resetComponentRoot(vm) {
|
|
5387
5383
|
const {
|
|
5388
5384
|
children,
|
|
5389
|
-
renderRoot
|
|
5385
|
+
renderRoot,
|
|
5386
|
+
renderer: {
|
|
5387
|
+
remove
|
|
5388
|
+
}
|
|
5390
5389
|
} = vm;
|
|
5391
5390
|
|
|
5392
5391
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
@@ -5402,6 +5401,12 @@ function resetComponentRoot(vm) {
|
|
|
5402
5401
|
vm.velements = EmptyArray;
|
|
5403
5402
|
}
|
|
5404
5403
|
function scheduleRehydration(vm) {
|
|
5404
|
+
const {
|
|
5405
|
+
renderer: {
|
|
5406
|
+
ssr
|
|
5407
|
+
}
|
|
5408
|
+
} = vm;
|
|
5409
|
+
|
|
5405
5410
|
if (isTrue(ssr) || isTrue(vm.isScheduled)) {
|
|
5406
5411
|
return;
|
|
5407
5412
|
}
|
|
@@ -5578,6 +5583,9 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
|
5578
5583
|
context: {
|
|
5579
5584
|
wiredConnecting,
|
|
5580
5585
|
wiredDisconnecting
|
|
5586
|
+
},
|
|
5587
|
+
renderer: {
|
|
5588
|
+
dispatchEvent
|
|
5581
5589
|
}
|
|
5582
5590
|
} = vm; // waiting for the component to be connected to formally request the context via the token
|
|
5583
5591
|
|
|
@@ -5849,70 +5857,90 @@ function hydrateRoot(vm) {
|
|
|
5849
5857
|
function hydrateVM(vm) {
|
|
5850
5858
|
const children = renderComponent(vm);
|
|
5851
5859
|
vm.children = children;
|
|
5852
|
-
const parentNode = vm
|
|
5860
|
+
const { renderRoot: parentNode, renderer: { getFirstChild }, } = vm;
|
|
5853
5861
|
hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
|
|
5854
5862
|
runRenderedCallback(vm);
|
|
5855
5863
|
}
|
|
5856
|
-
function hydrateNode(node, vnode) {
|
|
5864
|
+
function hydrateNode(node, vnode, renderer) {
|
|
5865
|
+
var _a, _b;
|
|
5857
5866
|
let hydratedNode;
|
|
5858
5867
|
switch (vnode.type) {
|
|
5859
5868
|
case 0 /* Text */:
|
|
5860
|
-
|
|
5869
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
5870
|
+
hydratedNode = hydrateText(node, vnode, renderer);
|
|
5861
5871
|
break;
|
|
5862
5872
|
case 1 /* Comment */:
|
|
5863
|
-
|
|
5873
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
5874
|
+
hydratedNode = hydrateComment(node, vnode, renderer);
|
|
5875
|
+
break;
|
|
5876
|
+
case 4 /* Static */:
|
|
5877
|
+
// VStatic are cacheable and cannot have custom renderer associated to them
|
|
5878
|
+
hydratedNode = hydrateStaticElement(node, vnode, renderer);
|
|
5864
5879
|
break;
|
|
5865
5880
|
case 2 /* Element */:
|
|
5866
|
-
hydratedNode = hydrateElement(node, vnode);
|
|
5881
|
+
hydratedNode = hydrateElement(node, vnode, (_a = vnode.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
5867
5882
|
break;
|
|
5868
5883
|
case 3 /* CustomElement */:
|
|
5869
|
-
hydratedNode = hydrateCustomElement(node, vnode);
|
|
5884
|
+
hydratedNode = hydrateCustomElement(node, vnode, (_b = vnode.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
5870
5885
|
break;
|
|
5871
5886
|
}
|
|
5872
|
-
return nextSibling(hydratedNode);
|
|
5887
|
+
return renderer.nextSibling(hydratedNode);
|
|
5873
5888
|
}
|
|
5874
|
-
function hydrateText(node, vnode) {
|
|
5889
|
+
function hydrateText(node, vnode, renderer) {
|
|
5875
5890
|
var _a;
|
|
5876
|
-
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT
|
|
5877
|
-
return handleMismatch(node, vnode);
|
|
5891
|
+
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */, renderer)) {
|
|
5892
|
+
return handleMismatch(node, vnode, renderer);
|
|
5878
5893
|
}
|
|
5879
5894
|
if (process.env.NODE_ENV !== 'production') {
|
|
5895
|
+
const { getProperty } = renderer;
|
|
5880
5896
|
const nodeValue = getProperty(node, 'nodeValue');
|
|
5881
5897
|
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
5882
5898
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
5883
5899
|
}
|
|
5884
5900
|
}
|
|
5901
|
+
const { setText } = renderer;
|
|
5885
5902
|
setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5886
5903
|
vnode.elm = node;
|
|
5887
5904
|
return node;
|
|
5888
5905
|
}
|
|
5889
|
-
function hydrateComment(node, vnode) {
|
|
5906
|
+
function hydrateComment(node, vnode, renderer) {
|
|
5890
5907
|
var _a;
|
|
5891
|
-
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT
|
|
5892
|
-
return handleMismatch(node, vnode);
|
|
5908
|
+
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */, renderer)) {
|
|
5909
|
+
return handleMismatch(node, vnode, renderer);
|
|
5893
5910
|
}
|
|
5894
5911
|
if (process.env.NODE_ENV !== 'production') {
|
|
5912
|
+
const { getProperty } = renderer;
|
|
5895
5913
|
const nodeValue = getProperty(node, 'nodeValue');
|
|
5896
5914
|
if (nodeValue !== vnode.text) {
|
|
5897
5915
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
5898
5916
|
}
|
|
5899
5917
|
}
|
|
5918
|
+
const { setProperty } = renderer;
|
|
5900
5919
|
setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5901
5920
|
vnode.elm = node;
|
|
5902
5921
|
return node;
|
|
5903
5922
|
}
|
|
5904
|
-
function
|
|
5905
|
-
if (!
|
|
5906
|
-
|
|
5907
|
-
|
|
5923
|
+
function hydrateStaticElement(elm, vnode, renderer) {
|
|
5924
|
+
if (!areCompatibleNodes(vnode.fragment, elm, vnode, renderer)) {
|
|
5925
|
+
return handleMismatch(elm, vnode, renderer);
|
|
5926
|
+
}
|
|
5927
|
+
vnode.elm = elm;
|
|
5928
|
+
return elm;
|
|
5929
|
+
}
|
|
5930
|
+
function hydrateElement(elm, vnode, renderer) {
|
|
5931
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
|
|
5932
|
+
!isMatchingElement(vnode, elm, renderer)) {
|
|
5933
|
+
return handleMismatch(elm, vnode, renderer);
|
|
5908
5934
|
}
|
|
5909
5935
|
vnode.elm = elm;
|
|
5936
|
+
const { owner } = vnode;
|
|
5910
5937
|
const { context } = vnode.data;
|
|
5911
5938
|
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual" /* Manual */);
|
|
5912
5939
|
if (isDomManual) {
|
|
5913
5940
|
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
5914
5941
|
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
5915
|
-
const { props } = vnode
|
|
5942
|
+
const { data: { props }, } = vnode;
|
|
5943
|
+
const { getProperty } = renderer;
|
|
5916
5944
|
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
5917
5945
|
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
5918
5946
|
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
@@ -5920,24 +5948,25 @@ function hydrateElement(elm, vnode) {
|
|
|
5920
5948
|
}
|
|
5921
5949
|
else {
|
|
5922
5950
|
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`,
|
|
5951
|
+
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, owner);
|
|
5924
5952
|
}
|
|
5925
5953
|
}
|
|
5926
5954
|
}
|
|
5927
5955
|
}
|
|
5928
|
-
patchElementPropsAndAttrs(vnode);
|
|
5956
|
+
patchElementPropsAndAttrs(vnode, renderer);
|
|
5929
5957
|
if (!isDomManual) {
|
|
5930
|
-
|
|
5958
|
+
const { getFirstChild } = renderer;
|
|
5959
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, owner);
|
|
5931
5960
|
}
|
|
5932
5961
|
return elm;
|
|
5933
5962
|
}
|
|
5934
|
-
function hydrateCustomElement(elm, vnode) {
|
|
5935
|
-
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT
|
|
5936
|
-
!isMatchingElement(vnode, elm)) {
|
|
5937
|
-
return handleMismatch(elm, vnode);
|
|
5963
|
+
function hydrateCustomElement(elm, vnode, renderer) {
|
|
5964
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
|
|
5965
|
+
!isMatchingElement(vnode, elm, renderer)) {
|
|
5966
|
+
return handleMismatch(elm, vnode, renderer);
|
|
5938
5967
|
}
|
|
5939
5968
|
const { sel, mode, ctor, owner } = vnode;
|
|
5940
|
-
const vm = createVM(elm, ctor, {
|
|
5969
|
+
const vm = createVM(elm, ctor, renderer, {
|
|
5941
5970
|
mode,
|
|
5942
5971
|
owner,
|
|
5943
5972
|
tagName: sel,
|
|
@@ -5946,13 +5975,14 @@ function hydrateCustomElement(elm, vnode) {
|
|
|
5946
5975
|
vnode.elm = elm;
|
|
5947
5976
|
vnode.vm = vm;
|
|
5948
5977
|
allocateChildren(vnode, vm);
|
|
5949
|
-
patchElementPropsAndAttrs(vnode);
|
|
5978
|
+
patchElementPropsAndAttrs(vnode, renderer);
|
|
5950
5979
|
// Insert hook section:
|
|
5951
5980
|
if (process.env.NODE_ENV !== 'production') {
|
|
5952
5981
|
assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
5953
5982
|
}
|
|
5954
5983
|
runConnectedCallback(vm);
|
|
5955
5984
|
if (vm.renderMode !== 0 /* Light */) {
|
|
5985
|
+
const { getFirstChild } = renderer;
|
|
5956
5986
|
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
5957
5987
|
// Note: for Light DOM, this is handled while hydrating the VM
|
|
5958
5988
|
hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
|
|
@@ -5964,11 +5994,12 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
5964
5994
|
let hasWarned = false;
|
|
5965
5995
|
let nextNode = node;
|
|
5966
5996
|
let anchor = null;
|
|
5997
|
+
const { renderer } = owner;
|
|
5967
5998
|
for (let i = 0; i < children.length; i++) {
|
|
5968
5999
|
const childVnode = children[i];
|
|
5969
6000
|
if (!isNull(childVnode)) {
|
|
5970
6001
|
if (nextNode) {
|
|
5971
|
-
nextNode = hydrateNode(nextNode, childVnode);
|
|
6002
|
+
nextNode = hydrateNode(nextNode, childVnode, renderer);
|
|
5972
6003
|
anchor = childVnode.elm;
|
|
5973
6004
|
}
|
|
5974
6005
|
else {
|
|
@@ -5979,7 +6010,7 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
5979
6010
|
logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
|
|
5980
6011
|
}
|
|
5981
6012
|
}
|
|
5982
|
-
mount(childVnode, parentNode, anchor);
|
|
6013
|
+
mount(childVnode, parentNode, renderer, anchor);
|
|
5983
6014
|
anchor = childVnode.elm;
|
|
5984
6015
|
}
|
|
5985
6016
|
}
|
|
@@ -5991,30 +6022,32 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
5991
6022
|
logError(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
|
|
5992
6023
|
}
|
|
5993
6024
|
}
|
|
6025
|
+
// nextSibling is mostly harmless, and since we don't have
|
|
6026
|
+
// a good reference to what element to act upon, we instead
|
|
6027
|
+
// rely on the vm's associated renderer for navigating to the
|
|
6028
|
+
// next node in the list to be hydrated.
|
|
6029
|
+
const { nextSibling } = renderer;
|
|
5994
6030
|
do {
|
|
5995
6031
|
const current = nextNode;
|
|
5996
6032
|
nextNode = nextSibling(nextNode);
|
|
5997
|
-
removeNode(current, parentNode);
|
|
6033
|
+
removeNode(current, parentNode, renderer);
|
|
5998
6034
|
} while (nextNode);
|
|
5999
6035
|
}
|
|
6000
6036
|
}
|
|
6001
|
-
function handleMismatch(node, vnode,
|
|
6037
|
+
function handleMismatch(node, vnode, renderer) {
|
|
6002
6038
|
hasMismatch = true;
|
|
6003
|
-
|
|
6004
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6005
|
-
logError(msg, vnode.owner);
|
|
6006
|
-
}
|
|
6007
|
-
}
|
|
6039
|
+
const { getProperty } = renderer;
|
|
6008
6040
|
const parentNode = getProperty(node, 'parentNode');
|
|
6009
|
-
mount(vnode, parentNode, node);
|
|
6010
|
-
removeNode(node, parentNode);
|
|
6041
|
+
mount(vnode, parentNode, renderer, node);
|
|
6042
|
+
removeNode(node, parentNode, renderer);
|
|
6011
6043
|
return vnode.elm;
|
|
6012
6044
|
}
|
|
6013
|
-
function patchElementPropsAndAttrs(vnode) {
|
|
6014
|
-
applyEventListeners(vnode);
|
|
6015
|
-
patchProps(null, vnode);
|
|
6045
|
+
function patchElementPropsAndAttrs(vnode, renderer) {
|
|
6046
|
+
applyEventListeners(vnode, renderer);
|
|
6047
|
+
patchProps(null, vnode, renderer);
|
|
6016
6048
|
}
|
|
6017
|
-
function hasCorrectNodeType(vnode, node, nodeType) {
|
|
6049
|
+
function hasCorrectNodeType(vnode, node, nodeType, renderer) {
|
|
6050
|
+
const { getProperty } = renderer;
|
|
6018
6051
|
if (getProperty(node, 'nodeType') !== nodeType) {
|
|
6019
6052
|
if (process.env.NODE_ENV !== 'production') {
|
|
6020
6053
|
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
@@ -6023,36 +6056,41 @@ function hasCorrectNodeType(vnode, node, nodeType) {
|
|
|
6023
6056
|
}
|
|
6024
6057
|
return true;
|
|
6025
6058
|
}
|
|
6026
|
-
function isMatchingElement(vnode, elm) {
|
|
6059
|
+
function isMatchingElement(vnode, elm, renderer) {
|
|
6060
|
+
const { getProperty } = renderer;
|
|
6027
6061
|
if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
|
|
6028
6062
|
if (process.env.NODE_ENV !== 'production') {
|
|
6029
6063
|
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
6030
6064
|
}
|
|
6031
6065
|
return false;
|
|
6032
6066
|
}
|
|
6033
|
-
const hasIncompatibleAttrs = validateAttrs(vnode, elm);
|
|
6034
|
-
const hasIncompatibleClass = validateClassAttr(vnode, elm);
|
|
6035
|
-
const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
|
|
6067
|
+
const hasIncompatibleAttrs = validateAttrs(vnode, elm, renderer);
|
|
6068
|
+
const hasIncompatibleClass = validateClassAttr(vnode, elm, renderer);
|
|
6069
|
+
const hasIncompatibleStyle = validateStyleAttr(vnode, elm, renderer);
|
|
6036
6070
|
return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
6037
6071
|
}
|
|
6038
|
-
function validateAttrs(vnode, elm) {
|
|
6072
|
+
function validateAttrs(vnode, elm, renderer) {
|
|
6039
6073
|
const { data: { attrs = {} }, } = vnode;
|
|
6040
6074
|
let nodesAreCompatible = true;
|
|
6041
6075
|
// Validate attributes, though we could always recovery from those by running the update mods.
|
|
6042
6076
|
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
6043
6077
|
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
6078
|
+
const { owner } = vnode;
|
|
6079
|
+
const { getAttribute } = renderer;
|
|
6044
6080
|
const elmAttrValue = getAttribute(elm, attrName);
|
|
6045
6081
|
if (String(attrValue) !== elmAttrValue) {
|
|
6046
6082
|
if (process.env.NODE_ENV !== 'production') {
|
|
6047
|
-
|
|
6083
|
+
const { getProperty } = renderer;
|
|
6084
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, owner);
|
|
6048
6085
|
}
|
|
6049
6086
|
nodesAreCompatible = false;
|
|
6050
6087
|
}
|
|
6051
6088
|
}
|
|
6052
6089
|
return nodesAreCompatible;
|
|
6053
6090
|
}
|
|
6054
|
-
function validateClassAttr(vnode, elm) {
|
|
6091
|
+
function validateClassAttr(vnode, elm, renderer) {
|
|
6055
6092
|
const { data: { className, classMap }, } = vnode;
|
|
6093
|
+
const { getProperty, getClassList } = renderer;
|
|
6056
6094
|
let nodesAreCompatible = true;
|
|
6057
6095
|
let vnodeClassName;
|
|
6058
6096
|
if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
|
|
@@ -6083,8 +6121,9 @@ function validateClassAttr(vnode, elm) {
|
|
|
6083
6121
|
}
|
|
6084
6122
|
return nodesAreCompatible;
|
|
6085
6123
|
}
|
|
6086
|
-
function validateStyleAttr(vnode, elm) {
|
|
6124
|
+
function validateStyleAttr(vnode, elm, renderer) {
|
|
6087
6125
|
const { data: { style, styleDecls }, } = vnode;
|
|
6126
|
+
const { getAttribute } = renderer;
|
|
6088
6127
|
const elmStyle = getAttribute(elm, 'style') || '';
|
|
6089
6128
|
let vnodeStyle;
|
|
6090
6129
|
let nodesAreCompatible = true;
|
|
@@ -6117,11 +6156,45 @@ function validateStyleAttr(vnode, elm) {
|
|
|
6117
6156
|
}
|
|
6118
6157
|
if (!nodesAreCompatible) {
|
|
6119
6158
|
if (process.env.NODE_ENV !== 'production') {
|
|
6159
|
+
const { getProperty } = renderer;
|
|
6120
6160
|
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
6121
6161
|
}
|
|
6122
6162
|
}
|
|
6123
6163
|
return nodesAreCompatible;
|
|
6124
6164
|
}
|
|
6165
|
+
function areCompatibleNodes(client, ssr, vnode, renderer) {
|
|
6166
|
+
const { getProperty, getAttribute } = renderer;
|
|
6167
|
+
if (getProperty(client, 'nodeType') === 3 /* TEXT */) {
|
|
6168
|
+
if (!hasCorrectNodeType(vnode, ssr, 3 /* TEXT */, renderer)) {
|
|
6169
|
+
return false;
|
|
6170
|
+
}
|
|
6171
|
+
return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
|
|
6172
|
+
}
|
|
6173
|
+
if (getProperty(client, 'nodeType') === 8 /* COMMENT */) {
|
|
6174
|
+
if (!hasCorrectNodeType(vnode, ssr, 8 /* COMMENT */, renderer)) {
|
|
6175
|
+
return false;
|
|
6176
|
+
}
|
|
6177
|
+
return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
|
|
6178
|
+
}
|
|
6179
|
+
if (!hasCorrectNodeType(vnode, ssr, 1 /* ELEMENT */, renderer)) {
|
|
6180
|
+
return false;
|
|
6181
|
+
}
|
|
6182
|
+
let isCompatibleElements = true;
|
|
6183
|
+
if (getProperty(client, 'tagName') !== getProperty(ssr, 'tagName')) {
|
|
6184
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6185
|
+
logError(`Hydration mismatch: expecting element with tag "${getProperty(client, 'tagName').toLowerCase()}" but found "${getProperty(ssr, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
6186
|
+
}
|
|
6187
|
+
return false;
|
|
6188
|
+
}
|
|
6189
|
+
const clientAttrsNames = getProperty(client, 'getAttributeNames').call(client);
|
|
6190
|
+
clientAttrsNames.forEach((attrName) => {
|
|
6191
|
+
if (getAttribute(client, attrName) !== getAttribute(ssr, attrName)) {
|
|
6192
|
+
logError(`Mismatch hydrating element <${getProperty(client, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${getAttribute(client, attrName)}" but found "${getAttribute(ssr, attrName)}"`, vnode.owner);
|
|
6193
|
+
isCompatibleElements = false;
|
|
6194
|
+
}
|
|
6195
|
+
});
|
|
6196
|
+
return isCompatibleElements;
|
|
6197
|
+
}
|
|
6125
6198
|
|
|
6126
6199
|
/*
|
|
6127
6200
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6258,5 +6331,5 @@ function getComponentConstructor(elm) {
|
|
|
6258
6331
|
return ctor;
|
|
6259
6332
|
}
|
|
6260
6333
|
|
|
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.
|
|
6334
|
+
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6335
|
+
/* version: 2.15.0 */
|