lwc 2.14.1 → 2.16.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.
Files changed (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +598 -541
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +600 -540
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +537 -485
  5. package/dist/engine-dom/iife/es5/engine-dom.js +768 -679
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +692 -621
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +600 -540
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +537 -485
  11. package/dist/engine-dom/umd/es5/engine-dom.js +768 -679
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +692 -621
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +455 -460
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +453 -461
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +24 -4
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +24 -4
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +24 -4
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +29 -3
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +29 -3
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +24 -4
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +24 -4
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +29 -3
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +29 -3
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. 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.14.1 */
297
+ /** version: 2.16.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$1(elm, {
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 { elm } = getAssociatedVM(this);
1542
- return dispatchEvent$1(elm, event);
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$1(elm, type, wrappedListener, options);
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$1(elm, type, wrappedListener, options);
1404
+ removeEventListener(elm, type, wrappedListener, options);
1555
1405
  },
1556
1406
  hasAttribute(name) {
1557
- const { elm } = getAssociatedVM(this);
1558
- return !isNull(getAttribute$1(elm, name));
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 { elm } = getAssociatedVM(this);
1562
- return !isNull(getAttribute$1(elm, name, namespace));
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 { elm } = getAssociatedVM(this);
1417
+ const vm = getAssociatedVM(this);
1418
+ const { elm, renderer: { removeAttribute }, } = vm;
1566
1419
  unlockAttribute(elm, name);
1567
- removeAttribute$1(elm, name);
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$1(elm, name, namespace);
1426
+ removeAttribute(elm, name, namespace);
1574
1427
  lockAttribute();
1575
1428
  },
1576
1429
  getAttribute(name) {
1577
- const { elm } = getAssociatedVM(this);
1578
- return getAttribute$1(elm, name);
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 { elm } = getAssociatedVM(this);
1582
- return getAttribute$1(elm, name, namespace);
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$1(elm, name, value);
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$1(elm, name, value, namespace);
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$1(elm);
1457
+ const { elm, renderer: { getBoundingClientRect }, } = vm;
1458
+ return getBoundingClientRect(elm);
1602
1459
  },
1603
1460
  get isConnected() {
1604
- const { elm } = getAssociatedVM(this);
1605
- return isConnected$1(elm);
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$1(elm);
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 getQueryMethod(queryMethod)(elm, arg);
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$1(tagName);
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 HTMLElementExported$1 {
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$1(tagName, CE);
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$1(elm, key, cur, XML_NAMESPACE);
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$1(elm, key, cur, XLINK_NAMESPACE);
2371
+ setAttribute(elm, key, cur, XLINK_NAMESPACE);
2533
2372
  }
2534
2373
  else if (isNull(cur) || isUndefined$1(cur)) {
2535
- removeAttribute$1(elm, key);
2374
+ removeAttribute(elm, key);
2536
2375
  }
2537
2376
  else {
2538
- setAttribute$1(elm, key, cur);
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$1(elm, key) : oldProps[key])) {
2573
- setProperty$1(elm, key, cur);
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 classList = getClassList$1(elm);
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$1(elm, 'style');
2493
+ removeAttribute(elm, 'style');
2652
2494
  }
2653
2495
  else {
2654
- setAttribute$1(elm, 'style', newStyle);
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$1(elm, name, handler);
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 classList = getClassList$1(elm);
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$1(elm, prop, value, important);
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
- patchText(n1, n2);
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
- patchComment(n1, n2);
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
- mountText(node, parent, anchor);
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
- mountComment(node, parent, anchor);
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
- mountElement(node, parent, anchor);
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
- mountCustomElement(node, parent, anchor);
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(node, parent, anchor) {
2771
- const { owner } = node;
2772
- const textNode = (node.elm = createText$1(node.text));
2773
- linkNodeToShadow(textNode, owner);
2774
- insertNode(textNode, parent, anchor);
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(node, parent, anchor) {
2785
- const { owner } = node;
2786
- const commentNode = (node.elm = createComment$1(node.text));
2787
- linkNodeToShadow(commentNode, owner);
2788
- insertNode(commentNode, parent, anchor);
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$2(sel, namespace);
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);
2668
+ }
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);
2805
2682
  }
2806
- function mountCustomElement(vnode, parent, anchor) {
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,34 +2724,36 @@
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
- removeNode(elm, parent);
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
2751
  switch (type) {
2873
2752
  case 2 /* Element */: {
2874
2753
  // Slot content is removed to trigger slotchange event when removing slot.
2875
2754
  // Only required for synthetic shadow.
2876
- const removeChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
2877
- unmountVNodes(vnode.children, elm, removeChildren);
2755
+ const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* Synthetic */;
2756
+ unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
2878
2757
  break;
2879
2758
  }
2880
2759
  case 3 /* CustomElement */: {
@@ -2887,11 +2766,11 @@
2887
2766
  }
2888
2767
  }
2889
2768
  }
2890
- function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
2769
+ function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
2891
2770
  for (; start < end; ++start) {
2892
2771
  const ch = vnodes[start];
2893
2772
  if (isVNode(ch)) {
2894
- unmount(ch, parent, doRemove);
2773
+ unmount(ch, parent, renderer, doRemove);
2895
2774
  }
2896
2775
  }
2897
2776
  }
@@ -2905,48 +2784,53 @@
2905
2784
  elm.$shadowToken$ = token;
2906
2785
  }
2907
2786
  // Set the scope token class for *.scoped.css styles
