lwc 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-dom/esm/es2017/engine-dom.js +637 -554
- package/dist/engine-dom/iife/es2017/engine-dom.js +639 -553
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +574 -497
- package/dist/engine-dom/iife/es5/engine-dom.js +807 -694
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +729 -634
- package/dist/engine-dom/umd/es2017/engine-dom.js +639 -553
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +574 -497
- package/dist/engine-dom/umd/es5/engine-dom.js +807 -694
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +729 -634
- package/dist/engine-server/commonjs/es2017/engine-server.js +494 -473
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +492 -474
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +24 -4
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +24 -4
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +24 -4
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +29 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +29 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +24 -4
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +24 -4
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +29 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +29 -3
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +7 -7
|
@@ -233,6 +233,7 @@
|
|
|
233
233
|
*/
|
|
234
234
|
const KEY__IS_NATIVE_SHADOW_ROOT_DEFINED = '$isNativeShadowRootDefined$';
|
|
235
235
|
const KEY__SHADOW_RESOLVER = '$shadowResolver$';
|
|
236
|
+
const KEY__SHADOW_STATIC = '$shadowStaticNode$';
|
|
236
237
|
const KEY__SHADOW_TOKEN = '$shadowToken$';
|
|
237
238
|
const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
|
238
239
|
const KEY__SCOPED_CSS = '$scoped$';
|
|
@@ -293,7 +294,7 @@
|
|
|
293
294
|
const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
294
295
|
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
295
296
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
296
|
-
/** version: 2.
|
|
297
|
+
/** version: 2.15.0 */
|
|
297
298
|
|
|
298
299
|
/*
|
|
299
300
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -497,158 +498,6 @@
|
|
|
497
498
|
return result;
|
|
498
499
|
}
|
|
499
500
|
|
|
500
|
-
//
|
|
501
|
-
// Primitives
|
|
502
|
-
//
|
|
503
|
-
let ssr$1;
|
|
504
|
-
function setSsr(ssrImpl) {
|
|
505
|
-
ssr$1 = ssrImpl;
|
|
506
|
-
}
|
|
507
|
-
let isNativeShadowDefined$1;
|
|
508
|
-
function setIsNativeShadowDefined(isNativeShadowDefinedImpl) {
|
|
509
|
-
isNativeShadowDefined$1 = isNativeShadowDefinedImpl;
|
|
510
|
-
}
|
|
511
|
-
let isSyntheticShadowDefined$1;
|
|
512
|
-
function setIsSyntheticShadowDefined(isSyntheticShadowDefinedImpl) {
|
|
513
|
-
isSyntheticShadowDefined$1 = isSyntheticShadowDefinedImpl;
|
|
514
|
-
}
|
|
515
|
-
let HTMLElementExported$1;
|
|
516
|
-
function setHTMLElement(HTMLElementImpl) {
|
|
517
|
-
HTMLElementExported$1 = HTMLElementImpl;
|
|
518
|
-
}
|
|
519
|
-
let insert$1;
|
|
520
|
-
function setInsert(insertImpl) {
|
|
521
|
-
insert$1 = insertImpl;
|
|
522
|
-
}
|
|
523
|
-
let remove$1;
|
|
524
|
-
function setRemove(removeImpl) {
|
|
525
|
-
remove$1 = removeImpl;
|
|
526
|
-
}
|
|
527
|
-
let createElement$2;
|
|
528
|
-
function setCreateElement(createElementImpl) {
|
|
529
|
-
createElement$2 = createElementImpl;
|
|
530
|
-
}
|
|
531
|
-
let createText$1;
|
|
532
|
-
function setCreateText(createTextImpl) {
|
|
533
|
-
createText$1 = createTextImpl;
|
|
534
|
-
}
|
|
535
|
-
let createComment$1;
|
|
536
|
-
function setCreateComment(createCommentImpl) {
|
|
537
|
-
createComment$1 = createCommentImpl;
|
|
538
|
-
}
|
|
539
|
-
let nextSibling$1;
|
|
540
|
-
function setNextSibling(nextSiblingImpl) {
|
|
541
|
-
nextSibling$1 = nextSiblingImpl;
|
|
542
|
-
}
|
|
543
|
-
let attachShadow$1;
|
|
544
|
-
function setAttachShadow(attachShadowImpl) {
|
|
545
|
-
attachShadow$1 = attachShadowImpl;
|
|
546
|
-
}
|
|
547
|
-
let getProperty$1;
|
|
548
|
-
function setGetProperty(getPropertyImpl) {
|
|
549
|
-
getProperty$1 = getPropertyImpl;
|
|
550
|
-
}
|
|
551
|
-
let setProperty$1;
|
|
552
|
-
function setSetProperty(setPropertyImpl) {
|
|
553
|
-
setProperty$1 = setPropertyImpl;
|
|
554
|
-
}
|
|
555
|
-
let setText$1;
|
|
556
|
-
function setSetText(setTextImpl) {
|
|
557
|
-
setText$1 = setTextImpl;
|
|
558
|
-
}
|
|
559
|
-
let getAttribute$1;
|
|
560
|
-
function setGetAttribute(getAttributeImpl) {
|
|
561
|
-
getAttribute$1 = getAttributeImpl;
|
|
562
|
-
}
|
|
563
|
-
let setAttribute$1;
|
|
564
|
-
function setSetAttribute(setAttributeImpl) {
|
|
565
|
-
setAttribute$1 = setAttributeImpl;
|
|
566
|
-
}
|
|
567
|
-
let removeAttribute$1;
|
|
568
|
-
function setRemoveAttribute(removeAttributeImpl) {
|
|
569
|
-
removeAttribute$1 = removeAttributeImpl;
|
|
570
|
-
}
|
|
571
|
-
let addEventListener$1;
|
|
572
|
-
function setAddEventListener(addEventListenerImpl) {
|
|
573
|
-
addEventListener$1 = addEventListenerImpl;
|
|
574
|
-
}
|
|
575
|
-
let removeEventListener$1;
|
|
576
|
-
function setRemoveEventListener(removeEventListenerImpl) {
|
|
577
|
-
removeEventListener$1 = removeEventListenerImpl;
|
|
578
|
-
}
|
|
579
|
-
let dispatchEvent$1;
|
|
580
|
-
function setDispatchEvent(dispatchEventImpl) {
|
|
581
|
-
dispatchEvent$1 = dispatchEventImpl;
|
|
582
|
-
}
|
|
583
|
-
let getClassList$1;
|
|
584
|
-
function setGetClassList(getClassListImpl) {
|
|
585
|
-
getClassList$1 = getClassListImpl;
|
|
586
|
-
}
|
|
587
|
-
let setCSSStyleProperty$1;
|
|
588
|
-
function setSetCSSStyleProperty(setCSSStylePropertyImpl) {
|
|
589
|
-
setCSSStyleProperty$1 = setCSSStylePropertyImpl;
|
|
590
|
-
}
|
|
591
|
-
let getBoundingClientRect$1;
|
|
592
|
-
function setGetBoundingClientRect(getBoundingClientRectImpl) {
|
|
593
|
-
getBoundingClientRect$1 = getBoundingClientRectImpl;
|
|
594
|
-
}
|
|
595
|
-
let querySelector$1;
|
|
596
|
-
function setQuerySelector(querySelectorImpl) {
|
|
597
|
-
querySelector$1 = querySelectorImpl;
|
|
598
|
-
}
|
|
599
|
-
let querySelectorAll$1;
|
|
600
|
-
function setQuerySelectorAll(querySelectorAllImpl) {
|
|
601
|
-
querySelectorAll$1 = querySelectorAllImpl;
|
|
602
|
-
}
|
|
603
|
-
let getElementsByTagName$1;
|
|
604
|
-
function setGetElementsByTagName(getElementsByTagNameImpl) {
|
|
605
|
-
getElementsByTagName$1 = getElementsByTagNameImpl;
|
|
606
|
-
}
|
|
607
|
-
let getElementsByClassName$1;
|
|
608
|
-
function setGetElementsByClassName(getElementsByClassNameImpl) {
|
|
609
|
-
getElementsByClassName$1 = getElementsByClassNameImpl;
|
|
610
|
-
}
|
|
611
|
-
let getChildren$1;
|
|
612
|
-
function setGetChildren(getChildrenImpl) {
|
|
613
|
-
getChildren$1 = getChildrenImpl;
|
|
614
|
-
}
|
|
615
|
-
let getChildNodes$1;
|
|
616
|
-
function setGetChildNodes(getChildNodesImpl) {
|
|
617
|
-
getChildNodes$1 = getChildNodesImpl;
|
|
618
|
-
}
|
|
619
|
-
let getFirstChild$1;
|
|
620
|
-
function setGetFirstChild(getFirstChildImpl) {
|
|
621
|
-
getFirstChild$1 = getFirstChildImpl;
|
|
622
|
-
}
|
|
623
|
-
let getFirstElementChild$1;
|
|
624
|
-
function setGetFirstElementChild(getFirstElementChildImpl) {
|
|
625
|
-
getFirstElementChild$1 = getFirstElementChildImpl;
|
|
626
|
-
}
|
|
627
|
-
let getLastChild$1;
|
|
628
|
-
function setGetLastChild(getLastChildImpl) {
|
|
629
|
-
getLastChild$1 = getLastChildImpl;
|
|
630
|
-
}
|
|
631
|
-
let getLastElementChild$1;
|
|
632
|
-
function setGetLastElementChild(getLastElementChildImpl) {
|
|
633
|
-
getLastElementChild$1 = getLastElementChildImpl;
|
|
634
|
-
}
|
|
635
|
-
let isConnected$1;
|
|
636
|
-
function setIsConnected(isConnectedImpl) {
|
|
637
|
-
isConnected$1 = isConnectedImpl;
|
|
638
|
-
}
|
|
639
|
-
let insertStylesheet$1;
|
|
640
|
-
function setInsertStylesheet(insertStylesheetImpl) {
|
|
641
|
-
insertStylesheet$1 = insertStylesheetImpl;
|
|
642
|
-
}
|
|
643
|
-
let defineCustomElement$1;
|
|
644
|
-
function setDefineCustomElement(defineCustomElementImpl) {
|
|
645
|
-
defineCustomElement$1 = defineCustomElementImpl;
|
|
646
|
-
}
|
|
647
|
-
let getCustomElement$1;
|
|
648
|
-
function setGetCustomElement(getCustomElementImpl) {
|
|
649
|
-
getCustomElement$1 = getCustomElementImpl;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
501
|
/*
|
|
653
502
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
654
503
|
* All rights reserved.
|
|
@@ -1524,8 +1373,8 @@
|
|
|
1524
1373
|
return this;
|
|
1525
1374
|
};
|
|
1526
1375
|
function doAttachShadow(vm) {
|
|
1527
|
-
const { elm, mode, shadowMode, def: { ctor }, } = vm;
|
|
1528
|
-
const shadowRoot = attachShadow
|
|
1376
|
+
const { elm, mode, shadowMode, def: { ctor }, renderer: { attachShadow }, } = vm;
|
|
1377
|
+
const shadowRoot = attachShadow(elm, {
|
|
1529
1378
|
[KEY__SYNTHETIC_MODE]: shadowMode === 1 /* Synthetic */,
|
|
1530
1379
|
delegatesFocus: Boolean(ctor.delegatesFocus),
|
|
1531
1380
|
mode,
|
|
@@ -1538,76 +1387,85 @@
|
|
|
1538
1387
|
LightningElement.prototype = {
|
|
1539
1388
|
constructor: LightningElement,
|
|
1540
1389
|
dispatchEvent(event) {
|
|
1541
|
-
const
|
|
1542
|
-
|
|
1390
|
+
const vm = getAssociatedVM(this);
|
|
1391
|
+
const { elm, renderer: { dispatchEvent }, } = vm;
|
|
1392
|
+
return dispatchEvent(elm, event);
|
|
1543
1393
|
},
|
|
1544
1394
|
addEventListener(type, listener, options) {
|
|
1545
1395
|
const vm = getAssociatedVM(this);
|
|
1546
|
-
const { elm } = vm;
|
|
1396
|
+
const { elm, renderer: { addEventListener }, } = vm;
|
|
1547
1397
|
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
1548
|
-
addEventListener
|
|
1398
|
+
addEventListener(elm, type, wrappedListener, options);
|
|
1549
1399
|
},
|
|
1550
1400
|
removeEventListener(type, listener, options) {
|
|
1551
1401
|
const vm = getAssociatedVM(this);
|
|
1552
|
-
const { elm } = vm;
|
|
1402
|
+
const { elm, renderer: { removeEventListener }, } = vm;
|
|
1553
1403
|
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
1554
|
-
removeEventListener
|
|
1404
|
+
removeEventListener(elm, type, wrappedListener, options);
|
|
1555
1405
|
},
|
|
1556
1406
|
hasAttribute(name) {
|
|
1557
|
-
const
|
|
1558
|
-
|
|
1407
|
+
const vm = getAssociatedVM(this);
|
|
1408
|
+
const { elm, renderer: { getAttribute }, } = vm;
|
|
1409
|
+
return !isNull(getAttribute(elm, name));
|
|
1559
1410
|
},
|
|
1560
1411
|
hasAttributeNS(namespace, name) {
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1412
|
+
const vm = getAssociatedVM(this);
|
|
1413
|
+
const { elm, renderer: { getAttribute }, } = vm;
|
|
1414
|
+
return !isNull(getAttribute(elm, name, namespace));
|
|
1563
1415
|
},
|
|
1564
1416
|
removeAttribute(name) {
|
|
1565
|
-
const
|
|
1417
|
+
const vm = getAssociatedVM(this);
|
|
1418
|
+
const { elm, renderer: { removeAttribute }, } = vm;
|
|
1566
1419
|
unlockAttribute(elm, name);
|
|
1567
|
-
removeAttribute
|
|
1420
|
+
removeAttribute(elm, name);
|
|
1568
1421
|
lockAttribute();
|
|
1569
1422
|
},
|
|
1570
1423
|
removeAttributeNS(namespace, name) {
|
|
1571
|
-
const { elm } = getAssociatedVM(this);
|
|
1424
|
+
const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
|
|
1572
1425
|
unlockAttribute(elm, name);
|
|
1573
|
-
removeAttribute
|
|
1426
|
+
removeAttribute(elm, name, namespace);
|
|
1574
1427
|
lockAttribute();
|
|
1575
1428
|
},
|
|
1576
1429
|
getAttribute(name) {
|
|
1577
|
-
const
|
|
1578
|
-
|
|
1430
|
+
const vm = getAssociatedVM(this);
|
|
1431
|
+
const { elm } = vm;
|
|
1432
|
+
const { getAttribute } = vm.renderer;
|
|
1433
|
+
return getAttribute(elm, name);
|
|
1579
1434
|
},
|
|
1580
1435
|
getAttributeNS(namespace, name) {
|
|
1581
|
-
const
|
|
1582
|
-
|
|
1436
|
+
const vm = getAssociatedVM(this);
|
|
1437
|
+
const { elm } = vm;
|
|
1438
|
+
const { getAttribute } = vm.renderer;
|
|
1439
|
+
return getAttribute(elm, name, namespace);
|
|
1583
1440
|
},
|
|
1584
1441
|
setAttribute(name, value) {
|
|
1585
1442
|
const vm = getAssociatedVM(this);
|
|
1586
|
-
const { elm } = vm;
|
|
1443
|
+
const { elm, renderer: { setAttribute }, } = vm;
|
|
1587
1444
|
unlockAttribute(elm, name);
|
|
1588
|
-
setAttribute
|
|
1445
|
+
setAttribute(elm, name, value);
|
|
1589
1446
|
lockAttribute();
|
|
1590
1447
|
},
|
|
1591
1448
|
setAttributeNS(namespace, name, value) {
|
|
1592
1449
|
const vm = getAssociatedVM(this);
|
|
1593
|
-
const { elm } = vm;
|
|
1450
|
+
const { elm, renderer: { setAttribute }, } = vm;
|
|
1594
1451
|
unlockAttribute(elm, name);
|
|
1595
|
-
setAttribute
|
|
1452
|
+
setAttribute(elm, name, value, namespace);
|
|
1596
1453
|
lockAttribute();
|
|
1597
1454
|
},
|
|
1598
1455
|
getBoundingClientRect() {
|
|
1599
1456
|
const vm = getAssociatedVM(this);
|
|
1600
|
-
const { elm } = vm;
|
|
1601
|
-
return getBoundingClientRect
|
|
1457
|
+
const { elm, renderer: { getBoundingClientRect }, } = vm;
|
|
1458
|
+
return getBoundingClientRect(elm);
|
|
1602
1459
|
},
|
|
1603
1460
|
get isConnected() {
|
|
1604
|
-
const
|
|
1605
|
-
|
|
1461
|
+
const vm = getAssociatedVM(this);
|
|
1462
|
+
const { elm, renderer: { isConnected }, } = vm;
|
|
1463
|
+
return isConnected(elm);
|
|
1606
1464
|
},
|
|
1607
1465
|
get classList() {
|
|
1608
1466
|
const vm = getAssociatedVM(this);
|
|
1609
|
-
const { elm } = vm;
|
|
1610
|
-
return getClassList
|
|
1467
|
+
const { elm, renderer: { getClassList }, } = vm;
|
|
1468
|
+
return getClassList(elm);
|
|
1611
1469
|
},
|
|
1612
1470
|
get template() {
|
|
1613
1471
|
const vm = getAssociatedVM(this);
|
|
@@ -1618,6 +1476,36 @@
|
|
|
1618
1476
|
// Authors should rely on this.template instead.
|
|
1619
1477
|
return null;
|
|
1620
1478
|
},
|
|
1479
|
+
get children() {
|
|
1480
|
+
const vm = getAssociatedVM(this);
|
|
1481
|
+
const renderer = vm.renderer;
|
|
1482
|
+
return renderer.getChildren(vm.elm);
|
|
1483
|
+
},
|
|
1484
|
+
get childNodes() {
|
|
1485
|
+
const vm = getAssociatedVM(this);
|
|
1486
|
+
const renderer = vm.renderer;
|
|
1487
|
+
return renderer.getChildNodes(vm.elm);
|
|
1488
|
+
},
|
|
1489
|
+
get firstChild() {
|
|
1490
|
+
const vm = getAssociatedVM(this);
|
|
1491
|
+
const renderer = vm.renderer;
|
|
1492
|
+
return renderer.getFirstChild(vm.elm);
|
|
1493
|
+
},
|
|
1494
|
+
get firstElementChild() {
|
|
1495
|
+
const vm = getAssociatedVM(this);
|
|
1496
|
+
const renderer = vm.renderer;
|
|
1497
|
+
return renderer.getFirstElementChild(vm.elm);
|
|
1498
|
+
},
|
|
1499
|
+
get lastChild() {
|
|
1500
|
+
const vm = getAssociatedVM(this);
|
|
1501
|
+
const renderer = vm.renderer;
|
|
1502
|
+
return renderer.getLastChild(vm.elm);
|
|
1503
|
+
},
|
|
1504
|
+
get lastElementChild() {
|
|
1505
|
+
const vm = getAssociatedVM(this);
|
|
1506
|
+
const renderer = vm.renderer;
|
|
1507
|
+
return renderer.getLastElementChild(vm.elm);
|
|
1508
|
+
},
|
|
1621
1509
|
render() {
|
|
1622
1510
|
const vm = getAssociatedVM(this);
|
|
1623
1511
|
return vm.def.template;
|
|
@@ -1628,70 +1516,19 @@
|
|
|
1628
1516
|
},
|
|
1629
1517
|
};
|
|
1630
1518
|
const queryAndChildGetterDescriptors = create(null);
|
|
1631
|
-
// The reason we don't just call `import * as renderer from '../renderer'` here is that the bundle size
|
|
1632
|
-
// is smaller if we reference each function individually. Otherwise Rollup will create one big frozen
|
|
1633
|
-
// object representing the renderer, with a lot of methods we don't actually need.
|
|
1634
|
-
const childGetters = [
|
|
1635
|
-
'children',
|
|
1636
|
-
'childNodes',
|
|
1637
|
-
'firstChild',
|
|
1638
|
-
'firstElementChild',
|
|
1639
|
-
'lastChild',
|
|
1640
|
-
'lastElementChild',
|
|
1641
|
-
];
|
|
1642
|
-
function getChildGetter(methodName) {
|
|
1643
|
-
switch (methodName) {
|
|
1644
|
-
case 'children':
|
|
1645
|
-
return getChildren$1;
|
|
1646
|
-
case 'childNodes':
|
|
1647
|
-
return getChildNodes$1;
|
|
1648
|
-
case 'firstChild':
|
|
1649
|
-
return getFirstChild$1;
|
|
1650
|
-
case 'firstElementChild':
|
|
1651
|
-
return getFirstElementChild$1;
|
|
1652
|
-
case 'lastChild':
|
|
1653
|
-
return getLastChild$1;
|
|
1654
|
-
case 'lastElementChild':
|
|
1655
|
-
return getLastElementChild$1;
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
// Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
|
|
1659
|
-
for (const childGetter of childGetters) {
|
|
1660
|
-
queryAndChildGetterDescriptors[childGetter] = {
|
|
1661
|
-
get() {
|
|
1662
|
-
const vm = getAssociatedVM(this);
|
|
1663
|
-
const { elm } = vm;
|
|
1664
|
-
return getChildGetter(childGetter)(elm);
|
|
1665
|
-
},
|
|
1666
|
-
configurable: true,
|
|
1667
|
-
enumerable: true,
|
|
1668
|
-
};
|
|
1669
|
-
}
|
|
1670
1519
|
const queryMethods = [
|
|
1671
1520
|
'getElementsByClassName',
|
|
1672
1521
|
'getElementsByTagName',
|
|
1673
1522
|
'querySelector',
|
|
1674
1523
|
'querySelectorAll',
|
|
1675
1524
|
];
|
|
1676
|
-
function getQueryMethod(methodName) {
|
|
1677
|
-
switch (methodName) {
|
|
1678
|
-
case 'getElementsByClassName':
|
|
1679
|
-
return getElementsByClassName$1;
|
|
1680
|
-
case 'getElementsByTagName':
|
|
1681
|
-
return getElementsByTagName$1;
|
|
1682
|
-
case 'querySelector':
|
|
1683
|
-
return querySelector$1;
|
|
1684
|
-
case 'querySelectorAll':
|
|
1685
|
-
return querySelectorAll$1;
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
1525
|
// Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
|
|
1689
1526
|
for (const queryMethod of queryMethods) {
|
|
1690
1527
|
queryAndChildGetterDescriptors[queryMethod] = {
|
|
1691
1528
|
value(arg) {
|
|
1692
1529
|
const vm = getAssociatedVM(this);
|
|
1693
|
-
const { elm } = vm;
|
|
1694
|
-
return
|
|
1530
|
+
const { elm, renderer } = vm;
|
|
1531
|
+
return renderer[queryMethod](elm, arg);
|
|
1695
1532
|
},
|
|
1696
1533
|
configurable: true,
|
|
1697
1534
|
enumerable: true,
|
|
@@ -2462,12 +2299,13 @@
|
|
|
2462
2299
|
* SPDX-License-Identifier: MIT
|
|
2463
2300
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2464
2301
|
*/
|
|
2465
|
-
function getUpgradableConstructor(tagName) {
|
|
2302
|
+
function getUpgradableConstructor(tagName, renderer) {
|
|
2303
|
+
const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
|
|
2466
2304
|
// Should never get a tag with upper case letter at this point, the compiler should
|
|
2467
2305
|
// produce only tags with lowercase letters
|
|
2468
2306
|
// But, for backwards compatibility, we will lower case the tagName
|
|
2469
2307
|
tagName = tagName.toLowerCase();
|
|
2470
|
-
let CE = getCustomElement
|
|
2308
|
+
let CE = getCustomElement(tagName);
|
|
2471
2309
|
if (!isUndefined$1(CE)) {
|
|
2472
2310
|
return CE;
|
|
2473
2311
|
}
|
|
@@ -2475,7 +2313,7 @@
|
|
|
2475
2313
|
* LWC Upgradable Element reference to an element that was created
|
|
2476
2314
|
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
2477
2315
|
*/
|
|
2478
|
-
CE = class LWCUpgradableElement extends
|
|
2316
|
+
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
2479
2317
|
constructor(upgradeCallback) {
|
|
2480
2318
|
super();
|
|
2481
2319
|
if (isFunction$1(upgradeCallback)) {
|
|
@@ -2483,7 +2321,7 @@
|
|
|
2483
2321
|
}
|
|
2484
2322
|
}
|
|
2485
2323
|
};
|
|
2486
|
-
defineCustomElement
|
|
2324
|
+
defineCustomElement(tagName, CE);
|
|
2487
2325
|
return CE;
|
|
2488
2326
|
}
|
|
2489
2327
|
|
|
@@ -2508,7 +2346,7 @@
|
|
|
2508
2346
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2509
2347
|
*/
|
|
2510
2348
|
const ColonCharCode = 58;
|
|
2511
|
-
function patchAttributes(oldVnode, vnode) {
|
|
2349
|
+
function patchAttributes(oldVnode, vnode, renderer) {
|
|
2512
2350
|
const { attrs } = vnode.data;
|
|
2513
2351
|
if (isUndefined$1(attrs)) {
|
|
2514
2352
|
return;
|
|
@@ -2518,6 +2356,7 @@
|
|
|
2518
2356
|
return;
|
|
2519
2357
|
}
|
|
2520
2358
|
const { elm } = vnode;
|
|
2359
|
+
const { setAttribute, removeAttribute } = renderer;
|
|
2521
2360
|
for (const key in attrs) {
|
|
2522
2361
|
const cur = attrs[key];
|
|
2523
2362
|
const old = oldAttrs[key];
|
|
@@ -2525,17 +2364,17 @@
|
|
|
2525
2364
|
unlockAttribute(elm, key);
|
|
2526
2365
|
if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
|
|
2527
2366
|
// Assume xml namespace
|
|
2528
|
-
setAttribute
|
|
2367
|
+
setAttribute(elm, key, cur, XML_NAMESPACE);
|
|
2529
2368
|
}
|
|
2530
2369
|
else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
|
|
2531
2370
|
// Assume xlink namespace
|
|
2532
|
-
setAttribute
|
|
2371
|
+
setAttribute(elm, key, cur, XLINK_NAMESPACE);
|
|
2533
2372
|
}
|
|
2534
2373
|
else if (isNull(cur) || isUndefined$1(cur)) {
|
|
2535
|
-
removeAttribute
|
|
2374
|
+
removeAttribute(elm, key);
|
|
2536
2375
|
}
|
|
2537
2376
|
else {
|
|
2538
|
-
setAttribute
|
|
2377
|
+
setAttribute(elm, key, cur);
|
|
2539
2378
|
}
|
|
2540
2379
|
lockAttribute();
|
|
2541
2380
|
}
|
|
@@ -2553,7 +2392,7 @@
|
|
|
2553
2392
|
// instead of relying on internally tracked values.
|
|
2554
2393
|
return sel === 'input' && (key === 'value' || key === 'checked');
|
|
2555
2394
|
}
|
|
2556
|
-
function patchProps(oldVnode, vnode) {
|
|
2395
|
+
function patchProps(oldVnode, vnode, renderer) {
|
|
2557
2396
|
const { props } = vnode.data;
|
|
2558
2397
|
if (isUndefined$1(props)) {
|
|
2559
2398
|
return;
|
|
@@ -2564,13 +2403,14 @@
|
|
|
2564
2403
|
}
|
|
2565
2404
|
const isFirstPatch = isNull(oldVnode);
|
|
2566
2405
|
const { elm, sel } = vnode;
|
|
2406
|
+
const { getProperty, setProperty } = renderer;
|
|
2567
2407
|
for (const key in props) {
|
|
2568
2408
|
const cur = props[key];
|
|
2569
2409
|
// Set the property if it's the first time is is patched or if the previous property is
|
|
2570
2410
|
// different than the one previously set.
|
|
2571
2411
|
if (isFirstPatch ||
|
|
2572
|
-
cur !== (isLiveBindingProp(sel, key) ? getProperty
|
|
2573
|
-
setProperty
|
|
2412
|
+
cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
|
|
2413
|
+
setProperty(elm, key, cur);
|
|
2574
2414
|
}
|
|
2575
2415
|
}
|
|
2576
2416
|
}
|
|
@@ -2611,13 +2451,14 @@
|
|
|
2611
2451
|
classNameToClassMap[className] = map;
|
|
2612
2452
|
return map;
|
|
2613
2453
|
}
|
|
2614
|
-
function patchClassAttribute(oldVnode, vnode) {
|
|
2454
|
+
function patchClassAttribute(oldVnode, vnode, renderer) {
|
|
2615
2455
|
const { elm, data: { className: newClass }, } = vnode;
|
|
2616
2456
|
const oldClass = isNull(oldVnode) ? undefined : oldVnode.data.className;
|
|
2617
2457
|
if (oldClass === newClass) {
|
|
2618
2458
|
return;
|
|
2619
2459
|
}
|
|
2620
|
-
const
|
|
2460
|
+
const { getClassList } = renderer;
|
|
2461
|
+
const classList = getClassList(elm);
|
|
2621
2462
|
const newClassMap = getMapFromClassName(newClass);
|
|
2622
2463
|
const oldClassMap = getMapFromClassName(oldClass);
|
|
2623
2464
|
let name;
|
|
@@ -2641,17 +2482,18 @@
|
|
|
2641
2482
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2642
2483
|
*/
|
|
2643
2484
|
// The style property is a string when defined via an expression in the template.
|
|
2644
|
-
function patchStyleAttribute(oldVnode, vnode) {
|
|
2485
|
+
function patchStyleAttribute(oldVnode, vnode, renderer) {
|
|
2645
2486
|
const { elm, data: { style: newStyle }, } = vnode;
|
|
2646
2487
|
const oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
|
|
2647
2488
|
if (oldStyle === newStyle) {
|
|
2648
2489
|
return;
|
|
2649
2490
|
}
|
|
2491
|
+
const { setAttribute, removeAttribute } = renderer;
|
|
2650
2492
|
if (!isString(newStyle) || newStyle === '') {
|
|
2651
|
-
removeAttribute
|
|
2493
|
+
removeAttribute(elm, 'style');
|
|
2652
2494
|
}
|
|
2653
2495
|
else {
|
|
2654
|
-
setAttribute
|
|
2496
|
+
setAttribute(elm, 'style', newStyle);
|
|
2655
2497
|
}
|
|
2656
2498
|
}
|
|
2657
2499
|
|
|
@@ -2661,14 +2503,15 @@
|
|
|
2661
2503
|
* SPDX-License-Identifier: MIT
|
|
2662
2504
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2663
2505
|
*/
|
|
2664
|
-
function applyEventListeners(vnode) {
|
|
2506
|
+
function applyEventListeners(vnode, renderer) {
|
|
2665
2507
|
const { elm, data: { on }, } = vnode;
|
|
2666
2508
|
if (isUndefined$1(on)) {
|
|
2667
2509
|
return;
|
|
2668
2510
|
}
|
|
2511
|
+
const { addEventListener } = renderer;
|
|
2669
2512
|
for (const name in on) {
|
|
2670
2513
|
const handler = on[name];
|
|
2671
|
-
addEventListener
|
|
2514
|
+
addEventListener(elm, name, handler);
|
|
2672
2515
|
}
|
|
2673
2516
|
}
|
|
2674
2517
|
|
|
@@ -2681,12 +2524,13 @@
|
|
|
2681
2524
|
// The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
|
|
2682
2525
|
// The compiler takes care of transforming the inline classnames into an object. It's faster to set the
|
|
2683
2526
|
// different classnames properties individually instead of via a string.
|
|
2684
|
-
function applyStaticClassAttribute(vnode) {
|
|
2527
|
+
function applyStaticClassAttribute(vnode, renderer) {
|
|
2685
2528
|
const { elm, data: { classMap }, } = vnode;
|
|
2686
2529
|
if (isUndefined$1(classMap)) {
|
|
2687
2530
|
return;
|
|
2688
2531
|
}
|
|
2689
|
-
const
|
|
2532
|
+
const { getClassList } = renderer;
|
|
2533
|
+
const classList = getClassList(elm);
|
|
2690
2534
|
for (const name in classMap) {
|
|
2691
2535
|
classList.add(name);
|
|
2692
2536
|
}
|
|
@@ -2701,14 +2545,15 @@
|
|
|
2701
2545
|
// The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
|
|
2702
2546
|
// The compiler takes care of transforming the inline style into an object. It's faster to set the
|
|
2703
2547
|
// different style properties individually instead of via a string.
|
|
2704
|
-
function applyStaticStyleAttribute(vnode) {
|
|
2548
|
+
function applyStaticStyleAttribute(vnode, renderer) {
|
|
2705
2549
|
const { elm, data: { styleDecls }, } = vnode;
|
|
2706
2550
|
if (isUndefined$1(styleDecls)) {
|
|
2707
2551
|
return;
|
|
2708
2552
|
}
|
|
2553
|
+
const { setCSSStyleProperty } = renderer;
|
|
2709
2554
|
for (let i = 0; i < styleDecls.length; i++) {
|
|
2710
2555
|
const [prop, value, important] = styleDecls[i];
|
|
2711
|
-
setCSSStyleProperty
|
|
2556
|
+
setCSSStyleProperty(elm, prop, value, important);
|
|
2712
2557
|
}
|
|
2713
2558
|
}
|
|
2714
2559
|
|
|
@@ -2718,94 +2563,126 @@
|
|
|
2718
2563
|
* SPDX-License-Identifier: MIT
|
|
2719
2564
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2720
2565
|
*/
|
|
2721
|
-
function patchChildren(c1, c2, parent) {
|
|
2566
|
+
function patchChildren(c1, c2, parent, renderer) {
|
|
2722
2567
|
if (hasDynamicChildren(c2)) {
|
|
2723
|
-
updateDynamicChildren(c1, c2, parent);
|
|
2568
|
+
updateDynamicChildren(c1, c2, parent, renderer);
|
|
2724
2569
|
}
|
|
2725
2570
|
else {
|
|
2726
|
-
updateStaticChildren(c1, c2, parent);
|
|
2571
|
+
updateStaticChildren(c1, c2, parent, renderer);
|
|
2727
2572
|
}
|
|
2728
2573
|
}
|
|
2729
|
-
function patch(n1, n2) {
|
|
2574
|
+
function patch(n1, n2, renderer) {
|
|
2575
|
+
var _a, _b;
|
|
2730
2576
|
if (n1 === n2) {
|
|
2731
2577
|
return;
|
|
2732
2578
|
}
|
|
2733
2579
|
switch (n2.type) {
|
|
2734
2580
|
case 0 /* Text */:
|
|
2735
|
-
|
|
2581
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
2582
|
+
patchText(n1, n2, renderer);
|
|
2736
2583
|
break;
|
|
2737
2584
|
case 1 /* Comment */:
|
|
2738
|
-
|
|
2585
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
2586
|
+
patchComment(n1, n2, renderer);
|
|
2587
|
+
break;
|
|
2588
|
+
case 4 /* Static */:
|
|
2589
|
+
n2.elm = n1.elm;
|
|
2739
2590
|
break;
|
|
2740
2591
|
case 2 /* Element */:
|
|
2741
|
-
patchElement(n1, n2);
|
|
2592
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
2742
2593
|
break;
|
|
2743
2594
|
case 3 /* CustomElement */:
|
|
2744
|
-
patchCustomElement(n1, n2);
|
|
2595
|
+
patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
2745
2596
|
break;
|
|
2746
2597
|
}
|
|
2747
2598
|
}
|
|
2748
|
-
function mount(node, parent, anchor) {
|
|
2599
|
+
function mount(node, parent, renderer, anchor) {
|
|
2600
|
+
var _a, _b;
|
|
2749
2601
|
switch (node.type) {
|
|
2750
2602
|
case 0 /* Text */:
|
|
2751
|
-
|
|
2603
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
2604
|
+
mountText(node, parent, anchor, renderer);
|
|
2752
2605
|
break;
|
|
2753
2606
|
case 1 /* Comment */:
|
|
2754
|
-
|
|
2607
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
2608
|
+
mountComment(node, parent, anchor, renderer);
|
|
2609
|
+
break;
|
|
2610
|
+
case 4 /* Static */:
|
|
2611
|
+
// VStatic cannot have a custom renderer associated to them, using owner's renderer
|
|
2612
|
+
mountStatic(node, parent, anchor, renderer);
|
|
2755
2613
|
break;
|
|
2756
2614
|
case 2 /* Element */:
|
|
2757
|
-
|
|
2615
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
2616
|
+
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
2758
2617
|
break;
|
|
2759
2618
|
case 3 /* CustomElement */:
|
|
2760
|
-
|
|
2619
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
2620
|
+
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
2761
2621
|
break;
|
|
2762
2622
|
}
|
|
2763
2623
|
}
|
|
2764
|
-
function patchText(n1, n2) {
|
|
2624
|
+
function patchText(n1, n2, renderer) {
|
|
2765
2625
|
n2.elm = n1.elm;
|
|
2766
2626
|
if (n2.text !== n1.text) {
|
|
2767
|
-
updateTextContent(n2);
|
|
2627
|
+
updateTextContent(n2, renderer);
|
|
2768
2628
|
}
|
|
2769
2629
|
}
|
|
2770
|
-
function mountText(
|
|
2771
|
-
const { owner } =
|
|
2772
|
-
const
|
|
2773
|
-
|
|
2774
|
-
|
|
2630
|
+
function mountText(vnode, parent, anchor, renderer) {
|
|
2631
|
+
const { owner } = vnode;
|
|
2632
|
+
const { createText } = renderer;
|
|
2633
|
+
const textNode = (vnode.elm = createText(vnode.text));
|
|
2634
|
+
linkNodeToShadow(textNode, owner, renderer);
|
|
2635
|
+
insertNode(textNode, parent, anchor, renderer);
|
|
2775
2636
|
}
|
|
2776
|
-
function patchComment(n1, n2) {
|
|
2637
|
+
function patchComment(n1, n2, renderer) {
|
|
2777
2638
|
n2.elm = n1.elm;
|
|
2778
2639
|
// FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
2779
2640
|
// it is the case today.
|
|
2780
2641
|
if (n2.text !== n1.text) {
|
|
2781
|
-
updateTextContent(n2);
|
|
2642
|
+
updateTextContent(n2, renderer);
|
|
2782
2643
|
}
|
|
2783
2644
|
}
|
|
2784
|
-
function mountComment(
|
|
2785
|
-
const { owner } =
|
|
2786
|
-
const
|
|
2787
|
-
|
|
2788
|
-
|
|
2645
|
+
function mountComment(vnode, parent, anchor, renderer) {
|
|
2646
|
+
const { owner } = vnode;
|
|
2647
|
+
const { createComment } = renderer;
|
|
2648
|
+
const commentNode = (vnode.elm = createComment(vnode.text));
|
|
2649
|
+
linkNodeToShadow(commentNode, owner, renderer);
|
|
2650
|
+
insertNode(commentNode, parent, anchor, renderer);
|
|
2789
2651
|
}
|
|
2790
|
-
function mountElement(vnode, parent, anchor) {
|
|
2652
|
+
function mountElement(vnode, parent, anchor, renderer) {
|
|
2791
2653
|
const { sel, owner, data: { svg }, } = vnode;
|
|
2654
|
+
const { createElement } = renderer;
|
|
2792
2655
|
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
2793
|
-
const elm = createElement
|
|
2794
|
-
linkNodeToShadow(elm, owner);
|
|
2795
|
-
fallbackElmHook(elm, vnode);
|
|
2656
|
+
const elm = createElement(sel, namespace);
|
|
2657
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
2658
|
+
fallbackElmHook(elm, vnode, renderer);
|
|
2796
2659
|
vnode.elm = elm;
|
|
2797
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
2798
|
-
insertNode(elm, parent, anchor);
|
|
2799
|
-
mountVNodes(vnode.children, elm, null);
|
|
2660
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
2661
|
+
insertNode(elm, parent, anchor, renderer);
|
|
2662
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
2800
2663
|
}
|
|
2801
|
-
function patchElement(n1, n2) {
|
|
2664
|
+
function patchElement(n1, n2, renderer) {
|
|
2802
2665
|
const elm = (n2.elm = n1.elm);
|
|
2803
|
-
patchElementPropsAndAttrs$1(n1, n2);
|
|
2804
|
-
patchChildren(n1.children, n2.children, elm);
|
|
2666
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
2667
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
2805
2668
|
}
|
|
2806
|
-
function
|
|
2669
|
+
function mountStatic(vnode, parent, anchor, renderer) {
|
|
2670
|
+
const { owner } = vnode;
|
|
2671
|
+
const { cloneNode, isSyntheticShadowDefined } = renderer;
|
|
2672
|
+
const elm = (vnode.elm = cloneNode(vnode.fragment, true));
|
|
2673
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
2674
|
+
// Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
2675
|
+
const { renderMode, shadowMode } = owner;
|
|
2676
|
+
if (isSyntheticShadowDefined) {
|
|
2677
|
+
if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
|
|
2678
|
+
elm[KEY__SHADOW_STATIC] = true;
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
insertNode(elm, parent, anchor, renderer);
|
|
2682
|
+
}
|
|
2683
|
+
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
2807
2684
|
const { sel, owner } = vnode;
|
|
2808
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
2685
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
2809
2686
|
/**
|
|
2810
2687
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
2811
2688
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -2815,9 +2692,9 @@
|
|
|
2815
2692
|
let vm;
|
|
2816
2693
|
const elm = new UpgradableConstructor((elm) => {
|
|
2817
2694
|
// the custom element from the registry is expecting an upgrade callback
|
|
2818
|
-
vm = createViewModelHook(elm, vnode);
|
|
2695
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
2819
2696
|
});
|
|
2820
|
-
linkNodeToShadow(elm, owner);
|
|
2697
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
2821
2698
|
vnode.elm = elm;
|
|
2822
2699
|
vnode.vm = vm;
|
|
2823
2700
|
if (vm) {
|
|
@@ -2826,20 +2703,20 @@
|
|
|
2826
2703
|
else if (vnode.ctor !== UpgradableConstructor) {
|
|
2827
2704
|
throw new TypeError(`Incorrect Component Constructor`);
|
|
2828
2705
|
}
|
|
2829
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
2830
|
-
insertNode(elm, parent, anchor);
|
|
2706
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
2707
|
+
insertNode(elm, parent, anchor, renderer);
|
|
2831
2708
|
if (vm) {
|
|
2832
2709
|
runConnectedCallback(vm);
|
|
2833
2710
|
}
|
|
2834
|
-
mountVNodes(vnode.children, elm, null);
|
|
2711
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
2835
2712
|
if (vm) {
|
|
2836
2713
|
appendVM(vm);
|
|
2837
2714
|
}
|
|
2838
2715
|
}
|
|
2839
|
-
function patchCustomElement(n1, n2) {
|
|
2716
|
+
function patchCustomElement(n1, n2, renderer) {
|
|
2840
2717
|
const elm = (n2.elm = n1.elm);
|
|
2841
2718
|
const vm = (n2.vm = n1.vm);
|
|
2842
|
-
patchElementPropsAndAttrs$1(n1, n2);
|
|
2719
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
2843
2720
|
if (!isUndefined$1(vm)) {
|
|
2844
2721
|
// in fallback mode, the allocation will always set children to
|
|
2845
2722
|
// empty and delegate the real allocation to the slot elements
|
|
@@ -2847,33 +2724,38 @@
|
|
|
2847
2724
|
}
|
|
2848
2725
|
// in fallback mode, the children will be always empty, so, nothing
|
|
2849
2726
|
// will happen, but in native, it does allocate the light dom
|
|
2850
|
-
patchChildren(n1.children, n2.children, elm);
|
|
2727
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
2851
2728
|
if (!isUndefined$1(vm)) {
|
|
2852
2729
|
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
2853
2730
|
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
2854
2731
|
rerenderVM(vm);
|
|
2855
2732
|
}
|
|
2856
2733
|
}
|
|
2857
|
-
function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
|
|
2734
|
+
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
2858
2735
|
for (; start < end; ++start) {
|
|
2859
2736
|
const vnode = vnodes[start];
|
|
2860
2737
|
if (isVNode(vnode)) {
|
|
2861
|
-
mount(vnode, parent, anchor);
|
|
2738
|
+
mount(vnode, parent, renderer, anchor);
|
|
2862
2739
|
}
|
|
2863
2740
|
}
|
|
2864
2741
|
}
|
|
2865
|
-
function unmount(vnode, parent, doRemove = false) {
|
|
2742
|
+
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
2866
2743
|
const { type, elm, sel } = vnode;
|
|
2867
2744
|
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
2868
2745
|
// subtree root, is the only element worth unmounting from the subtree.
|
|
2869
2746
|
if (doRemove) {
|
|
2870
|
-
|
|
2747
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
2748
|
+
// but the removal used here is from the owner instead.
|
|
2749
|
+
removeNode(elm, parent, renderer);
|
|
2871
2750
|
}
|
|
2872
|
-
const removeChildren = sel === 'slot'; // slot content is removed to trigger slotchange event when removing slot
|
|
2873
2751
|
switch (type) {
|
|
2874
|
-
case 2 /* Element */:
|
|
2875
|
-
|
|
2752
|
+
case 2 /* Element */: {
|
|
2753
|
+
// Slot content is removed to trigger slotchange event when removing slot.
|
|
2754
|
+
// Only required for synthetic shadow.
|
|
2755
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
|
|
2756
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
2876
2757
|
break;
|
|
2758
|
+
}
|
|
2877
2759
|
case 3 /* CustomElement */: {
|
|
2878
2760
|
const { vm } = vnode;
|
|
2879
2761
|
// No need to unmount the children here, `removeVM` will take care of removing the
|
|
@@ -2884,11 +2766,11 @@
|
|
|
2884
2766
|
}
|
|
2885
2767
|
}
|
|
2886
2768
|
}
|
|
2887
|
-
function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
|
|
2769
|
+
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
2888
2770
|
for (; start < end; ++start) {
|
|
2889
2771
|
const ch = vnodes[start];
|
|
2890
2772
|
if (isVNode(ch)) {
|
|
2891
|
-
unmount(ch, parent, doRemove);
|
|
2773
|
+
unmount(ch, parent, renderer, doRemove);
|
|
2892
2774
|
}
|
|
2893
2775
|
}
|
|
2894
2776
|
}
|
|
@@ -2902,48 +2784,53 @@
|
|
|
2902
2784
|
elm.$shadowToken$ = token;
|
|
2903
2785
|
}
|
|
2904
2786
|
// Set the scope token class for *.scoped.css styles
|
|
2905
|
-
function setScopeTokenClassIfNecessary(elm, owner) {
|
|
2787
|
+
function setScopeTokenClassIfNecessary(elm, owner, renderer) {
|
|
2906
2788
|
const { cmpTemplate, context } = owner;
|
|
2789
|
+
const { getClassList } = renderer;
|
|
2907
2790
|
const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
|
|
2908
2791
|
if (!isUndefined$1(token) && context.hasScopedStyles) {
|
|
2909
|
-
|
|
2792
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
2793
|
+
// probably we should have a renderer api for just the add operation
|
|
2794
|
+
getClassList(elm).add(token);
|
|
2910
2795
|
}
|
|
2911
2796
|
}
|
|
2912
|
-
function linkNodeToShadow(elm, owner) {
|
|
2797
|
+
function linkNodeToShadow(elm, owner, renderer) {
|
|
2913
2798
|
const { renderRoot, renderMode, shadowMode } = owner;
|
|
2799
|
+
const { isSyntheticShadowDefined } = renderer;
|
|
2914
2800
|
// TODO [#1164]: this should eventually be done by the polyfill directly
|
|
2915
|
-
if (isSyntheticShadowDefined
|
|
2801
|
+
if (isSyntheticShadowDefined) {
|
|
2916
2802
|
if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
|
|
2917
2803
|
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
2918
2804
|
}
|
|
2919
2805
|
}
|
|
2920
2806
|
}
|
|
2921
|
-
function updateTextContent(vnode) {
|
|
2807
|
+
function updateTextContent(vnode, renderer) {
|
|
2922
2808
|
const { elm, text } = vnode;
|
|
2923
|
-
setText
|
|
2809
|
+
const { setText } = renderer;
|
|
2810
|
+
setText(elm, text);
|
|
2924
2811
|
}
|
|
2925
|
-
function insertNode(node, parent, anchor) {
|
|
2926
|
-
insert
|
|
2812
|
+
function insertNode(node, parent, anchor, renderer) {
|
|
2813
|
+
renderer.insert(node, parent, anchor);
|
|
2927
2814
|
}
|
|
2928
|
-
function removeNode(node, parent) {
|
|
2929
|
-
remove
|
|
2815
|
+
function removeNode(node, parent, renderer) {
|
|
2816
|
+
renderer.remove(node, parent);
|
|
2930
2817
|
}
|
|
2931
|
-
function patchElementPropsAndAttrs$1(oldVnode, vnode) {
|
|
2818
|
+
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
2932
2819
|
if (isNull(oldVnode)) {
|
|
2933
|
-
applyEventListeners(vnode);
|
|
2934
|
-
applyStaticClassAttribute(vnode);
|
|
2935
|
-
applyStaticStyleAttribute(vnode);
|
|
2820
|
+
applyEventListeners(vnode, renderer);
|
|
2821
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
2822
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
2936
2823
|
}
|
|
2937
2824
|
// Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
2938
2825
|
// value is set before type=radio.
|
|
2939
|
-
patchClassAttribute(oldVnode, vnode);
|
|
2940
|
-
patchStyleAttribute(oldVnode, vnode);
|
|
2941
|
-
patchAttributes(oldVnode, vnode);
|
|
2942
|
-
patchProps(oldVnode, vnode);
|
|
2826
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
2827
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
2828
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
2829
|
+
patchProps(oldVnode, vnode, renderer);
|
|
2943
2830
|
}
|
|
2944
|
-
function fallbackElmHook(elm, vnode) {
|
|
2831
|
+
function fallbackElmHook(elm, vnode, renderer) {
|
|
2945
2832
|
const { owner } = vnode;
|
|
2946
|
-
setScopeTokenClassIfNecessary(elm, owner);
|
|
2833
|
+
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
2947
2834
|
if (owner.shadowMode === 1 /* Synthetic */) {
|
|
2948
2835
|
const { data: { context }, } = vnode;
|
|
2949
2836
|
const { stylesheetToken } = owner.context;
|
|
@@ -2983,7 +2870,7 @@
|
|
|
2983
2870
|
vnode.children = EmptyArray;
|
|
2984
2871
|
}
|
|
2985
2872
|
}
|
|
2986
|
-
function createViewModelHook(elm, vnode) {
|
|
2873
|
+
function createViewModelHook(elm, vnode, renderer) {
|
|
2987
2874
|
let vm = getAssociatedVMIfPresent(elm);
|
|
2988
2875
|
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
2989
2876
|
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
@@ -2992,7 +2879,7 @@
|
|
|
2992
2879
|
return vm;
|
|
2993
2880
|
}
|
|
2994
2881
|
const { sel, mode, ctor, owner } = vnode;
|
|
2995
|
-
setScopeTokenClassIfNecessary(elm, owner);
|
|
2882
|
+
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
2996
2883
|
if (owner.shadowMode === 1 /* Synthetic */) {
|
|
2997
2884
|
const { stylesheetToken } = owner.context;
|
|
2998
2885
|
// when running in synthetic shadow mode, we need to set the shadowToken value
|
|
@@ -3001,7 +2888,7 @@
|
|
|
3001
2888
|
setElementShadowToken(elm, stylesheetToken);
|
|
3002
2889
|
}
|
|
3003
2890
|
}
|
|
3004
|
-
vm = createVM(elm, ctor, {
|
|
2891
|
+
vm = createVM(elm, ctor, renderer, {
|
|
3005
2892
|
mode,
|
|
3006
2893
|
owner,
|
|
3007
2894
|
tagName: sel,
|
|
@@ -3073,7 +2960,7 @@
|
|
|
3073
2960
|
}
|
|
3074
2961
|
return map;
|
|
3075
2962
|
}
|
|
3076
|
-
function updateDynamicChildren(oldCh, newCh, parent) {
|
|
2963
|
+
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
3077
2964
|
let oldStartIdx = 0;
|
|
3078
2965
|
let newStartIdx = 0;
|
|
3079
2966
|
let oldEndIdx = oldCh.length - 1;
|
|
@@ -3102,26 +2989,26 @@
|
|
|
3102
2989
|
newEndVnode = newCh[--newEndIdx];
|
|
3103
2990
|
}
|
|
3104
2991
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
3105
|
-
patch(oldStartVnode, newStartVnode);
|
|
2992
|
+
patch(oldStartVnode, newStartVnode, renderer);
|
|
3106
2993
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3107
2994
|
newStartVnode = newCh[++newStartIdx];
|
|
3108
2995
|
}
|
|
3109
2996
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
3110
|
-
patch(oldEndVnode, newEndVnode);
|
|
2997
|
+
patch(oldEndVnode, newEndVnode, renderer);
|
|
3111
2998
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3112
2999
|
newEndVnode = newCh[--newEndIdx];
|
|
3113
3000
|
}
|
|
3114
3001
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
3115
3002
|
// Vnode moved right
|
|
3116
|
-
patch(oldStartVnode, newEndVnode);
|
|
3117
|
-
insertNode(oldStartVnode.elm, parent, nextSibling
|
|
3003
|
+
patch(oldStartVnode, newEndVnode, renderer);
|
|
3004
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
3118
3005
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3119
3006
|
newEndVnode = newCh[--newEndIdx];
|
|
3120
3007
|
}
|
|
3121
3008
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
3122
3009
|
// Vnode moved left
|
|
3123
|
-
patch(oldEndVnode, newStartVnode);
|
|
3124
|
-
insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
|
|
3010
|
+
patch(oldEndVnode, newStartVnode, renderer);
|
|
3011
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
3125
3012
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3126
3013
|
newStartVnode = newCh[++newStartIdx];
|
|
3127
3014
|
}
|
|
@@ -3132,7 +3019,7 @@
|
|
|
3132
3019
|
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
3133
3020
|
if (isUndefined$1(idxInOld)) {
|
|
3134
3021
|
// New element
|
|
3135
|
-
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
3022
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3136
3023
|
newStartVnode = newCh[++newStartIdx];
|
|
3137
3024
|
}
|
|
3138
3025
|
else {
|
|
@@ -3140,10 +3027,10 @@
|
|
|
3140
3027
|
if (isVNode(elmToMove)) {
|
|
3141
3028
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
3142
3029
|
// New element
|
|
3143
|
-
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
3030
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3144
3031
|
}
|
|
3145
3032
|
else {
|
|
3146
|
-
patch(elmToMove, newStartVnode);
|
|
3033
|
+
patch(elmToMove, newStartVnode, renderer);
|
|
3147
3034
|
// Delete the old child, but copy the array since it is read-only.
|
|
3148
3035
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
3149
3036
|
// so we only care about the `oldCh` object inside this function.
|
|
@@ -3155,7 +3042,7 @@
|
|
|
3155
3042
|
}
|
|
3156
3043
|
// We've already cloned at least once, so it's no longer read-only
|
|
3157
3044
|
oldCh[idxInOld] = undefined;
|
|
3158
|
-
insertNode(elmToMove.elm, parent, oldStartVnode.elm);
|
|
3045
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
3159
3046
|
}
|
|
3160
3047
|
}
|
|
3161
3048
|
newStartVnode = newCh[++newStartIdx];
|
|
@@ -3172,25 +3059,25 @@
|
|
|
3172
3059
|
n = newCh[++i];
|
|
3173
3060
|
} while (!isVNode(n) && i < newChEnd);
|
|
3174
3061
|
before = isVNode(n) ? n.elm : null;
|
|
3175
|
-
mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
|
|
3062
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
3176
3063
|
}
|
|
3177
3064
|
else {
|
|
3178
|
-
unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
|
|
3065
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
3179
3066
|
}
|
|
3180
3067
|
}
|
|
3181
3068
|
}
|
|
3182
|
-
function updateStaticChildren(c1, c2, parent) {
|
|
3069
|
+
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
3183
3070
|
const c1Length = c1.length;
|
|
3184
3071
|
const c2Length = c2.length;
|
|
3185
3072
|
if (c1Length === 0) {
|
|
3186
3073
|
// the old list is empty, we can directly insert anything new
|
|
3187
|
-
mountVNodes(c2, parent, null);
|
|
3074
|
+
mountVNodes(c2, parent, renderer, null);
|
|
3188
3075
|
return;
|
|
3189
3076
|
}
|
|
3190
3077
|
if (c2Length === 0) {
|
|
3191
3078
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
3192
3079
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
3193
|
-
unmountVNodes(c1, parent, true);
|
|
3080
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
3194
3081
|
return;
|
|
3195
3082
|
}
|
|
3196
3083
|
// if the old list is not empty, the new list MUST have the same
|
|
@@ -3203,16 +3090,16 @@
|
|
|
3203
3090
|
if (isVNode(n1)) {
|
|
3204
3091
|
if (isVNode(n2)) {
|
|
3205
3092
|
// both vnodes are equivalent, and we just need to patch them
|
|
3206
|
-
patch(n1, n2);
|
|
3093
|
+
patch(n1, n2, renderer);
|
|
3207
3094
|
anchor = n2.elm;
|
|
3208
3095
|
}
|
|
3209
3096
|
else {
|
|
3210
3097
|
// removing the old vnode since the new one is null
|
|
3211
|
-
unmount(n1, parent, true);
|
|
3098
|
+
unmount(n1, parent, renderer, true);
|
|
3212
3099
|
}
|
|
3213
3100
|
}
|
|
3214
3101
|
else if (isVNode(n2)) {
|
|
3215
|
-
mount(n2, parent, anchor);
|
|
3102
|
+
mount(n2, parent, renderer, anchor);
|
|
3216
3103
|
anchor = n2.elm;
|
|
3217
3104
|
}
|
|
3218
3105
|
}
|
|
@@ -3229,6 +3116,17 @@
|
|
|
3229
3116
|
function addVNodeToChildLWC(vnode) {
|
|
3230
3117
|
ArrayPush$1.call(getVMBeingRendered().velements, vnode);
|
|
3231
3118
|
}
|
|
3119
|
+
// [st]atic node
|
|
3120
|
+
function st(fragment, key) {
|
|
3121
|
+
return {
|
|
3122
|
+
type: 4 /* Static */,
|
|
3123
|
+
sel: undefined,
|
|
3124
|
+
key,
|
|
3125
|
+
elm: undefined,
|
|
3126
|
+
fragment,
|
|
3127
|
+
owner: getVMBeingRendered(),
|
|
3128
|
+
};
|
|
3129
|
+
}
|
|
3232
3130
|
// [h]tml node
|
|
3233
3131
|
function h(sel, data, children = EmptyArray) {
|
|
3234
3132
|
const vmBeingRendered = getVMBeingRendered();
|
|
@@ -3505,6 +3403,7 @@
|
|
|
3505
3403
|
co,
|
|
3506
3404
|
dc,
|
|
3507
3405
|
ti,
|
|
3406
|
+
st,
|
|
3508
3407
|
gid,
|
|
3509
3408
|
fid,
|
|
3510
3409
|
shc,
|
|
@@ -3528,7 +3427,7 @@
|
|
|
3528
3427
|
}, [api.t(content)]);
|
|
3529
3428
|
}
|
|
3530
3429
|
function updateStylesheetToken(vm, template) {
|
|
3531
|
-
const { elm, context, renderMode, shadowMode } = vm;
|
|
3430
|
+
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
3532
3431
|
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
3533
3432
|
const isSyntheticShadow = renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */;
|
|
3534
3433
|
const { hasScopedStyles } = context;
|
|
@@ -3539,10 +3438,10 @@
|
|
|
3539
3438
|
const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
|
|
3540
3439
|
if (!isUndefined$1(oldToken)) {
|
|
3541
3440
|
if (oldHasTokenInClass) {
|
|
3542
|
-
getClassList
|
|
3441
|
+
getClassList(elm).remove(makeHostToken(oldToken));
|
|
3543
3442
|
}
|
|
3544
3443
|
if (oldHasTokenInAttribute) {
|
|
3545
|
-
removeAttribute
|
|
3444
|
+
removeAttribute(elm, makeHostToken(oldToken));
|
|
3546
3445
|
}
|
|
3547
3446
|
}
|
|
3548
3447
|
// Apply the new template styling token to the host element, if the new template has any
|
|
@@ -3553,11 +3452,11 @@
|
|
|
3553
3452
|
// Set the new styling token on the host element
|
|
3554
3453
|
if (!isUndefined$1(newToken)) {
|
|
3555
3454
|
if (hasScopedStyles) {
|
|
3556
|
-
getClassList
|
|
3455
|
+
getClassList(elm).add(makeHostToken(newToken));
|
|
3557
3456
|
newHasTokenInClass = true;
|
|
3558
3457
|
}
|
|
3559
3458
|
if (isSyntheticShadow) {
|
|
3560
|
-
setAttribute
|
|
3459
|
+
setAttribute(elm, makeHostToken(newToken), '');
|
|
3561
3460
|
newHasTokenInAttribute = true;
|
|
3562
3461
|
}
|
|
3563
3462
|
}
|
|
@@ -3637,19 +3536,18 @@
|
|
|
3637
3536
|
return owner;
|
|
3638
3537
|
}
|
|
3639
3538
|
function createStylesheet(vm, stylesheets) {
|
|
3640
|
-
const { renderMode, shadowMode } = vm;
|
|
3539
|
+
const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
|
|
3641
3540
|
if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
|
|
3642
3541
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3643
|
-
insertStylesheet
|
|
3542
|
+
insertStylesheet(stylesheets[i]);
|
|
3644
3543
|
}
|
|
3645
3544
|
}
|
|
3646
|
-
else if (ssr
|
|
3545
|
+
else if (ssr || vm.hydrated) {
|
|
3647
3546
|
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3648
3547
|
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3649
3548
|
// the first time the VM renders.
|
|
3650
3549
|
// native shadow or light DOM, SSR
|
|
3651
|
-
|
|
3652
|
-
return createInlineStyleVNode(combinedStylesheetContent);
|
|
3550
|
+
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
3653
3551
|
}
|
|
3654
3552
|
else {
|
|
3655
3553
|
// native shadow or light DOM, DOM renderer
|
|
@@ -3657,7 +3555,7 @@
|
|
|
3657
3555
|
// null root means a global style
|
|
3658
3556
|
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
3659
3557
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3660
|
-
insertStylesheet
|
|
3558
|
+
insertStylesheet(stylesheets[i], target);
|
|
3661
3559
|
}
|
|
3662
3560
|
}
|
|
3663
3561
|
return null;
|
|
@@ -3735,6 +3633,59 @@
|
|
|
3735
3633
|
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"`);
|
|
3736
3634
|
}
|
|
3737
3635
|
}
|
|
3636
|
+
function buildParseFragmentFn(createFragmentFn) {
|
|
3637
|
+
return (strings, ...keys) => {
|
|
3638
|
+
const cache = create(null);
|
|
3639
|
+
return function () {
|
|
3640
|
+
const { context: { hasScopedStyles, stylesheetToken }, shadowMode, renderer, } = getVMBeingRendered();
|
|
3641
|
+
const hasStyleToken = !isUndefined$1(stylesheetToken);
|
|
3642
|
+
const isSyntheticShadow = shadowMode === 1 /* Synthetic */;
|
|
3643
|
+
let cacheKey = 0;
|
|
3644
|
+
if (hasStyleToken && hasScopedStyles) {
|
|
3645
|
+
cacheKey |= 1 /* HAS_SCOPED_STYLE */;
|
|
3646
|
+
}
|
|
3647
|
+
if (hasStyleToken && isSyntheticShadow) {
|
|
3648
|
+
cacheKey |= 2 /* SHADOW_MODE_SYNTHETIC */;
|
|
3649
|
+
}
|
|
3650
|
+
if (!isUndefined$1(cache[cacheKey])) {
|
|
3651
|
+
return cache[cacheKey];
|
|
3652
|
+
}
|
|
3653
|
+
const classToken = hasScopedStyles && hasStyleToken ? ' ' + stylesheetToken : '';
|
|
3654
|
+
const classAttrToken = hasScopedStyles && hasStyleToken ? ` class="${stylesheetToken}"` : '';
|
|
3655
|
+
const attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetToken : '';
|
|
3656
|
+
let htmlFragment = '';
|
|
3657
|
+
for (let i = 0, n = keys.length; i < n; i++) {
|
|
3658
|
+
switch (keys[i]) {
|
|
3659
|
+
case 0: // styleToken in existing class attr
|
|
3660
|
+
htmlFragment += strings[i] + classToken;
|
|
3661
|
+
break;
|
|
3662
|
+
case 1: // styleToken for added class attr
|
|
3663
|
+
htmlFragment += strings[i] + classAttrToken;
|
|
3664
|
+
break;
|
|
3665
|
+
case 2: // styleToken as attr
|
|
3666
|
+
htmlFragment += strings[i] + attrToken;
|
|
3667
|
+
break;
|
|
3668
|
+
case 3: // ${1}${2}
|
|
3669
|
+
htmlFragment += strings[i] + classAttrToken + attrToken;
|
|
3670
|
+
break;
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
htmlFragment += strings[strings.length - 1];
|
|
3674
|
+
cache[cacheKey] = createFragmentFn(htmlFragment, renderer);
|
|
3675
|
+
return cache[cacheKey];
|
|
3676
|
+
};
|
|
3677
|
+
};
|
|
3678
|
+
}
|
|
3679
|
+
// Note: at the moment this code executes, we don't have a renderer yet.
|
|
3680
|
+
const parseFragment = buildParseFragmentFn((html, renderer) => {
|
|
3681
|
+
const { createFragment } = renderer;
|
|
3682
|
+
return createFragment(html);
|
|
3683
|
+
});
|
|
3684
|
+
const parseSVGFragment = buildParseFragmentFn((html, renderer) => {
|
|
3685
|
+
const { createFragment, getFirstChild } = renderer;
|
|
3686
|
+
const fragment = createFragment('<svg>' + html + '</svg>');
|
|
3687
|
+
return getFirstChild(fragment);
|
|
3688
|
+
});
|
|
3738
3689
|
function evaluateTemplate(vm, html) {
|
|
3739
3690
|
const isUpdatingTemplateInception = isUpdatingTemplate;
|
|
3740
3691
|
const vmOfTemplateBeingUpdatedInception = vmBeingRendered;
|
|
@@ -3772,7 +3723,7 @@
|
|
|
3772
3723
|
// Evaluate, create stylesheet and cache the produced VNode for future
|
|
3773
3724
|
// re-rendering.
|
|
3774
3725
|
const stylesheetsContent = getStylesheetsContent(vm, html);
|
|
3775
|
-
context.
|
|
3726
|
+
context.styleVNodes =
|
|
3776
3727
|
stylesheetsContent.length === 0
|
|
3777
3728
|
? null
|
|
3778
3729
|
: createStylesheet(vm, stylesheetsContent);
|
|
@@ -3784,9 +3735,9 @@
|
|
|
3784
3735
|
// Set the global flag that template is being updated
|
|
3785
3736
|
isUpdatingTemplate = true;
|
|
3786
3737
|
vnodes = html.call(undefined, api, component, cmpSlots, context.tplCache);
|
|
3787
|
-
const {
|
|
3788
|
-
if (!isNull(
|
|
3789
|
-
ArrayUnshift.
|
|
3738
|
+
const { styleVNodes } = context;
|
|
3739
|
+
if (!isNull(styleVNodes)) {
|
|
3740
|
+
ArrayUnshift.apply(vnodes, styleVNodes);
|
|
3790
3741
|
}
|
|
3791
3742
|
});
|
|
3792
3743
|
}, () => {
|
|
@@ -4056,9 +4007,20 @@
|
|
|
4056
4007
|
|
|
4057
4008
|
resetComponentStateWhenRemoved(vm);
|
|
4058
4009
|
}
|
|
4059
|
-
function createVM(elm, ctor, options) {
|
|
4060
|
-
var _a;
|
|
4061
4010
|
|
|
4011
|
+
function getNearestShadowAncestor(vm) {
|
|
4012
|
+
let ancestor = vm.owner;
|
|
4013
|
+
|
|
4014
|
+
while (!isNull(ancestor) && ancestor.renderMode === 0
|
|
4015
|
+
/* Light */
|
|
4016
|
+
) {
|
|
4017
|
+
ancestor = ancestor.owner;
|
|
4018
|
+
}
|
|
4019
|
+
|
|
4020
|
+
return ancestor;
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
function createVM(elm, ctor, renderer, options) {
|
|
4062
4024
|
const {
|
|
4063
4025
|
mode,
|
|
4064
4026
|
owner,
|
|
@@ -4088,28 +4050,29 @@
|
|
|
4088
4050
|
cmpTemplate: null,
|
|
4089
4051
|
hydrated: Boolean(hydrated),
|
|
4090
4052
|
renderMode: def.renderMode,
|
|
4091
|
-
shadowMode: computeShadowMode(def, owner),
|
|
4092
|
-
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,
|
|
4093
4053
|
context: {
|
|
4094
4054
|
stylesheetToken: undefined,
|
|
4095
4055
|
hasTokenInClass: undefined,
|
|
4096
4056
|
hasTokenInAttribute: undefined,
|
|
4097
4057
|
hasScopedStyles: undefined,
|
|
4098
|
-
|
|
4058
|
+
styleVNodes: null,
|
|
4099
4059
|
tplCache: EmptyObject,
|
|
4100
4060
|
wiredConnecting: EmptyArray,
|
|
4101
4061
|
wiredDisconnecting: EmptyArray
|
|
4102
4062
|
},
|
|
4103
4063
|
// Properties set right after VM creation.
|
|
4104
4064
|
tro: null,
|
|
4065
|
+
shadowMode: null,
|
|
4105
4066
|
// Properties set by the LightningElement constructor.
|
|
4106
4067
|
component: null,
|
|
4107
4068
|
shadowRoot: null,
|
|
4108
4069
|
renderRoot: null,
|
|
4109
4070
|
callHook,
|
|
4110
4071
|
setHook,
|
|
4111
|
-
getHook
|
|
4072
|
+
getHook,
|
|
4073
|
+
renderer
|
|
4112
4074
|
};
|
|
4075
|
+
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
4113
4076
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
4114
4077
|
|
|
4115
4078
|
|
|
@@ -4122,12 +4085,17 @@
|
|
|
4122
4085
|
return vm;
|
|
4123
4086
|
}
|
|
4124
4087
|
|
|
4125
|
-
function computeShadowMode(
|
|
4126
|
-
|
|
4127
|
-
|
|
4088
|
+
function computeShadowMode(vm, renderer) {
|
|
4089
|
+
const {
|
|
4090
|
+
def
|
|
4091
|
+
} = vm;
|
|
4092
|
+
const {
|
|
4093
|
+
isSyntheticShadowDefined,
|
|
4094
|
+
isNativeShadowDefined
|
|
4095
|
+
} = renderer;
|
|
4128
4096
|
let shadowMode;
|
|
4129
4097
|
|
|
4130
|
-
if (isSyntheticShadowDefined
|
|
4098
|
+
if (isSyntheticShadowDefined) {
|
|
4131
4099
|
if (def.renderMode === 0
|
|
4132
4100
|
/* Light */
|
|
4133
4101
|
) {
|
|
@@ -4136,7 +4104,7 @@
|
|
|
4136
4104
|
shadowMode = 0
|
|
4137
4105
|
/* Native */
|
|
4138
4106
|
;
|
|
4139
|
-
} else if (isNativeShadowDefined
|
|
4107
|
+
} else if (isNativeShadowDefined) {
|
|
4140
4108
|
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
4141
4109
|
// the if-condition.
|
|
4142
4110
|
if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
@@ -4147,13 +4115,23 @@
|
|
|
4147
4115
|
/* Native */
|
|
4148
4116
|
;
|
|
4149
4117
|
} else {
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4118
|
+
const shadowAncestor = getNearestShadowAncestor(vm);
|
|
4119
|
+
|
|
4120
|
+
if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
|
|
4121
|
+
/* Native */
|
|
4122
|
+
) {
|
|
4123
|
+
// Transitive support for native Shadow DOM. A component in native mode
|
|
4124
|
+
// transitively opts all of its descendants into native.
|
|
4125
|
+
shadowMode = 0
|
|
4126
|
+
/* Native */
|
|
4127
|
+
;
|
|
4128
|
+
} else {
|
|
4129
|
+
// Synthetic if neither this component nor any of its ancestors are configured
|
|
4130
|
+
// to be native.
|
|
4131
|
+
shadowMode = 1
|
|
4132
|
+
/* Synthetic */
|
|
4133
|
+
;
|
|
4134
|
+
}
|
|
4157
4135
|
}
|
|
4158
4136
|
} else {
|
|
4159
4137
|
shadowMode = 1
|
|
@@ -4200,7 +4178,8 @@
|
|
|
4200
4178
|
function patchShadowRoot(vm, newCh) {
|
|
4201
4179
|
const {
|
|
4202
4180
|
renderRoot,
|
|
4203
|
-
children: oldCh
|
|
4181
|
+
children: oldCh,
|
|
4182
|
+
renderer
|
|
4204
4183
|
} = vm; // caching the new children collection
|
|
4205
4184
|
|
|
4206
4185
|
vm.children = newCh;
|
|
@@ -4216,7 +4195,7 @@
|
|
|
4216
4195
|
, vm);
|
|
4217
4196
|
}, () => {
|
|
4218
4197
|
// job
|
|
4219
|
-
patchChildren(oldCh, newCh, renderRoot);
|
|
4198
|
+
patchChildren(oldCh, newCh, renderRoot, renderer);
|
|
4220
4199
|
}, () => {
|
|
4221
4200
|
// post
|
|
4222
4201
|
logOperationEnd(2
|
|
@@ -4241,10 +4220,13 @@
|
|
|
4241
4220
|
const {
|
|
4242
4221
|
def: {
|
|
4243
4222
|
renderedCallback
|
|
4223
|
+
},
|
|
4224
|
+
renderer: {
|
|
4225
|
+
ssr
|
|
4244
4226
|
}
|
|
4245
4227
|
} = vm;
|
|
4246
4228
|
|
|
4247
|
-
if (isTrue(ssr
|
|
4229
|
+
if (isTrue(ssr)) {
|
|
4248
4230
|
return;
|
|
4249
4231
|
}
|
|
4250
4232
|
|
|
@@ -4469,14 +4451,17 @@
|
|
|
4469
4451
|
function resetComponentRoot(vm) {
|
|
4470
4452
|
const {
|
|
4471
4453
|
children,
|
|
4472
|
-
renderRoot
|
|
4454
|
+
renderRoot,
|
|
4455
|
+
renderer: {
|
|
4456
|
+
remove
|
|
4457
|
+
}
|
|
4473
4458
|
} = vm;
|
|
4474
4459
|
|
|
4475
4460
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
4476
4461
|
const child = children[i];
|
|
4477
4462
|
|
|
4478
4463
|
if (!isNull(child) && !isUndefined$1(child.elm)) {
|
|
4479
|
-
remove
|
|
4464
|
+
remove(child.elm, renderRoot);
|
|
4480
4465
|
}
|
|
4481
4466
|
}
|
|
4482
4467
|
|
|
@@ -4485,7 +4470,13 @@
|
|
|
4485
4470
|
vm.velements = EmptyArray;
|
|
4486
4471
|
}
|
|
4487
4472
|
function scheduleRehydration(vm) {
|
|
4488
|
-
|
|
4473
|
+
const {
|
|
4474
|
+
renderer: {
|
|
4475
|
+
ssr
|
|
4476
|
+
}
|
|
4477
|
+
} = vm;
|
|
4478
|
+
|
|
4479
|
+
if (isTrue(ssr) || isTrue(vm.isScheduled)) {
|
|
4489
4480
|
return;
|
|
4490
4481
|
}
|
|
4491
4482
|
|
|
@@ -4644,6 +4635,9 @@
|
|
|
4644
4635
|
context: {
|
|
4645
4636
|
wiredConnecting,
|
|
4646
4637
|
wiredDisconnecting
|
|
4638
|
+
},
|
|
4639
|
+
renderer: {
|
|
4640
|
+
dispatchEvent
|
|
4647
4641
|
}
|
|
4648
4642
|
} = vm; // waiting for the component to be connected to formally request the context via the token
|
|
4649
4643
|
|
|
@@ -4667,7 +4661,7 @@
|
|
|
4667
4661
|
}
|
|
4668
4662
|
|
|
4669
4663
|
});
|
|
4670
|
-
dispatchEvent
|
|
4664
|
+
dispatchEvent(elm, contextRegistrationEvent);
|
|
4671
4665
|
});
|
|
4672
4666
|
}
|
|
4673
4667
|
|
|
@@ -4905,78 +4899,97 @@
|
|
|
4905
4899
|
function hydrateVM(vm) {
|
|
4906
4900
|
const children = renderComponent(vm);
|
|
4907
4901
|
vm.children = children;
|
|
4908
|
-
const parentNode = vm
|
|
4909
|
-
hydrateChildren(getFirstChild
|
|
4902
|
+
const { renderRoot: parentNode, renderer: { getFirstChild }, } = vm;
|
|
4903
|
+
hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
|
|
4910
4904
|
runRenderedCallback(vm);
|
|
4911
4905
|
}
|
|
4912
|
-
function hydrateNode(node, vnode) {
|
|
4906
|
+
function hydrateNode(node, vnode, renderer) {
|
|
4907
|
+
var _a, _b;
|
|
4913
4908
|
let hydratedNode;
|
|
4914
4909
|
switch (vnode.type) {
|
|
4915
4910
|
case 0 /* Text */:
|
|
4916
|
-
|
|
4911
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
4912
|
+
hydratedNode = hydrateText(node, vnode, renderer);
|
|
4917
4913
|
break;
|
|
4918
4914
|
case 1 /* Comment */:
|
|
4919
|
-
|
|
4915
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
4916
|
+
hydratedNode = hydrateComment(node, vnode, renderer);
|
|
4917
|
+
break;
|
|
4918
|
+
case 4 /* Static */:
|
|
4919
|
+
// VStatic are cacheable and cannot have custom renderer associated to them
|
|
4920
|
+
hydratedNode = hydrateStaticElement(node, vnode, renderer);
|
|
4920
4921
|
break;
|
|
4921
4922
|
case 2 /* Element */:
|
|
4922
|
-
hydratedNode = hydrateElement(node, vnode);
|
|
4923
|
+
hydratedNode = hydrateElement(node, vnode, (_a = vnode.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
4923
4924
|
break;
|
|
4924
4925
|
case 3 /* CustomElement */:
|
|
4925
|
-
hydratedNode = hydrateCustomElement(node, vnode);
|
|
4926
|
+
hydratedNode = hydrateCustomElement(node, vnode, (_b = vnode.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
4926
4927
|
break;
|
|
4927
4928
|
}
|
|
4928
|
-
return nextSibling
|
|
4929
|
+
return renderer.nextSibling(hydratedNode);
|
|
4929
4930
|
}
|
|
4930
|
-
function hydrateText(node, vnode) {
|
|
4931
|
+
function hydrateText(node, vnode, renderer) {
|
|
4931
4932
|
var _a;
|
|
4932
|
-
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT
|
|
4933
|
-
return handleMismatch(node, vnode);
|
|
4933
|
+
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */, renderer)) {
|
|
4934
|
+
return handleMismatch(node, vnode, renderer);
|
|
4934
4935
|
}
|
|
4935
|
-
setText
|
|
4936
|
+
const { setText } = renderer;
|
|
4937
|
+
setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
4936
4938
|
vnode.elm = node;
|
|
4937
4939
|
return node;
|
|
4938
4940
|
}
|
|
4939
|
-
function hydrateComment(node, vnode) {
|
|
4941
|
+
function hydrateComment(node, vnode, renderer) {
|
|
4940
4942
|
var _a;
|
|
4941
|
-
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT
|
|
4942
|
-
return handleMismatch(node, vnode);
|
|
4943
|
+
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */, renderer)) {
|
|
4944
|
+
return handleMismatch(node, vnode, renderer);
|
|
4943
4945
|
}
|
|
4944
|
-
setProperty
|
|
4946
|
+
const { setProperty } = renderer;
|
|
4947
|
+
setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
4945
4948
|
vnode.elm = node;
|
|
4946
4949
|
return node;
|
|
4947
4950
|
}
|
|
4948
|
-
function
|
|
4949
|
-
if (!
|
|
4950
|
-
|
|
4951
|
-
return handleMismatch(elm, vnode);
|
|
4951
|
+
function hydrateStaticElement(elm, vnode, renderer) {
|
|
4952
|
+
if (!areCompatibleNodes(vnode.fragment, elm, vnode, renderer)) {
|
|
4953
|
+
return handleMismatch(elm, vnode, renderer);
|
|
4952
4954
|
}
|
|
4953
4955
|
vnode.elm = elm;
|
|
4956
|
+
return elm;
|
|
4957
|
+
}
|
|
4958
|
+
function hydrateElement(elm, vnode, renderer) {
|
|
4959
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
|
|
4960
|
+
!isMatchingElement(vnode, elm, renderer)) {
|
|
4961
|
+
return handleMismatch(elm, vnode, renderer);
|
|
4962
|
+
}
|
|
4963
|
+
vnode.elm = elm;
|
|
4964
|
+
const { owner } = vnode;
|
|
4954
4965
|
const { context } = vnode.data;
|
|
4955
4966
|
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual" /* Manual */);
|
|
4956
4967
|
if (isDomManual) {
|
|
4957
4968
|
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
4958
4969
|
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
4959
|
-
const { props } = vnode
|
|
4970
|
+
const { data: { props }, } = vnode;
|
|
4971
|
+
const { getProperty } = renderer;
|
|
4960
4972
|
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
4961
|
-
if (getProperty
|
|
4973
|
+
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
4962
4974
|
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
4963
4975
|
vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
|
|
4964
4976
|
}
|
|
4965
4977
|
}
|
|
4966
4978
|
}
|
|
4967
|
-
patchElementPropsAndAttrs(vnode);
|
|
4979
|
+
patchElementPropsAndAttrs(vnode, renderer);
|
|
4968
4980
|
if (!isDomManual) {
|
|
4969
|
-
|
|
4981
|
+
const { getFirstChild } = renderer;
|
|
4982
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, owner);
|
|
4970
4983
|
}
|
|
4971
4984
|
return elm;
|
|
4972
4985
|
}
|
|
4973
|
-
function hydrateCustomElement(elm, vnode) {
|
|
4974
|
-
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT
|
|
4975
|
-
!isMatchingElement(vnode, elm)) {
|
|
4976
|
-
return handleMismatch(elm, vnode);
|
|
4986
|
+
function hydrateCustomElement(elm, vnode, renderer) {
|
|
4987
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */, renderer) ||
|
|
4988
|
+
!isMatchingElement(vnode, elm, renderer)) {
|
|
4989
|
+
return handleMismatch(elm, vnode, renderer);
|
|
4977
4990
|
}
|
|
4978
4991
|
const { sel, mode, ctor, owner } = vnode;
|
|
4979
|
-
const vm = createVM(elm, ctor, {
|
|
4992
|
+
const vm = createVM(elm, ctor, renderer, {
|
|
4980
4993
|
mode,
|
|
4981
4994
|
owner,
|
|
4982
4995
|
tagName: sel,
|
|
@@ -4985,12 +4998,13 @@
|
|
|
4985
4998
|
vnode.elm = elm;
|
|
4986
4999
|
vnode.vm = vm;
|
|
4987
5000
|
allocateChildren(vnode, vm);
|
|
4988
|
-
patchElementPropsAndAttrs(vnode);
|
|
5001
|
+
patchElementPropsAndAttrs(vnode, renderer);
|
|
4989
5002
|
runConnectedCallback(vm);
|
|
4990
5003
|
if (vm.renderMode !== 0 /* Light */) {
|
|
5004
|
+
const { getFirstChild } = renderer;
|
|
4991
5005
|
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
4992
5006
|
// Note: for Light DOM, this is handled while hydrating the VM
|
|
4993
|
-
hydrateChildren(getFirstChild
|
|
5007
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
|
|
4994
5008
|
}
|
|
4995
5009
|
hydrateVM(vm);
|
|
4996
5010
|
return elm;
|
|
@@ -4998,78 +5012,89 @@
|
|
|
4998
5012
|
function hydrateChildren(node, children, parentNode, owner) {
|
|
4999
5013
|
let nextNode = node;
|
|
5000
5014
|
let anchor = null;
|
|
5015
|
+
const { renderer } = owner;
|
|
5001
5016
|
for (let i = 0; i < children.length; i++) {
|
|
5002
5017
|
const childVnode = children[i];
|
|
5003
5018
|
if (!isNull(childVnode)) {
|
|
5004
5019
|
if (nextNode) {
|
|
5005
|
-
nextNode = hydrateNode(nextNode, childVnode);
|
|
5020
|
+
nextNode = hydrateNode(nextNode, childVnode, renderer);
|
|
5006
5021
|
anchor = childVnode.elm;
|
|
5007
5022
|
}
|
|
5008
5023
|
else {
|
|
5009
5024
|
hasMismatch = true;
|
|
5010
|
-
mount(childVnode, parentNode, anchor);
|
|
5025
|
+
mount(childVnode, parentNode, renderer, anchor);
|
|
5011
5026
|
anchor = childVnode.elm;
|
|
5012
5027
|
}
|
|
5013
5028
|
}
|
|
5014
5029
|
}
|
|
5015
5030
|
if (nextNode) {
|
|
5016
5031
|
hasMismatch = true;
|
|
5032
|
+
// nextSibling is mostly harmless, and since we don't have
|
|
5033
|
+
// a good reference to what element to act upon, we instead
|
|
5034
|
+
// rely on the vm's associated renderer for navigating to the
|
|
5035
|
+
// next node in the list to be hydrated.
|
|
5036
|
+
const { nextSibling } = renderer;
|
|
5017
5037
|
do {
|
|
5018
5038
|
const current = nextNode;
|
|
5019
|
-
nextNode = nextSibling
|
|
5020
|
-
removeNode(current, parentNode);
|
|
5039
|
+
nextNode = nextSibling(nextNode);
|
|
5040
|
+
removeNode(current, parentNode, renderer);
|
|
5021
5041
|
} while (nextNode);
|
|
5022
5042
|
}
|
|
5023
5043
|
}
|
|
5024
|
-
function handleMismatch(node, vnode,
|
|
5044
|
+
function handleMismatch(node, vnode, renderer) {
|
|
5025
5045
|
hasMismatch = true;
|
|
5026
|
-
const
|
|
5027
|
-
|
|
5028
|
-
|
|
5046
|
+
const { getProperty } = renderer;
|
|
5047
|
+
const parentNode = getProperty(node, 'parentNode');
|
|
5048
|
+
mount(vnode, parentNode, renderer, node);
|
|
5049
|
+
removeNode(node, parentNode, renderer);
|
|
5029
5050
|
return vnode.elm;
|
|
5030
5051
|
}
|
|
5031
|
-
function patchElementPropsAndAttrs(vnode) {
|
|
5032
|
-
applyEventListeners(vnode);
|
|
5033
|
-
patchProps(null, vnode);
|
|
5052
|
+
function patchElementPropsAndAttrs(vnode, renderer) {
|
|
5053
|
+
applyEventListeners(vnode, renderer);
|
|
5054
|
+
patchProps(null, vnode, renderer);
|
|
5034
5055
|
}
|
|
5035
|
-
function hasCorrectNodeType(vnode, node, nodeType) {
|
|
5036
|
-
|
|
5056
|
+
function hasCorrectNodeType(vnode, node, nodeType, renderer) {
|
|
5057
|
+
const { getProperty } = renderer;
|
|
5058
|
+
if (getProperty(node, 'nodeType') !== nodeType) {
|
|
5037
5059
|
return false;
|
|
5038
5060
|
}
|
|
5039
5061
|
return true;
|
|
5040
5062
|
}
|
|
5041
|
-
function isMatchingElement(vnode, elm) {
|
|
5042
|
-
|
|
5063
|
+
function isMatchingElement(vnode, elm, renderer) {
|
|
5064
|
+
const { getProperty } = renderer;
|
|
5065
|
+
if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
|
|
5043
5066
|
return false;
|
|
5044
5067
|
}
|
|
5045
|
-
const hasIncompatibleAttrs = validateAttrs(vnode, elm);
|
|
5046
|
-
const hasIncompatibleClass = validateClassAttr(vnode, elm);
|
|
5047
|
-
const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
|
|
5068
|
+
const hasIncompatibleAttrs = validateAttrs(vnode, elm, renderer);
|
|
5069
|
+
const hasIncompatibleClass = validateClassAttr(vnode, elm, renderer);
|
|
5070
|
+
const hasIncompatibleStyle = validateStyleAttr(vnode, elm, renderer);
|
|
5048
5071
|
return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
5049
5072
|
}
|
|
5050
|
-
function validateAttrs(vnode, elm) {
|
|
5073
|
+
function validateAttrs(vnode, elm, renderer) {
|
|
5051
5074
|
const { data: { attrs = {} }, } = vnode;
|
|
5052
5075
|
let nodesAreCompatible = true;
|
|
5053
5076
|
// Validate attributes, though we could always recovery from those by running the update mods.
|
|
5054
5077
|
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
5055
5078
|
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
5056
|
-
const
|
|
5079
|
+
const { getAttribute } = renderer;
|
|
5080
|
+
const elmAttrValue = getAttribute(elm, attrName);
|
|
5057
5081
|
if (String(attrValue) !== elmAttrValue) {
|
|
5058
5082
|
nodesAreCompatible = false;
|
|
5059
5083
|
}
|
|
5060
5084
|
}
|
|
5061
5085
|
return nodesAreCompatible;
|
|
5062
5086
|
}
|
|
5063
|
-
function validateClassAttr(vnode, elm) {
|
|
5087
|
+
function validateClassAttr(vnode, elm, renderer) {
|
|
5064
5088
|
const { data: { className, classMap }, } = vnode;
|
|
5089
|
+
const { getProperty, getClassList } = renderer;
|
|
5065
5090
|
let nodesAreCompatible = true;
|
|
5066
|
-
if (!isUndefined$1(className) && String(className) !== getProperty
|
|
5091
|
+
if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
|
|
5067
5092
|
// className is used when class is bound to an expr.
|
|
5068
5093
|
nodesAreCompatible = false;
|
|
5069
5094
|
}
|
|
5070
5095
|
else if (!isUndefined$1(classMap)) {
|
|
5071
5096
|
// classMap is used when class is set to static value.
|
|
5072
|
-
const classList = getClassList
|
|
5097
|
+
const classList = getClassList(elm);
|
|
5073
5098
|
let computedClassName = '';
|
|
5074
5099
|
// all classes from the vnode should be in the element.classList
|
|
5075
5100
|
for (const name in classMap) {
|
|
@@ -5085,9 +5110,10 @@
|
|
|
5085
5110
|
}
|
|
5086
5111
|
return nodesAreCompatible;
|
|
5087
5112
|
}
|
|
5088
|
-
function validateStyleAttr(vnode, elm) {
|
|
5113
|
+
function validateStyleAttr(vnode, elm, renderer) {
|
|
5089
5114
|
const { data: { style, styleDecls }, } = vnode;
|
|
5090
|
-
const
|
|
5115
|
+
const { getAttribute } = renderer;
|
|
5116
|
+
const elmStyle = getAttribute(elm, 'style') || '';
|
|
5091
5117
|
let nodesAreCompatible = true;
|
|
5092
5118
|
if (!isUndefined$1(style) && style !== elmStyle) {
|
|
5093
5119
|
nodesAreCompatible = false;
|
|
@@ -5117,6 +5143,36 @@
|
|
|
5117
5143
|
}
|
|
5118
5144
|
return nodesAreCompatible;
|
|
5119
5145
|
}
|
|
5146
|
+
function areCompatibleNodes(client, ssr, vnode, renderer) {
|
|
5147
|
+
const { getProperty, getAttribute } = renderer;
|
|
5148
|
+
if (getProperty(client, 'nodeType') === 3 /* TEXT */) {
|
|
5149
|
+
if (!hasCorrectNodeType(vnode, ssr, 3 /* TEXT */, renderer)) {
|
|
5150
|
+
return false;
|
|
5151
|
+
}
|
|
5152
|
+
return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
|
|
5153
|
+
}
|
|
5154
|
+
if (getProperty(client, 'nodeType') === 8 /* COMMENT */) {
|
|
5155
|
+
if (!hasCorrectNodeType(vnode, ssr, 8 /* COMMENT */, renderer)) {
|
|
5156
|
+
return false;
|
|
5157
|
+
}
|
|
5158
|
+
return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
|
|
5159
|
+
}
|
|
5160
|
+
if (!hasCorrectNodeType(vnode, ssr, 1 /* ELEMENT */, renderer)) {
|
|
5161
|
+
return false;
|
|
5162
|
+
}
|
|
5163
|
+
let isCompatibleElements = true;
|
|
5164
|
+
if (getProperty(client, 'tagName') !== getProperty(ssr, 'tagName')) {
|
|
5165
|
+
return false;
|
|
5166
|
+
}
|
|
5167
|
+
const clientAttrsNames = getProperty(client, 'getAttributeNames').call(client);
|
|
5168
|
+
clientAttrsNames.forEach((attrName) => {
|
|
5169
|
+
if (getAttribute(client, attrName) !== getAttribute(ssr, attrName)) {
|
|
5170
|
+
logError(`Mismatch hydrating element <${getProperty(client, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${getAttribute(client, attrName)}" but found "${getAttribute(ssr, attrName)}"`, vnode.owner);
|
|
5171
|
+
isCompatibleElements = false;
|
|
5172
|
+
}
|
|
5173
|
+
});
|
|
5174
|
+
return isCompatibleElements;
|
|
5175
|
+
}
|
|
5120
5176
|
|
|
5121
5177
|
/*
|
|
5122
5178
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5157,7 +5213,7 @@
|
|
|
5157
5213
|
}
|
|
5158
5214
|
return ctor;
|
|
5159
5215
|
}
|
|
5160
|
-
/* version: 2.
|
|
5216
|
+
/* version: 2.15.0 */
|
|
5161
5217
|
|
|
5162
5218
|
/*
|
|
5163
5219
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5307,7 +5363,7 @@
|
|
|
5307
5363
|
try {
|
|
5308
5364
|
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
5309
5365
|
// _wrapNativeSuper()
|
|
5310
|
-
// This is a problem because LWCUpgradableElement extends renderer.
|
|
5366
|
+
// This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
|
|
5311
5367
|
// get wrapped by babel.
|
|
5312
5368
|
const HTMLElementAlias = HTMLElement;
|
|
5313
5369
|
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
@@ -5361,8 +5417,17 @@
|
|
|
5361
5417
|
hydrating = value;
|
|
5362
5418
|
}
|
|
5363
5419
|
const ssr = false;
|
|
5420
|
+
function isHydrating() {
|
|
5421
|
+
return hydrating;
|
|
5422
|
+
}
|
|
5364
5423
|
const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
|
|
5365
5424
|
const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
|
|
5425
|
+
function cloneNode(node, deep) {
|
|
5426
|
+
return node.cloneNode(deep);
|
|
5427
|
+
}
|
|
5428
|
+
function createFragment(html) {
|
|
5429
|
+
return document.createRange().createContextualFragment(html).firstChild;
|
|
5430
|
+
}
|
|
5366
5431
|
function createElement$1(tagName, namespace) {
|
|
5367
5432
|
return isUndefined$1(namespace)
|
|
5368
5433
|
? document.createElement(tagName)
|
|
@@ -5469,44 +5534,53 @@
|
|
|
5469
5534
|
function isConnected(node) {
|
|
5470
5535
|
return node.isConnected;
|
|
5471
5536
|
}
|
|
5537
|
+
function assertInstanceOfHTMLElement(elm, msg) {
|
|
5538
|
+
assert.invariant(elm instanceof HTMLElement, msg);
|
|
5539
|
+
}
|
|
5472
5540
|
const HTMLElementExported = HTMLElementConstructor;
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5541
|
+
const renderer = {
|
|
5542
|
+
ssr,
|
|
5543
|
+
isNativeShadowDefined,
|
|
5544
|
+
isSyntheticShadowDefined,
|
|
5545
|
+
HTMLElementExported,
|
|
5546
|
+
isHydrating,
|
|
5547
|
+
insert,
|
|
5548
|
+
remove,
|
|
5549
|
+
cloneNode,
|
|
5550
|
+
createFragment,
|
|
5551
|
+
createElement: createElement$1,
|
|
5552
|
+
createText,
|
|
5553
|
+
createComment,
|
|
5554
|
+
nextSibling,
|
|
5555
|
+
attachShadow,
|
|
5556
|
+
getProperty,
|
|
5557
|
+
setProperty,
|
|
5558
|
+
setText,
|
|
5559
|
+
getAttribute,
|
|
5560
|
+
setAttribute,
|
|
5561
|
+
removeAttribute,
|
|
5562
|
+
addEventListener,
|
|
5563
|
+
removeEventListener,
|
|
5564
|
+
dispatchEvent,
|
|
5565
|
+
getClassList,
|
|
5566
|
+
setCSSStyleProperty,
|
|
5567
|
+
getBoundingClientRect,
|
|
5568
|
+
querySelector,
|
|
5569
|
+
querySelectorAll,
|
|
5570
|
+
getElementsByTagName,
|
|
5571
|
+
getElementsByClassName,
|
|
5572
|
+
getChildren,
|
|
5573
|
+
getChildNodes,
|
|
5574
|
+
getFirstChild,
|
|
5575
|
+
getFirstElementChild,
|
|
5576
|
+
getLastChild,
|
|
5577
|
+
getLastElementChild,
|
|
5578
|
+
isConnected,
|
|
5579
|
+
insertStylesheet,
|
|
5580
|
+
assertInstanceOfHTMLElement,
|
|
5581
|
+
defineCustomElement,
|
|
5582
|
+
getCustomElement,
|
|
5583
|
+
};
|
|
5510
5584
|
|
|
5511
5585
|
/*
|
|
5512
5586
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5528,7 +5602,7 @@
|
|
|
5528
5602
|
}
|
|
5529
5603
|
}
|
|
5530
5604
|
function createVMWithProps(element, Ctor, props) {
|
|
5531
|
-
const vm = createVM(element, Ctor, {
|
|
5605
|
+
const vm = createVM(element, Ctor, renderer, {
|
|
5532
5606
|
mode: 'open',
|
|
5533
5607
|
owner: null,
|
|
5534
5608
|
tagName: element.tagName.toLowerCase(),
|
|
@@ -5619,7 +5693,7 @@
|
|
|
5619
5693
|
hydratedCustomElements.add(this);
|
|
5620
5694
|
}
|
|
5621
5695
|
else {
|
|
5622
|
-
createVM(this, Ctor, {
|
|
5696
|
+
createVM(this, Ctor, renderer, {
|
|
5623
5697
|
mode: 'open',
|
|
5624
5698
|
owner: null,
|
|
5625
5699
|
tagName: this.tagName,
|
|
@@ -5701,7 +5775,7 @@
|
|
|
5701
5775
|
if (!isFunction$1(Ctor)) {
|
|
5702
5776
|
throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
|
|
5703
5777
|
}
|
|
5704
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
5778
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
5705
5779
|
let wasComponentUpgraded = false;
|
|
5706
5780
|
// the custom element from the registry is expecting an upgrade callback
|
|
5707
5781
|
/**
|
|
@@ -5711,7 +5785,7 @@
|
|
|
5711
5785
|
* an upgradable custom element.
|
|
5712
5786
|
*/
|
|
5713
5787
|
const element = new UpgradableConstructor((elm) => {
|
|
5714
|
-
createVM(elm, Ctor, {
|
|
5788
|
+
createVM(elm, Ctor, renderer, {
|
|
5715
5789
|
tagName: sel,
|
|
5716
5790
|
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
5717
5791
|
owner: null,
|
|
@@ -5795,7 +5869,7 @@
|
|
|
5795
5869
|
});
|
|
5796
5870
|
freeze(LightningElement);
|
|
5797
5871
|
seal(LightningElement.prototype);
|
|
5798
|
-
/* version: 2.
|
|
5872
|
+
/* version: 2.15.0 */
|
|
5799
5873
|
|
|
5800
5874
|
exports.LightningElement = LightningElement;
|
|
5801
5875
|
exports.__unstable__ProfilerControl = profilerControl;
|
|
@@ -5809,11 +5883,14 @@
|
|
|
5809
5883
|
exports.hydrateComponent = hydrateComponent;
|
|
5810
5884
|
exports.isComponentConstructor = isComponentConstructor;
|
|
5811
5885
|
exports.isNodeFromTemplate = isNodeShadowed;
|
|
5886
|
+
exports.parseFragment = parseFragment;
|
|
5887
|
+
exports.parseSVGFragment = parseSVGFragment;
|
|
5812
5888
|
exports.readonly = readonly;
|
|
5813
5889
|
exports.register = register;
|
|
5814
5890
|
exports.registerComponent = registerComponent;
|
|
5815
5891
|
exports.registerDecorators = registerDecorators;
|
|
5816
5892
|
exports.registerTemplate = registerTemplate;
|
|
5893
|
+
exports.renderer = renderer;
|
|
5817
5894
|
exports.sanitizeAttribute = sanitizeAttribute;
|
|
5818
5895
|
exports.setFeatureFlag = setFeatureFlag;
|
|
5819
5896
|
exports.setFeatureFlagForTest = setFeatureFlagForTest;
|