2908
- function setScopeTokenClassIfNecessary(elm, owner) {
2787
+ function setScopeTokenClassIfNecessary(elm, owner, renderer) {
2909
2788
  const { cmpTemplate, context } = owner;
2789
+ const { getClassList } = renderer;
2910
2790
  const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
2911
2791
  if (!isUndefined$1(token) && context.hasScopedStyles) {
2912
- getClassList$1(elm).add(token);
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);
2913
2795
  }
2914
2796
  }
2915
- function linkNodeToShadow(elm, owner) {
2797
+ function linkNodeToShadow(elm, owner, renderer) {
2916
2798
  const { renderRoot, renderMode, shadowMode } = owner;
2799
+ const { isSyntheticShadowDefined } = renderer;
2917
2800
  // TODO [#1164]: this should eventually be done by the polyfill directly
2918
- if (isSyntheticShadowDefined$1) {
2801
+ if (isSyntheticShadowDefined) {
2919
2802
  if (shadowMode === 1 /* Synthetic */ || renderMode === 0 /* Light */) {
2920
2803
  elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
2921
2804
  }
2922
2805
  }
2923
2806
  }
2924
- function updateTextContent(vnode) {
2807
+ function updateTextContent(vnode, renderer) {
2925
2808
  const { elm, text } = vnode;
2926
- setText$1(elm, text);
2809
+ const { setText } = renderer;
2810
+ setText(elm, text);
2927
2811
  }
2928
- function insertNode(node, parent, anchor) {
2929
- insert$1(node, parent, anchor);
2812
+ function insertNode(node, parent, anchor, renderer) {
2813
+ renderer.insert(node, parent, anchor);
2930
2814
  }
2931
- function removeNode(node, parent) {
2932
- remove$1(node, parent);
2815
+ function removeNode(node, parent, renderer) {
2816
+ renderer.remove(node, parent);
2933
2817
  }
2934
- function patchElementPropsAndAttrs$1(oldVnode, vnode) {
2818
+ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
2935
2819
  if (isNull(oldVnode)) {
2936
- applyEventListeners(vnode);
2937
- applyStaticClassAttribute(vnode);
2938
- applyStaticStyleAttribute(vnode);
2820
+ applyEventListeners(vnode, renderer);
2821
+ applyStaticClassAttribute(vnode, renderer);
2822
+ applyStaticStyleAttribute(vnode, renderer);
2939
2823
  }
2940
2824
  // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
2941
2825
  // value is set before type=radio.
2942
- patchClassAttribute(oldVnode, vnode);
2943
- patchStyleAttribute(oldVnode, vnode);
2944
- patchAttributes(oldVnode, vnode);
2945
- patchProps(oldVnode, vnode);
2826
+ patchClassAttribute(oldVnode, vnode, renderer);
2827
+ patchStyleAttribute(oldVnode, vnode, renderer);
2828
+ patchAttributes(oldVnode, vnode, renderer);
2829
+ patchProps(oldVnode, vnode, renderer);
2946
2830
  }
2947
- function fallbackElmHook(elm, vnode) {
2831
+ function fallbackElmHook(elm, vnode, renderer) {
2948
2832
  const { owner } = vnode;
2949
- setScopeTokenClassIfNecessary(elm, owner);
2833
+ setScopeTokenClassIfNecessary(elm, owner, renderer);
2950
2834
  if (owner.shadowMode === 1 /* Synthetic */) {
2951
2835
  const { data: { context }, } = vnode;
2952
2836
  const { stylesheetToken } = owner.context;
@@ -2986,7 +2870,7 @@
2986
2870
  vnode.children = EmptyArray;
2987
2871
  }
2988
2872
  }
2989
- function createViewModelHook(elm, vnode) {
2873
+ function createViewModelHook(elm, vnode, renderer) {
2990
2874
  let vm = getAssociatedVMIfPresent(elm);
2991
2875
  // There is a possibility that a custom element is registered under tagName, in which case, the
2992
2876
  // initialization is already carry on, and there is nothing else to do here since this hook is
@@ -2995,7 +2879,7 @@
2995
2879
  return vm;
2996
2880
  }
2997
2881
  const { sel, mode, ctor, owner } = vnode;
2998
- setScopeTokenClassIfNecessary(elm, owner);
2882
+ setScopeTokenClassIfNecessary(elm, owner, renderer);
2999
2883
  if (owner.shadowMode === 1 /* Synthetic */) {
3000
2884
  const { stylesheetToken } = owner.context;
3001
2885
  // when running in synthetic shadow mode, we need to set the shadowToken value
@@ -3004,7 +2888,7 @@
3004
2888
  setElementShadowToken(elm, stylesheetToken);
3005
2889
  }
3006
2890
  }
3007
- vm = createVM(elm, ctor, {
2891
+ vm = createVM(elm, ctor, renderer, {
3008
2892
  mode,
3009
2893
  owner,
3010
2894
  tagName: sel,
@@ -3076,7 +2960,7 @@
3076
2960
  }
3077
2961
  return map;
3078
2962
  }
3079
- function updateDynamicChildren(oldCh, newCh, parent) {
2963
+ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
3080
2964
  let oldStartIdx = 0;
3081
2965
  let newStartIdx = 0;
3082
2966
  let oldEndIdx = oldCh.length - 1;
@@ -3105,26 +2989,26 @@
3105
2989
  newEndVnode = newCh[--newEndIdx];
3106
2990
  }
3107
2991
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
3108
- patch(oldStartVnode, newStartVnode);
2992
+ patch(oldStartVnode, newStartVnode, renderer);
3109
2993
  oldStartVnode = oldCh[++oldStartIdx];
3110
2994
  newStartVnode = newCh[++newStartIdx];
3111
2995
  }
3112
2996
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
3113
- patch(oldEndVnode, newEndVnode);
2997
+ patch(oldEndVnode, newEndVnode, renderer);
3114
2998
  oldEndVnode = oldCh[--oldEndIdx];
3115
2999
  newEndVnode = newCh[--newEndIdx];
3116
3000
  }
3117
3001
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
3118
3002
  // Vnode moved right
3119
- patch(oldStartVnode, newEndVnode);
3120
- insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
3003
+ patch(oldStartVnode, newEndVnode, renderer);
3004
+ insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
3121
3005
  oldStartVnode = oldCh[++oldStartIdx];
3122
3006
  newEndVnode = newCh[--newEndIdx];
3123
3007
  }
3124
3008
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
3125
3009
  // Vnode moved left
3126
- patch(oldEndVnode, newStartVnode);
3127
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
3010
+ patch(oldEndVnode, newStartVnode, renderer);
3011
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
3128
3012
  oldEndVnode = oldCh[--oldEndIdx];
3129
3013
  newStartVnode = newCh[++newStartIdx];
3130
3014
  }
@@ -3135,7 +3019,7 @@
3135
3019
  idxInOld = oldKeyToIdx[newStartVnode.key];
3136
3020
  if (isUndefined$1(idxInOld)) {
3137
3021
  // New element
3138
- mount(newStartVnode, parent, oldStartVnode.elm);
3022
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3139
3023
  newStartVnode = newCh[++newStartIdx];
3140
3024
  }
3141
3025
  else {
@@ -3143,10 +3027,10 @@
3143
3027
  if (isVNode(elmToMove)) {
3144
3028
  if (elmToMove.sel !== newStartVnode.sel) {
3145
3029
  // New element
3146
- mount(newStartVnode, parent, oldStartVnode.elm);
3030
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3147
3031
  }
3148
3032
  else {
3149
- patch(elmToMove, newStartVnode);
3033
+ patch(elmToMove, newStartVnode, renderer);
3150
3034
  // Delete the old child, but copy the array since it is read-only.
3151
3035
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3152
3036
  // so we only care about the `oldCh` object inside this function.
@@ -3158,7 +3042,7 @@
3158
3042
  }
3159
3043
  // We've already cloned at least once, so it's no longer read-only
3160
3044
  oldCh[idxInOld] = undefined;
3161
- insertNode(elmToMove.elm, parent, oldStartVnode.elm);
3045
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
3162
3046
  }
3163
3047
  }
3164
3048
  newStartVnode = newCh[++newStartIdx];
@@ -3175,25 +3059,25 @@
3175
3059
  n = newCh[++i];
3176
3060
  } while (!isVNode(n) && i < newChEnd);
3177
3061
  before = isVNode(n) ? n.elm : null;
3178
- mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
3062
+ mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
3179
3063
  }
3180
3064
  else {
3181
- unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
3065
+ unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
3182
3066
  }
3183
3067
  }
3184
3068
  }
3185
- function updateStaticChildren(c1, c2, parent) {
3069
+ function updateStaticChildren(c1, c2, parent, renderer) {
3186
3070
  const c1Length = c1.length;
3187
3071
  const c2Length = c2.length;
3188
3072
  if (c1Length === 0) {
3189
3073
  // the old list is empty, we can directly insert anything new
3190
- mountVNodes(c2, parent, null);
3074
+ mountVNodes(c2, parent, renderer, null);
3191
3075
  return;
3192
3076
  }
3193
3077
  if (c2Length === 0) {
3194
3078
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
3195
3079
  // this is the case in which the dynamic children of an if-directive should be removed
3196
- unmountVNodes(c1, parent, true);
3080
+ unmountVNodes(c1, parent, renderer, true);
3197
3081
  return;
3198
3082
  }
3199
3083
  // if the old list is not empty, the new list MUST have the same
@@ -3206,16 +3090,16 @@
3206
3090
  if (isVNode(n1)) {
3207
3091
  if (isVNode(n2)) {
3208
3092
  // both vnodes are equivalent, and we just need to patch them
3209
- patch(n1, n2);
3093
+ patch(n1, n2, renderer);
3210
3094
  anchor = n2.elm;
3211
3095
  }
3212
3096
  else {
3213
3097
  // removing the old vnode since the new one is null
3214
- unmount(n1, parent, true);
3098
+ unmount(n1, parent, renderer, true);
3215
3099
  }
3216
3100
  }
3217
3101
  else if (isVNode(n2)) {
3218
- mount(n2, parent, anchor);
3102
+ mount(n2, parent, renderer, anchor);
3219
3103
  anchor = n2.elm;
3220
3104
  }
3221
3105
  }
@@ -3232,6 +3116,17 @@
3232
3116
  function addVNodeToChildLWC(vnode) {
3233
3117
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
3234
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
+ }
3235
3130
  // [h]tml node
3236
3131
  function h(sel, data, children = EmptyArray) {
3237
3132
  const vmBeingRendered = getVMBeingRendered();
@@ -3508,6 +3403,7 @@
3508
3403
  co,
3509
3404
  dc,
3510
3405
  ti,
3406
+ st,
3511
3407
  gid,
3512
3408
  fid,
3513
3409
  shc,
@@ -3531,7 +3427,7 @@
3531
3427
  }, [api.t(content)]);
3532
3428
  }
3533
3429
  function updateStylesheetToken(vm, template) {
3534
- const { elm, context, renderMode, shadowMode } = vm;
3430
+ const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
3535
3431
  const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
3536
3432
  const isSyntheticShadow = renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */;
3537
3433
  const { hasScopedStyles } = context;
@@ -3542,10 +3438,10 @@
3542
3438
  const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
3543
3439
  if (!isUndefined$1(oldToken)) {
3544
3440
  if (oldHasTokenInClass) {
3545
- getClassList$1(elm).remove(makeHostToken(oldToken));
3441
+ getClassList(elm).remove(makeHostToken(oldToken));
3546
3442
  }
3547
3443
  if (oldHasTokenInAttribute) {
3548
- removeAttribute$1(elm, makeHostToken(oldToken));
3444
+ removeAttribute(elm, makeHostToken(oldToken));
3549
3445
  }
3550
3446
  }
3551
3447
  // Apply the new template styling token to the host element, if the new template has any
@@ -3556,11 +3452,11 @@
3556
3452
  // Set the new styling token on the host element
3557
3453
  if (!isUndefined$1(newToken)) {
3558
3454
  if (hasScopedStyles) {
3559
- getClassList$1(elm).add(makeHostToken(newToken));
3455
+ getClassList(elm).add(makeHostToken(newToken));
3560
3456
  newHasTokenInClass = true;
3561
3457
  }
3562
3458
  if (isSyntheticShadow) {
3563
- setAttribute$1(elm, makeHostToken(newToken), '');
3459
+ setAttribute(elm, makeHostToken(newToken), '');
3564
3460
  newHasTokenInAttribute = true;
3565
3461
  }
3566
3462
  }
@@ -3640,19 +3536,18 @@
3640
3536
  return owner;
3641
3537
  }
3642
3538
  function createStylesheet(vm, stylesheets) {
3643
- const { renderMode, shadowMode } = vm;
3539
+ const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3644
3540
  if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
3645
3541
  for (let i = 0; i < stylesheets.length; i++) {
3646
- insertStylesheet$1(stylesheets[i]);
3542
+ insertStylesheet(stylesheets[i]);
3647
3543
  }
3648
3544
  }
3649
- else if (ssr$1 || vm.hydrated) {
3545
+ else if (ssr || vm.hydrated) {
3650
3546
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3651
3547
  // This works in the client, because the stylesheets are created, and cached in the VM
3652
3548
  // the first time the VM renders.
3653
3549
  // native shadow or light DOM, SSR
3654
- const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
3655
- return createInlineStyleVNode(combinedStylesheetContent);
3550
+ return ArrayMap.call(stylesheets, createInlineStyleVNode);
3656
3551
  }
3657
3552
  else {
3658
3553
  // native shadow or light DOM, DOM renderer
@@ -3660,7 +3555,7 @@
3660
3555
  // null root means a global style
3661
3556
  const target = isNull(root) ? undefined : root.shadowRoot;
3662
3557
  for (let i = 0; i < stylesheets.length; i++) {
3663
- insertStylesheet$1(stylesheets[i], target);
3558
+ insertStylesheet(stylesheets[i], target);
3664
3559
  }
3665
3560
  }
3666
3561
  return null;
@@ -3738,6 +3633,59 @@
3738
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"`);
3739
3634
  }
3740
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
+ });
3741
3689
  function evaluateTemplate(vm, html) {
3742
3690
  const isUpdatingTemplateInception = isUpdatingTemplate;
3743
3691
  const vmOfTemplateBeingUpdatedInception = vmBeingRendered;
@@ -3775,7 +3723,7 @@
3775
3723
  // Evaluate, create stylesheet and cache the produced VNode for future
3776
3724
  // re-rendering.
3777
3725
  const stylesheetsContent = getStylesheetsContent(vm, html);
3778
- context.styleVNode =
3726
+ context.styleVNodes =
3779
3727
  stylesheetsContent.length === 0
3780
3728
  ? null
3781
3729
  : createStylesheet(vm, stylesheetsContent);
@@ -3787,9 +3735,9 @@
3787
3735
  // Set the global flag that template is being updated
3788
3736
  isUpdatingTemplate = true;
3789
3737
  vnodes = html.call(undefined, api, component, cmpSlots, context.tplCache);
3790
- const { styleVNode } = context;
3791
- if (!isNull(styleVNode)) {
3792
- ArrayUnshift.call(vnodes, styleVNode);
3738
+ const { styleVNodes } = context;
3739
+ if (!isNull(styleVNodes)) {
3740
+ ArrayUnshift.apply(vnodes, styleVNodes);
3793
3741
  }
3794
3742
  });
3795
3743
  }, () => {
@@ -4072,7 +4020,7 @@
4072
4020
  return ancestor;
4073
4021
  }
4074
4022
 
4075
- function createVM(elm, ctor, options) {
4023
+ function createVM(elm, ctor, renderer, options) {
4076
4024
  const {
4077
4025
  mode,
4078
4026
  owner,
@@ -4107,7 +4055,7 @@
4107
4055
  hasTokenInClass: undefined,
4108
4056
  hasTokenInAttribute: undefined,
4109
4057
  hasScopedStyles: undefined,
4110
- styleVNode: null,
4058
+ styleVNodes: null,
4111
4059
  tplCache: EmptyObject,
4112
4060
  wiredConnecting: EmptyArray,
4113
4061
  wiredDisconnecting: EmptyArray
@@ -4121,9 +4069,10 @@
4121
4069
  renderRoot: null,
4122
4070
  callHook,
4123
4071
  setHook,
4124
- getHook
4072
+ getHook,
4073
+ renderer
4125
4074
  };
4126
- vm.shadowMode = computeShadowMode(vm);
4075
+ vm.shadowMode = computeShadowMode(vm, renderer);
4127
4076
  vm.tro = getTemplateReactiveObserver(vm);
4128
4077
 
4129
4078
 
@@ -4136,13 +4085,17 @@
4136
4085
  return vm;
4137
4086
  }
4138
4087
 
4139
- function computeShadowMode(vm) {
4088
+ function computeShadowMode(vm, renderer) {
4140
4089
  const {
4141
4090
  def
4142
4091
  } = vm;
4092
+ const {
4093
+ isSyntheticShadowDefined,
4094
+ isNativeShadowDefined
4095
+ } = renderer;
4143
4096
  let shadowMode;
4144
4097
 
4145
- if (isSyntheticShadowDefined$1) {
4098
+ if (isSyntheticShadowDefined) {
4146
4099
  if (def.renderMode === 0
4147
4100
  /* Light */
4148
4101
  ) {
@@ -4151,7 +4104,7 @@
4151
4104
  shadowMode = 0
4152
4105
  /* Native */
4153
4106
  ;
4154
- } else if (isNativeShadowDefined$1) {
4107
+ } else if (isNativeShadowDefined) {
4155
4108
  // Not combined with above condition because @lwc/features only supports identifiers in
4156
4109
  // the if-condition.
4157
4110
  if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
@@ -4225,7 +4178,8 @@
4225
4178
  function patchShadowRoot(vm, newCh) {
4226
4179
  const {
4227
4180
  renderRoot,
4228
- children: oldCh
4181
+ children: oldCh,
4182
+ renderer
4229
4183
  } = vm; // caching the new children collection
4230
4184
 
4231
4185
  vm.children = newCh;
@@ -4241,7 +4195,7 @@
4241
4195
  , vm);
4242
4196
  }, () => {
4243
4197
  // job
4244
- patchChildren(oldCh, newCh, renderRoot);
4198
+ patchChildren(oldCh, newCh, renderRoot, renderer);
4245
4199
  }, () => {
4246
4200
  // post
4247
4201
  logOperationEnd(2
@@ -4266,10 +4220,13 @@
4266
4220
  const {
4267
4221
  def: {
4268
4222
  renderedCallback
4223
+ },
4224
+ renderer: {
4225
+ ssr
4269
4226
  }
4270
4227
  } = vm;
4271
4228
 
4272
- if (isTrue(ssr$1)) {
4229
+ if (isTrue(ssr)) {
4273
4230
  return;
4274
4231
  }
4275
4232
 
@@ -4494,14 +4451,17 @@
4494
4451
  function resetComponentRoot(vm) {
4495
4452
  const {
4496
4453
  children,
4497
- renderRoot
4454
+ renderRoot,
4455
+ renderer: {
4456
+ remove
4457
+ }
4498
4458
  } = vm;
4499
4459
 
4500
4460
  for (let i = 0, len = children.length; i < len; i++) {
4501
4461
  const child = children[i];
4502
4462
 
4503
4463
  if (!isNull(child) && !isUndefined$1(child.elm)) {
4504
- remove$1(child.elm, renderRoot);
4464
+ remove(child.elm, renderRoot);
4505
4465
  }
4506
4466
  }
4507
4467
 
@@ -4510,7 +4470,13 @@
4510
4470
  vm.velements = EmptyArray;
4511
4471
  }
4512
4472
  function scheduleRehydration(vm) {
4513
- if (isTrue(ssr$1) || isTrue(vm.isScheduled)) {
4473
+ const {
4474
+ renderer: {
4475
+ ssr
4476
+ }
4477
+ } = vm;
4478
+
4479
+ if (isTrue(ssr) || isTrue(vm.isScheduled)) {
4514
4480
  return;
4515
4481
  }
4516
4482
 
@@ -4669,6 +4635,9 @@
4669
4635
  context: {
4670
4636
  wiredConnecting,
4671
4637
  wiredDisconnecting
4638
+ },
4639
+ renderer: {
4640
+ dispatchEvent
4672
4641
  }
4673
4642
  } = vm; // waiting for the component to be connected to formally request the context via the token
4674
4643
 
@@ -4692,7 +4661,7 @@
4692
4661
  }
4693
4662
 
4694
4663
  });
4695
- dispatchEvent$1(elm, contextRegistrationEvent);
4664
+ dispatchEvent(elm, contextRegistrationEvent);
4696
4665
  });
4697
4666
  }
4698
4667
 
@@ -4930,78 +4899,97 @@
4930
4899
  function hydrateVM(vm) {
4931
4900
  const children = renderComponent(vm);
4932
4901
  vm.children = children;
4933
- const parentNode = vm.renderRoot;
4934
- hydrateChildren(getFirstChild$1(parentNode), children, parentNode);
4902
+ const { renderRoot: parentNode, renderer: { getFirstChild }, } = vm;
4903
+ hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
4935
4904
  runRenderedCallback(vm);
4936
4905
  }
4937
- function hydrateNode(node, vnode) {
4906
+ function hydrateNode(node, vnode, renderer) {
4907
+ var _a, _b;
4938
4908
  let hydratedNode;
4939
4909
  switch (vnode.type) {
4940
4910
  case 0 /* Text */:
4941
- hydratedNode = hydrateText(node, vnode);
4911
+ // VText has no special capability, fallback to the owner's renderer
4912
+ hydratedNode = hydrateText(node, vnode, renderer);
4942
4913
  break;
4943
4914
  case 1 /* Comment */:
4944
- hydratedNode = hydrateComment(node, vnode);
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);
4945
4921
  break;
4946
4922
  case 2 /* Element */:
4947
- hydratedNode = hydrateElement(node, vnode);
4923
+ hydratedNode = hydrateElement(node, vnode, (_a = vnode.data.renderer) !== null && _a !== void 0 ? _a : renderer);
4948
4924
  break;
4949
4925
  case 3 /* CustomElement */:
4950
- hydratedNode = hydrateCustomElement(node, vnode);
4926
+ hydratedNode = hydrateCustomElement(node, vnode, (_b = vnode.data.renderer) !== null && _b !== void 0 ? _b : renderer);
4951
4927
  break;
4952
4928
  }
4953
- return nextSibling$1(hydratedNode);
4929
+ return renderer.nextSibling(hydratedNode);
4954
4930
  }
4955
- function hydrateText(node, vnode) {
4931
+ function hydrateText(node, vnode, renderer) {
4956
4932
  var _a;
4957
- if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */)) {
4958
- return handleMismatch(node, vnode);
4933
+ if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */, renderer)) {
4934
+ return handleMismatch(node, vnode, renderer);
4959
4935
  }
4960
- setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
4936
+ const { setText } = renderer;
4937
+ setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
4961
4938
  vnode.elm = node;
4962
4939
  return node;
4963
4940
  }
4964
- function hydrateComment(node, vnode) {
4941
+ function hydrateComment(node, vnode, renderer) {
4965
4942
  var _a;
4966
- if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */)) {
4967
- return handleMismatch(node, vnode);
4943
+ if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */, renderer)) {
4944
+ return handleMismatch(node, vnode, renderer);
4968
4945
  }
4969
- setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
4946
+ const { setProperty } = renderer;
4947
+ setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
4970
4948
  vnode.elm = node;
4971
4949
  return node;
4972
4950
  }
4973
- function hydrateElement(elm, vnode) {
4974
- if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
4975
- !isMatchingElement(vnode, elm)) {
4976
- return handleMismatch(elm, vnode);
4951
+ function hydrateStaticElement(elm, vnode, renderer) {
4952
+ if (!areCompatibleNodes(vnode.fragment, elm, vnode, renderer)) {
4953
+ return handleMismatch(elm, vnode, renderer);
4954
+ }
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);
4977
4962
  }
4978
4963
  vnode.elm = elm;
4964
+ const { owner } = vnode;
4979
4965
  const { context } = vnode.data;
4980
4966
  const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual" /* Manual */);
4981
4967
  if (isDomManual) {
4982
4968
  // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
4983
4969
  // remove the innerHTML from props so it reuses the existing dom elements.
4984
- const { props } = vnode.data;
4970
+ const { data: { props }, } = vnode;
4971
+ const { getProperty } = renderer;
4985
4972
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
4986
- if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
4973
+ if (getProperty(elm, 'innerHTML') === props.innerHTML) {
4987
4974
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
4988
4975
  vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
4989
4976
  }
4990
4977
  }
4991
4978
  }
4992
- patchElementPropsAndAttrs(vnode);
4979
+ patchElementPropsAndAttrs(vnode, renderer);
4993
4980
  if (!isDomManual) {
4994
- hydrateChildren(getFirstChild$1(elm), vnode.children, elm, vnode.owner);
4981
+ const { getFirstChild } = renderer;
4982
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, owner);
4995
4983
  }
4996
4984
  return elm;
4997
4985
  }
4998
- function hydrateCustomElement(elm, vnode) {
4999
- if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
5000
- !isMatchingElement(vnode, elm)) {
5001
- 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);
5002
4990
  }
5003
4991
  const { sel, mode, ctor, owner } = vnode;
5004
- const vm = createVM(elm, ctor, {
4992
+ const vm = createVM(elm, ctor, renderer, {
5005
4993
  mode,
5006
4994
  owner,
5007
4995
  tagName: sel,
@@ -5010,12 +4998,13 @@
5010
4998
  vnode.elm = elm;
5011
4999
  vnode.vm = vm;
5012
5000
  allocateChildren(vnode, vm);
5013
- patchElementPropsAndAttrs(vnode);
5001
+ patchElementPropsAndAttrs(vnode, renderer);
5014
5002
  runConnectedCallback(vm);
5015
5003
  if (vm.renderMode !== 0 /* Light */) {
5004
+ const { getFirstChild } = renderer;
5016
5005
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5017
5006
  // Note: for Light DOM, this is handled while hydrating the VM
5018
- hydrateChildren(getFirstChild$1(elm), vnode.children, elm);
5007
+ hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
5019
5008
  }
5020
5009
  hydrateVM(vm);
5021
5010
  return elm;
@@ -5023,78 +5012,89 @@
5023
5012
  function hydrateChildren(node, children, parentNode, owner) {
5024
5013
  let nextNode = node;
5025
5014
  let anchor = null;
5015
+ const { renderer } = owner;
5026
5016
  for (let i = 0; i < children.length; i++) {
5027
5017
  const childVnode = children[i];
5028
5018
  if (!isNull(childVnode)) {
5029
5019
  if (nextNode) {
5030
- nextNode = hydrateNode(nextNode, childVnode);
5020
+ nextNode = hydrateNode(nextNode, childVnode, renderer);
5031
5021
  anchor = childVnode.elm;
5032
5022
  }
5033
5023
  else {
5034
5024
  hasMismatch = true;
5035
- mount(childVnode, parentNode, anchor);
5025
+ mount(childVnode, parentNode, renderer, anchor);
5036
5026
  anchor = childVnode.elm;
5037
5027
  }
5038
5028
  }
5039
5029
  }
5040
5030
  if (nextNode) {
5041
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;
5042
5037
  do {
5043
5038
  const current = nextNode;
5044
- nextNode = nextSibling$1(nextNode);
5045
- removeNode(current, parentNode);
5039
+ nextNode = nextSibling(nextNode);
5040
+ removeNode(current, parentNode, renderer);
5046
5041
  } while (nextNode);
5047
5042
  }
5048
5043
  }
5049
- function handleMismatch(node, vnode, msg) {
5044
+ function handleMismatch(node, vnode, renderer) {
5050
5045
  hasMismatch = true;
5051
- const parentNode = getProperty$1(node, 'parentNode');
5052
- mount(vnode, parentNode, node);
5053
- removeNode(node, parentNode);
5046
+ const { getProperty } = renderer;
5047
+ const parentNode = getProperty(node, 'parentNode');
5048
+ mount(vnode, parentNode, renderer, node);
5049
+ removeNode(node, parentNode, renderer);
5054
5050
  return vnode.elm;
5055
5051
  }
5056
- function patchElementPropsAndAttrs(vnode) {
5057
- applyEventListeners(vnode);
5058
- patchProps(null, vnode);
5052
+ function patchElementPropsAndAttrs(vnode, renderer) {
5053
+ applyEventListeners(vnode, renderer);
5054
+ patchProps(null, vnode, renderer);
5059
5055
  }
5060
- function hasCorrectNodeType(vnode, node, nodeType) {
5061
- if (getProperty$1(node, 'nodeType') !== nodeType) {
5056
+ function hasCorrectNodeType(vnode, node, nodeType, renderer) {
5057
+ const { getProperty } = renderer;
5058
+ if (getProperty(node, 'nodeType') !== nodeType) {
5062
5059
  return false;
5063
5060
  }
5064
5061
  return true;
5065
5062
  }
5066
- function isMatchingElement(vnode, elm) {
5067
- if (vnode.sel.toLowerCase() !== getProperty$1(elm, 'tagName').toLowerCase()) {
5063
+ function isMatchingElement(vnode, elm, renderer) {
5064
+ const { getProperty } = renderer;
5065
+ if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
5068
5066
  return false;
5069
5067
  }
5070
- const hasIncompatibleAttrs = validateAttrs(vnode, elm);
5071
- const hasIncompatibleClass = validateClassAttr(vnode, elm);
5072
- 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);
5073
5071
  return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
5074
5072
  }
5075
- function validateAttrs(vnode, elm) {
5073
+ function validateAttrs(vnode, elm, renderer) {
5076
5074
  const { data: { attrs = {} }, } = vnode;
5077
5075
  let nodesAreCompatible = true;
5078
5076
  // Validate attributes, though we could always recovery from those by running the update mods.
5079
5077
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
5080
5078
  for (const [attrName, attrValue] of Object.entries(attrs)) {
5081
- const elmAttrValue = getAttribute$1(elm, attrName);
5079
+ const { getAttribute } = renderer;
5080
+ const elmAttrValue = getAttribute(elm, attrName);
5082
5081
  if (String(attrValue) !== elmAttrValue) {
5083
5082
  nodesAreCompatible = false;
5084
5083
  }
5085
5084
  }
5086
5085
  return nodesAreCompatible;
5087
5086
  }
5088
- function validateClassAttr(vnode, elm) {
5087
+ function validateClassAttr(vnode, elm, renderer) {
5089
5088
  const { data: { className, classMap }, } = vnode;
5089
+ const { getProperty, getClassList } = renderer;
5090
5090
  let nodesAreCompatible = true;
5091
- if (!isUndefined$1(className) && String(className) !== getProperty$1(elm, 'className')) {
5091
+ if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
5092
5092
  // className is used when class is bound to an expr.
5093
5093
  nodesAreCompatible = false;
5094
5094
  }
5095
5095
  else if (!isUndefined$1(classMap)) {
5096
5096
  // classMap is used when class is set to static value.
5097
- const classList = getClassList$1(elm);
5097
+ const classList = getClassList(elm);
5098
5098
  let computedClassName = '';
5099
5099
  // all classes from the vnode should be in the element.classList
5100
5100
  for (const name in classMap) {
@@ -5110,9 +5110,10 @@
5110
5110
  }
5111
5111
  return nodesAreCompatible;
5112
5112
  }
5113
- function validateStyleAttr(vnode, elm) {
5113
+ function validateStyleAttr(vnode, elm, renderer) {
5114
5114
  const { data: { style, styleDecls }, } = vnode;
5115
- const elmStyle = getAttribute$1(elm, 'style') || '';
5115
+ const { getAttribute } = renderer;
5116
+ const elmStyle = getAttribute(elm, 'style') || '';
5116
5117
  let nodesAreCompatible = true;
5117
5118
  if (!isUndefined$1(style) && style !== elmStyle) {
5118
5119
  nodesAreCompatible = false;
@@ -5142,6 +5143,36 @@
5142
5143
  }
5143
5144
  return nodesAreCompatible;
5144
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
+ }
5145
5176
 
5146
5177
  /*
5147
5178
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5182,7 +5213,7 @@
5182
5213
  }
5183
5214
  return ctor;
5184
5215
  }
5185
- /* version: 2.14.1 */
5216
+ /* version: 2.16.0 */
5186
5217
 
5187
5218
  /*
5188
5219
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5332,7 +5363,7 @@
5332
5363
  try {
5333
5364
  // dereference HTMLElement global because babel wraps globals in compat mode with a
5334
5365
  // _wrapNativeSuper()
5335
- // This is a problem because LWCUpgradableElement extends renderer.HTMLElement which does not
5366
+ // This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
5336
5367
  // get wrapped by babel.
5337
5368
  const HTMLElementAlias = HTMLElement;
5338
5369
  // In case we use compat mode with a modern browser, the compat mode transformation
@@ -5386,8 +5417,17 @@
5386
5417
  hydrating = value;
5387
5418
  }
5388
5419
  const ssr = false;
5420
+ function isHydrating() {
5421
+ return hydrating;
5422
+ }
5389
5423
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
5390
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
+ }
5391
5431
  function createElement$1(tagName, namespace) {
5392
5432
  return isUndefined$1(namespace)
5393
5433
  ? document.createElement(tagName)
@@ -5494,44 +5534,53 @@
5494
5534
  function isConnected(node) {
5495
5535
  return node.isConnected;
5496
5536
  }
5537
+ function assertInstanceOfHTMLElement(elm, msg) {
5538
+ assert.invariant(elm instanceof HTMLElement, msg);
5539
+ }
5497
5540
  const HTMLElementExported = HTMLElementConstructor;
5498
- setAttachShadow(attachShadow);
5499
- setCreateComment(createComment);
5500
- setCreateElement(createElement$1);
5501
- setCreateText(createText);
5502
- setDefineCustomElement(defineCustomElement);
5503
- setDispatchEvent(dispatchEvent);
5504
- setGetAttribute(getAttribute);
5505
- setGetBoundingClientRect(getBoundingClientRect);
5506
- setGetChildNodes(getChildNodes);
5507
- setGetChildren(getChildren);
5508
- setGetClassList(getClassList);
5509
- setGetCustomElement(getCustomElement);
5510
- setGetElementsByClassName(getElementsByClassName);
5511
- setGetElementsByTagName(getElementsByTagName);
5512
- setGetFirstChild(getFirstChild);
5513
- setGetFirstElementChild(getFirstElementChild);
5514
- setGetLastChild(getLastChild);
5515
- setGetLastElementChild(getLastElementChild);
5516
- setGetProperty(getProperty);
5517
- setHTMLElement(HTMLElementExported);
5518
- setInsert(insert);
5519
- setIsConnected(isConnected);
5520
- setIsNativeShadowDefined(isNativeShadowDefined);
5521
- setIsSyntheticShadowDefined(isSyntheticShadowDefined);
5522
- setNextSibling(nextSibling);
5523
- setQuerySelector(querySelector);
5524
- setQuerySelectorAll(querySelectorAll);
5525
- setRemove(remove);
5526
- setRemoveAttribute(removeAttribute);
5527
- setRemoveEventListener(removeEventListener);
5528
- setSetAttribute(setAttribute);
5529
- setSetCSSStyleProperty(setCSSStyleProperty);
5530
- setSetProperty(setProperty);
5531
- setSetText(setText);
5532
- setSsr(ssr);
5533
- setAddEventListener(addEventListener);
5534
- setInsertStylesheet(insertStylesheet);
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
+ };
5535
5584
 
5536
5585
  /*
5537
5586
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5553,7 +5602,7 @@
5553
5602
  }
5554
5603
  }
5555
5604
  function createVMWithProps(element, Ctor, props) {
5556
- const vm = createVM(element, Ctor, {
5605
+ const vm = createVM(element, Ctor, renderer, {
5557
5606
  mode: 'open',
5558
5607
  owner: null,
5559
5608
  tagName: element.tagName.toLowerCase(),
@@ -5644,7 +5693,7 @@
5644
5693
  hydratedCustomElements.add(this);
5645
5694
  }
5646
5695
  else {
5647
- createVM(this, Ctor, {
5696
+ createVM(this, Ctor, renderer, {
5648
5697
  mode: 'open',
5649
5698
  owner: null,
5650
5699
  tagName: this.tagName,
@@ -5726,7 +5775,7 @@
5726
5775
  if (!isFunction$1(Ctor)) {
5727
5776
  throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
5728
5777
  }
5729
- const UpgradableConstructor = getUpgradableConstructor(sel);
5778
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
5730
5779
  let wasComponentUpgraded = false;
5731
5780
  // the custom element from the registry is expecting an upgrade callback
5732
5781
  /**
@@ -5736,7 +5785,7 @@
5736
5785
  * an upgradable custom element.
5737
5786
  */
5738
5787
  const element = new UpgradableConstructor((elm) => {
5739
- createVM(elm, Ctor, {
5788
+ createVM(elm, Ctor, renderer, {
5740
5789
  tagName: sel,
5741
5790
  mode: options.mode !== 'closed' ? 'open' : 'closed',
5742
5791
  owner: null,
@@ -5820,7 +5869,7 @@
5820
5869
  });
5821
5870
  freeze(LightningElement);
5822
5871
  seal(LightningElement.prototype);
5823
- /* version: 2.14.1 */
5872
+ /* version: 2.16.0 */
5824
5873
 
5825
5874
  exports.LightningElement = LightningElement;
5826
5875
  exports.__unstable__ProfilerControl = profilerControl;
@@ -5834,11 +5883,14 @@
5834
5883
  exports.hydrateComponent = hydrateComponent;
5835
5884
  exports.isComponentConstructor = isComponentConstructor;
5836
5885
  exports.isNodeFromTemplate = isNodeShadowed;
5886
+ exports.parseFragment = parseFragment;
5887
+ exports.parseSVGFragment = parseSVGFragment;
5837
5888
  exports.readonly = readonly;
5838
5889
  exports.register = register;
5839
5890
  exports.registerComponent = registerComponent;
5840
5891
  exports.registerDecorators = registerDecorators;
5841
5892
  exports.registerTemplate = registerTemplate;
5893
+ exports.renderer = renderer;
5842
5894
  exports.sanitizeAttribute = sanitizeAttribute;
5843
5895
  exports.setFeatureFlag = setFeatureFlag;
5844
5896
  exports.setFeatureFlagForTest = setFeatureFlagForTest;