@phatvu/web-component-poc 1.0.2 → 1.0.3

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 (30) hide show
  1. package/dist/cjs/{fast-carousel.cjs.entry.js → fast-button_3.cjs.entry.js} +210 -3
  2. package/dist/cjs/{index-C756SOR-.js → index-B2BTpdbN.js} +373 -114
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/web-component-poc.cjs.js +2 -2
  5. package/dist/collection/components/button/button.js +2 -3
  6. package/dist/collection/components/fast-carousel/carousel.js +2 -3
  7. package/dist/components/fast-button.js +1 -1
  8. package/dist/components/fast-carousel.js +1 -1
  9. package/dist/components/index.js +1 -1
  10. package/dist/components/jobs-list-only-ui.js +1 -1
  11. package/dist/components/p-UM9TUfe3.js +1 -0
  12. package/dist/esm/{fast-carousel.entry.js → fast-button_3.entry.js} +209 -4
  13. package/dist/esm/{index-D7_MJBO8.js → index-Dk5CvWmb.js} +373 -114
  14. package/dist/esm/loader.js +3 -3
  15. package/dist/esm/web-component-poc.js +3 -3
  16. package/dist/web-component-poc/p-3d68d559.entry.js +1 -0
  17. package/dist/web-component-poc/p-Dk5CvWmb.js +2 -0
  18. package/dist/web-component-poc/web-component-poc.esm.js +1 -1
  19. package/hydrate/index.js +15 -506
  20. package/hydrate/index.mjs +15 -506
  21. package/package.json +1 -1
  22. package/dist/cjs/fast-button_2.cjs.entry.js +0 -211
  23. package/dist/components/p-Cw2MJ5l2.js +0 -1
  24. package/dist/esm/fast-button_2.entry.js +0 -208
  25. package/dist/web-component-poc/index-xE9n11HX.js.map +0 -1
  26. package/dist/web-component-poc/index.esm.js.map +0 -1
  27. package/dist/web-component-poc/p-0bc6d45d.entry.js +0 -1
  28. package/dist/web-component-poc/p-8ab359cc.entry.js +0 -1
  29. package/dist/web-component-poc/p-D7_MJBO8.js +0 -2
  30. package/dist/web-component-poc/web-component-poc.esm.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  const NAMESPACE = 'web-component-poc';
2
- const BUILD = /* web-component-poc */ { hotModuleReplacement: false, hydratedSelectorName: "hydrated", lazyLoad: true, prop: true, propChangeCallback: false, updatable: true};
2
+ const BUILD = /* web-component-poc */ { hotModuleReplacement: false, hydratedSelectorName: "hydrated", lazyLoad: true, prop: true, propChangeCallback: false, shadowDom: false, slotRelocation: true, updatable: true};
3
3
 
4
4
  /*
5
5
  Stencil Client Platform v4.43.2 | MIT Licensed | https://stenciljs.com
@@ -172,6 +172,7 @@ var plt = {
172
172
  rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
173
173
  ce: (eventName, opts) => new CustomEvent(eventName, opts)
174
174
  };
175
+ var supportsShadow = BUILD.shadowDom;
175
176
  var promiseResolve = (v) => Promise.resolve(v);
176
177
  var supportsConstructableStylesheets = /* @__PURE__ */ (() => {
177
178
  try {
@@ -220,27 +221,27 @@ var flush = () => {
220
221
  };
221
222
  var nextTick = (cb) => promiseResolve().then(cb);
222
223
  var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
223
-
224
- // src/utils/style.ts
225
- function createStyleSheetIfNeededAndSupported(styles2) {
226
- return void 0;
227
- }
228
-
229
- // src/utils/shadow-root.ts
230
- var globalStyleSheet;
231
- function createShadowRoot(cmpMeta) {
232
- var _a;
233
- const opts = { mode: "open" };
234
- const shadowRoot = this.attachShadow(opts);
235
- if (globalStyleSheet === void 0) globalStyleSheet = (_a = createStyleSheetIfNeededAndSupported()) != null ? _a : null;
236
- if (globalStyleSheet) {
237
- if (supportsMutableAdoptedStyleSheets) {
238
- shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
239
- } else {
240
- shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
224
+ var updateFallbackSlotVisibility = (elm) => {
225
+ const childNodes = internalCall(elm, "childNodes");
226
+ if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
227
+ getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
228
+ if (slotNode.nodeType === 1 /* ElementNode */ && slotNode.tagName === "SLOT-FB") {
229
+ if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) {
230
+ slotNode.hidden = true;
231
+ } else {
232
+ slotNode.hidden = false;
233
+ }
234
+ }
235
+ });
236
+ }
237
+ let i2 = 0;
238
+ for (i2 = 0; i2 < childNodes.length; i2++) {
239
+ const childNode = childNodes[i2];
240
+ if (childNode.nodeType === 1 /* ElementNode */ && internalCall(childNode, "childNodes").length) {
241
+ updateFallbackSlotVisibility(childNode);
241
242
  }
242
243
  }
243
- }
244
+ };
244
245
  var getSlottedChildNodes = (childNodes) => {
245
246
  const result = [];
246
247
  for (let i2 = 0; i2 < childNodes.length; i2++) {
@@ -251,6 +252,44 @@ var getSlottedChildNodes = (childNodes) => {
251
252
  }
252
253
  return result;
253
254
  };
255
+ function getHostSlotNodes(childNodes, hostName, slotName) {
256
+ let i2 = 0;
257
+ let slottedNodes = [];
258
+ let childNode;
259
+ for (; i2 < childNodes.length; i2++) {
260
+ childNode = childNodes[i2];
261
+ if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0 || getSlotName(childNode) === slotName)) {
262
+ slottedNodes.push(childNode);
263
+ if (typeof slotName !== "undefined") return slottedNodes;
264
+ }
265
+ slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
266
+ }
267
+ return slottedNodes;
268
+ }
269
+ var getSlotChildSiblings = (slot, slotName, includeSlot = true) => {
270
+ const childNodes = [];
271
+ if (includeSlot && slot["s-sr"] || !slot["s-sr"]) childNodes.push(slot);
272
+ let node = slot;
273
+ while (node = node.nextSibling) {
274
+ if (getSlotName(node) === slotName && (includeSlot || !node["s-sr"])) childNodes.push(node);
275
+ }
276
+ return childNodes;
277
+ };
278
+ var isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
279
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
280
+ if (nodeToRelocate.getAttribute("slot") === null && slotName === "") {
281
+ return true;
282
+ }
283
+ if (nodeToRelocate.getAttribute("slot") === slotName) {
284
+ return true;
285
+ }
286
+ return false;
287
+ }
288
+ if (nodeToRelocate["s-sn"] === slotName) {
289
+ return true;
290
+ }
291
+ return slotName === "";
292
+ };
254
293
  var addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
255
294
  if (newChild["s-ol"] && newChild["s-ol"].isConnected) {
256
295
  return;
@@ -307,6 +346,18 @@ function patchSlotNode(node) {
307
346
  node.assignedElements = assignedFactory(true);
308
347
  node.assignedNodes = assignedFactory(false);
309
348
  }
349
+ function dispatchSlotChangeEvent(elm) {
350
+ elm.dispatchEvent(new CustomEvent("slotchange", { bubbles: false, cancelable: false, composed: false }));
351
+ }
352
+ function findSlotFromSlottedNode(slottedNode, parentHost) {
353
+ var _a;
354
+ parentHost = parentHost || ((_a = slottedNode["s-ol"]) == null ? void 0 : _a.parentElement);
355
+ if (!parentHost) return { slotNode: null, slotName: "" };
356
+ const slotName = slottedNode["s-sn"] = getSlotName(slottedNode) || "";
357
+ const childNodes = internalCall(parentHost, "childNodes");
358
+ const slotNode = getHostSlotNodes(childNodes, parentHost.tagName, slotName)[0];
359
+ return { slotNode, slotName };
360
+ }
310
361
  function internalCall(node, method) {
311
362
  if ("__" + method in node) {
312
363
  const toReturn = node["__" + method];
@@ -456,29 +507,13 @@ var addStyle = (styleContainerNode, cmpMeta, mode) => {
456
507
  var attachStyles = (hostRef) => {
457
508
  const cmpMeta = hostRef.$cmpMeta$;
458
509
  const elm = hostRef.$hostElement$;
459
- const flags = cmpMeta.$flags$;
460
510
  const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
461
- const scopeId2 = addStyle(
462
- elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
511
+ addStyle(
512
+ elm.getRootNode(),
463
513
  cmpMeta);
464
- if (flags & 10 /* needsScopedEncapsulation */) {
465
- elm["s-sc"] = scopeId2;
466
- elm.classList.add(scopeId2 + "-h");
467
- }
468
514
  endAttachStyles();
469
515
  };
470
516
  var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
471
- var convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, "$1{");
472
- var hydrateScopedToShadow = () => {
473
- if (!win.document) {
474
- return;
475
- }
476
- const styles2 = win.document.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
477
- let i2 = 0;
478
- for (; i2 < styles2.length; i2++) {
479
- registerStyle(styles2[i2].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles2[i2].innerHTML), true);
480
- }
481
- };
482
517
  var isComplexType = (o) => {
483
518
  o = typeof o;
484
519
  return o === "object" || o === "function";
@@ -491,6 +526,7 @@ var h = (nodeName, vnodeData, ...children) => {
491
526
  }
492
527
  let child = null;
493
528
  let key = null;
529
+ let slotName = null;
494
530
  let simple = false;
495
531
  let lastSimple = false;
496
532
  const vNodeChildren = [];
@@ -517,6 +553,9 @@ var h = (nodeName, vnodeData, ...children) => {
517
553
  if (vnodeData.key) {
518
554
  key = vnodeData.key;
519
555
  }
556
+ if (vnodeData.name) {
557
+ slotName = vnodeData.name;
558
+ }
520
559
  {
521
560
  const classData = vnodeData.className || vnodeData.class;
522
561
  if (classData) {
@@ -532,6 +571,9 @@ var h = (nodeName, vnodeData, ...children) => {
532
571
  {
533
572
  vnode.$key$ = key;
534
573
  }
574
+ {
575
+ vnode.$name$ = slotName;
576
+ }
535
577
  return vnode;
536
578
  };
537
579
  var newVNode = (tag, text) => {
@@ -549,6 +591,9 @@ var newVNode = (tag, text) => {
549
591
  {
550
592
  vnode.$key$ = null;
551
593
  }
594
+ {
595
+ vnode.$name$ = null;
596
+ }
552
597
  return vnode;
553
598
  };
554
599
  var Host = {};
@@ -562,7 +607,7 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
562
607
  const childRenderNodes = [];
563
608
  const slotNodes = [];
564
609
  const slottedNodes = [];
565
- const shadowRootNodes = shadowRoot ? [] : null;
610
+ const shadowRootNodes = null;
566
611
  const vnode = newVNode(tagName, null);
567
612
  vnode.$elm$ = hostElm;
568
613
  if (win.document && (!plt.$orgLocNodes$ || !plt.$orgLocNodes$.size)) {
@@ -670,27 +715,6 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
670
715
  currentPos = (slottedItem.node["s-oo"] || currentPos) + 1;
671
716
  }
672
717
  }
673
- if (shadowRoot && !shadowRoot.childNodes.length) {
674
- let rnIdex = 0;
675
- const rnLen = shadowRootNodes.length;
676
- if (rnLen) {
677
- for (rnIdex; rnIdex < rnLen; rnIdex++) {
678
- const node = shadowRootNodes[rnIdex];
679
- if (node) {
680
- shadowRoot.appendChild(node);
681
- }
682
- }
683
- Array.from(hostElm.childNodes).forEach((node) => {
684
- if (typeof node["s-en"] !== "string" && typeof node["s-sn"] !== "string") {
685
- if (node.nodeType === 1 /* ElementNode */ && node.slot && node.hidden) {
686
- node.removeAttribute("hidden");
687
- } else if (node.nodeType === 8 /* CommentNode */ && !node.nodeValue) {
688
- node.parentNode.removeChild(node);
689
- }
690
- }
691
- });
692
- }
693
- }
694
718
  hostRef.$hostElement$ = hostElm;
695
719
  endHydrate();
696
720
  };
@@ -743,9 +767,6 @@ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes,
743
767
  parentVNode.$children$[childVNode.$index$] = childVNode;
744
768
  }
745
769
  parentVNode = childVNode;
746
- if (shadowRootNodes && childVNode.$depth$ === "0") {
747
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
748
- }
749
770
  }
750
771
  }
751
772
  if (node.shadowRoot) {
@@ -804,9 +825,6 @@ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes,
804
825
  }
805
826
  parentVNode.$children$[childVNode.$index$] = childVNode;
806
827
  }
807
- if (shadowRootNodes && childVNode.$depth$ === "0") {
808
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
809
- }
810
828
  }
811
829
  } else if (childNodeType === COMMENT_NODE_ID) {
812
830
  childVNode.$elm$ = findCorrespondingNode(node, 8 /* CommentNode */);
@@ -829,8 +847,9 @@ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes,
829
847
  slottedNodes
830
848
  );
831
849
  } else if (childNodeType === CONTENT_REF_ID) {
832
- if (shadowRootNodes) {
833
- node.remove();
850
+ {
851
+ hostElm["s-cr"] = node;
852
+ node["s-cn"] = true;
834
853
  }
835
854
  }
836
855
  }
@@ -890,22 +909,7 @@ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNod
890
909
  childVNode.$name$ = slotName || null;
891
910
  childVNode.$tag$ = "slot";
892
911
  const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
893
- if (shadowRootNodes && win.document) {
894
- const slot = childVNode.$elm$ = win.document.createElement(childVNode.$tag$);
895
- if (childVNode.$name$) {
896
- childVNode.$elm$.setAttribute("name", slotName);
897
- }
898
- if (parentVNode.$elm$.shadowRoot && parentNodeId && parentNodeId !== childVNode.$hostId$) {
899
- internalCall(parentVNode.$elm$, "insertBefore")(slot, internalCall(parentVNode.$elm$, "children")[0]);
900
- } else {
901
- internalCall(internalCall(node, "parentNode"), "insertBefore")(slot, node);
902
- }
903
- addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
904
- node.remove();
905
- if (childVNode.$depth$ === "0") {
906
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
907
- }
908
- } else {
912
+ {
909
913
  const slot = childVNode.$elm$;
910
914
  const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
911
915
  addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
@@ -1275,18 +1279,43 @@ function sortedAttrNames(attrNames) {
1275
1279
  attrNames
1276
1280
  );
1277
1281
  }
1282
+ var contentRef;
1278
1283
  var hostTagName;
1279
1284
  var useNativeShadowDom = false;
1285
+ var checkSlotFallbackVisibility = false;
1286
+ var checkSlotRelocate = false;
1280
1287
  var isSvgMode = false;
1281
1288
  var refCallbacksToRemove = [];
1282
1289
  var refCallbacksToAttach = [];
1283
1290
  var createElm = (oldParentVNode, newParentVNode, childIndex) => {
1291
+ var _a;
1284
1292
  const newVNode2 = newParentVNode.$children$[childIndex];
1285
1293
  let i2 = 0;
1286
1294
  let elm;
1287
1295
  let childNode;
1296
+ let oldVNode;
1297
+ if (!useNativeShadowDom) {
1298
+ checkSlotRelocate = true;
1299
+ if (newVNode2.$tag$ === "slot") {
1300
+ newVNode2.$flags$ |= newVNode2.$children$ ? (
1301
+ // slot element has fallback content
1302
+ // still create an element that "mocks" the slot element
1303
+ 2 /* isSlotFallback */
1304
+ ) : (
1305
+ // slot element does not have fallback content
1306
+ // create an html comment we'll use to always reference
1307
+ // where actual slot content should sit next to
1308
+ 1 /* isSlotReference */
1309
+ );
1310
+ }
1311
+ }
1288
1312
  if (newVNode2.$text$ != null) {
1289
1313
  elm = newVNode2.$elm$ = win.document.createTextNode(newVNode2.$text$);
1314
+ } else if (newVNode2.$flags$ & 1 /* isSlotReference */) {
1315
+ elm = newVNode2.$elm$ = win.document.createTextNode("");
1316
+ {
1317
+ updateElement(null, newVNode2, isSvgMode);
1318
+ }
1290
1319
  } else {
1291
1320
  if (!isSvgMode) {
1292
1321
  isSvgMode = newVNode2.$tag$ === "svg";
@@ -1296,7 +1325,7 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
1296
1325
  }
1297
1326
  elm = newVNode2.$elm$ = win.document.createElementNS(
1298
1327
  isSvgMode ? SVG_NS : HTML_NS,
1299
- newVNode2.$tag$
1328
+ !useNativeShadowDom && BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1300
1329
  ) ;
1301
1330
  if (isSvgMode && newVNode2.$tag$ === "foreignObject") {
1302
1331
  isSvgMode = false;
@@ -1322,6 +1351,19 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
1322
1351
  }
1323
1352
  }
1324
1353
  elm["s-hn"] = hostTagName;
1354
+ {
1355
+ if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
1356
+ elm["s-sr"] = true;
1357
+ elm["s-cr"] = contentRef;
1358
+ elm["s-sn"] = newVNode2.$name$ || "";
1359
+ elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
1360
+ patchSlotNode(elm);
1361
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
1362
+ if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
1363
+ relocateToHostRoot(oldParentVNode.$elm$);
1364
+ }
1365
+ }
1366
+ }
1325
1367
  return elm;
1326
1368
  };
1327
1369
  var relocateToHostRoot = (parentElm) => {
@@ -1338,17 +1380,41 @@ var relocateToHostRoot = (parentElm) => {
1338
1380
  if (childNode["s-sh"] != null) {
1339
1381
  insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
1340
1382
  childNode["s-sh"] = void 0;
1383
+ checkSlotRelocate = true;
1341
1384
  }
1342
1385
  }
1343
1386
  }
1344
1387
  plt.$flags$ &= -2 /* isTmpDisconnected */;
1345
1388
  };
1389
+ var putBackInOriginalLocation = (parentElm, recursive) => {
1390
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
1391
+ const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
1392
+ if (parentElm["s-sr"]) {
1393
+ let node = parentElm;
1394
+ while (node = node.nextSibling) {
1395
+ if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
1396
+ oldSlotChildNodes.push(node);
1397
+ }
1398
+ }
1399
+ }
1400
+ for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
1401
+ const childNode = oldSlotChildNodes[i2];
1402
+ if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
1403
+ insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
1404
+ childNode["s-ol"].remove();
1405
+ childNode["s-ol"] = void 0;
1406
+ childNode["s-sh"] = void 0;
1407
+ checkSlotRelocate = true;
1408
+ }
1409
+ if (recursive) {
1410
+ putBackInOriginalLocation(childNode, recursive);
1411
+ }
1412
+ }
1413
+ plt.$flags$ &= -2 /* isTmpDisconnected */;
1414
+ };
1346
1415
  var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1347
- let containerElm = parentElm;
1416
+ let containerElm = parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
1348
1417
  let childNode;
1349
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1350
- containerElm = containerElm.shadowRoot;
1351
- }
1352
1418
  if (parentVNode.$tag$ === "template") {
1353
1419
  containerElm = containerElm.content;
1354
1420
  }
@@ -1357,7 +1423,7 @@ var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1357
1423
  childNode = createElm(null, parentVNode, startIdx);
1358
1424
  if (childNode) {
1359
1425
  vnodes[startIdx].$elm$ = childNode;
1360
- insertBefore(containerElm, childNode, before);
1426
+ insertBefore(containerElm, childNode, referenceNode(before) );
1361
1427
  }
1362
1428
  }
1363
1429
  }
@@ -1369,6 +1435,14 @@ var removeVnodes = (vnodes, startIdx, endIdx) => {
1369
1435
  const elm = vnode.$elm$;
1370
1436
  nullifyVNodeRefs(vnode);
1371
1437
  if (elm) {
1438
+ {
1439
+ checkSlotFallbackVisibility = true;
1440
+ if (elm["s-ol"]) {
1441
+ elm["s-ol"].remove();
1442
+ } else {
1443
+ putBackInOriginalLocation(elm, true);
1444
+ }
1445
+ }
1372
1446
  elm.remove();
1373
1447
  }
1374
1448
  }
@@ -1406,11 +1480,17 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
1406
1480
  oldEndVnode = oldCh[--oldEndIdx];
1407
1481
  newEndVnode = newCh[--newEndIdx];
1408
1482
  } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
1483
+ if ((oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1484
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1485
+ }
1409
1486
  patch(oldStartVnode, newEndVnode, isInitialRender);
1410
1487
  insertBefore(containerElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1411
1488
  oldStartVnode = oldCh[++oldStartIdx];
1412
1489
  newEndVnode = newCh[--newEndIdx];
1413
1490
  } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
1491
+ if ((oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1492
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1493
+ }
1414
1494
  patch(oldEndVnode, newStartVnode, isInitialRender);
1415
1495
  insertBefore(containerElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
1416
1496
  oldEndVnode = oldCh[--oldEndIdx];
@@ -1441,7 +1521,11 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
1441
1521
  }
1442
1522
  if (node) {
1443
1523
  {
1444
- insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1524
+ insertBefore(
1525
+ referenceNode(oldStartVnode.$elm$).parentNode,
1526
+ node,
1527
+ referenceNode(oldStartVnode.$elm$)
1528
+ );
1445
1529
  }
1446
1530
  }
1447
1531
  }
@@ -1461,6 +1545,9 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
1461
1545
  };
1462
1546
  var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1463
1547
  if (leftVNode.$tag$ === rightVNode.$tag$) {
1548
+ if (leftVNode.$tag$ === "slot") {
1549
+ return leftVNode.$name$ === rightVNode.$name$;
1550
+ }
1464
1551
  if (!isInitialRender) {
1465
1552
  return leftVNode.$key$ === rightVNode.$key$;
1466
1553
  }
@@ -1471,12 +1558,14 @@ var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1471
1558
  }
1472
1559
  return false;
1473
1560
  };
1561
+ var referenceNode = (node) => node && node["s-ol"] || node;
1474
1562
  var patch = (oldVNode, newVNode2, isInitialRender = false) => {
1475
1563
  const elm = newVNode2.$elm$ = oldVNode.$elm$;
1476
1564
  const oldChildren = oldVNode.$children$;
1477
1565
  const newChildren = newVNode2.$children$;
1478
1566
  const tag = newVNode2.$tag$;
1479
1567
  const text = newVNode2.$text$;
1568
+ let defaultHolder;
1480
1569
  if (text == null) {
1481
1570
  {
1482
1571
  isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
@@ -1508,10 +1597,62 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
1508
1597
  if (isSvgMode && tag === "svg") {
1509
1598
  isSvgMode = false;
1510
1599
  }
1600
+ } else if ((defaultHolder = elm["s-cr"])) {
1601
+ defaultHolder.parentNode.textContent = text;
1511
1602
  } else if (oldVNode.$text$ !== text) {
1512
1603
  elm.data = text;
1513
1604
  }
1514
1605
  };
1606
+ var relocateNodes = [];
1607
+ var markSlotContentForRelocation = (elm) => {
1608
+ let node;
1609
+ let hostContentNodes;
1610
+ let j;
1611
+ const children = elm.__childNodes || elm.childNodes;
1612
+ for (const childNode of children) {
1613
+ if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
1614
+ hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
1615
+ const slotName = childNode["s-sn"];
1616
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
1617
+ node = hostContentNodes[j];
1618
+ if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
1619
+ if (isNodeLocatedInSlot(node, slotName)) {
1620
+ let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1621
+ checkSlotFallbackVisibility = true;
1622
+ node["s-sn"] = node["s-sn"] || slotName;
1623
+ if (relocateNodeData) {
1624
+ relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
1625
+ relocateNodeData.$slotRefNode$ = childNode;
1626
+ } else {
1627
+ node["s-sh"] = childNode["s-hn"];
1628
+ relocateNodes.push({
1629
+ $slotRefNode$: childNode,
1630
+ $nodeToRelocate$: node
1631
+ });
1632
+ }
1633
+ if (node["s-sr"]) {
1634
+ relocateNodes.map((relocateNode) => {
1635
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
1636
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1637
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
1638
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1639
+ }
1640
+ }
1641
+ });
1642
+ }
1643
+ } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1644
+ relocateNodes.push({
1645
+ $nodeToRelocate$: node
1646
+ });
1647
+ }
1648
+ }
1649
+ }
1650
+ }
1651
+ if (childNode.nodeType === 1 /* ElementNode */) {
1652
+ markSlotContentForRelocation(childNode);
1653
+ }
1654
+ }
1655
+ };
1515
1656
  var nullifyVNodeRefs = (vNode) => {
1516
1657
  {
1517
1658
  if (vNode.$attrs$ && vNode.$attrs$.ref) {
@@ -1534,6 +1675,14 @@ var flushQueuedRefCallbacks = () => {
1534
1675
  }
1535
1676
  };
1536
1677
  var insertBefore = (parent, newNode, reference, isInitialLoad) => {
1678
+ {
1679
+ if (typeof newNode["s-sn"] === "string") {
1680
+ parent.insertBefore(newNode, reference);
1681
+ const { slotNode } = findSlotFromSlottedNode(newNode);
1682
+ if (slotNode && !isInitialLoad) dispatchSlotChangeEvent(slotNode);
1683
+ return newNode;
1684
+ }
1685
+ }
1537
1686
  if (parent.__insertBefore) {
1538
1687
  return parent.__insertBefore(newNode, reference);
1539
1688
  } else {
@@ -1541,6 +1690,7 @@ var insertBefore = (parent, newNode, reference, isInitialLoad) => {
1541
1690
  }
1542
1691
  };
1543
1692
  var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1693
+ var _a, _b, _c, _d, _e;
1544
1694
  const hostElm = hostRef.$hostElement$;
1545
1695
  const cmpMeta = hostRef.$cmpMeta$;
1546
1696
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
@@ -1557,9 +1707,108 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1557
1707
  rootVnode.$tag$ = null;
1558
1708
  rootVnode.$flags$ |= 4 /* isHost */;
1559
1709
  hostRef.$vnode$ = rootVnode;
1560
- rootVnode.$elm$ = oldVNode.$elm$ = hostElm.shadowRoot || hostElm ;
1561
- useNativeShadowDom = !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && !(cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */);
1710
+ rootVnode.$elm$ = oldVNode.$elm$ = hostElm;
1711
+ useNativeShadowDom = supportsShadow;
1712
+ {
1713
+ contentRef = hostElm["s-cr"];
1714
+ checkSlotFallbackVisibility = false;
1715
+ }
1562
1716
  patch(oldVNode, rootVnode, isInitialLoad);
1717
+ {
1718
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
1719
+ if (checkSlotRelocate) {
1720
+ markSlotContentForRelocation(rootVnode.$elm$);
1721
+ for (const relocateData of relocateNodes) {
1722
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
1723
+ if (!nodeToRelocate["s-ol"] && win.document) {
1724
+ const orgLocationNode = win.document.createTextNode("");
1725
+ orgLocationNode["s-nr"] = nodeToRelocate;
1726
+ insertBefore(
1727
+ nodeToRelocate.parentNode,
1728
+ nodeToRelocate["s-ol"] = orgLocationNode,
1729
+ nodeToRelocate,
1730
+ isInitialLoad
1731
+ );
1732
+ }
1733
+ }
1734
+ for (const relocateData of relocateNodes) {
1735
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
1736
+ const slotRefNode = relocateData.$slotRefNode$;
1737
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */ && isInitialLoad) {
1738
+ nodeToRelocate["s-ih"] = (_a = nodeToRelocate.hidden) != null ? _a : false;
1739
+ }
1740
+ if (slotRefNode) {
1741
+ const parentNodeRef = slotRefNode.parentNode;
1742
+ let insertBeforeNode = slotRefNode.nextSibling;
1743
+ if (insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */) {
1744
+ let orgLocationNode = (_b = nodeToRelocate["s-ol"]) == null ? void 0 : _b.previousSibling;
1745
+ while (orgLocationNode) {
1746
+ let refNode = (_c = orgLocationNode["s-nr"]) != null ? _c : null;
1747
+ if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === (refNode.__parentNode || refNode.parentNode)) {
1748
+ refNode = refNode.nextSibling;
1749
+ while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
1750
+ refNode = refNode == null ? void 0 : refNode.nextSibling;
1751
+ }
1752
+ if (!refNode || !refNode["s-nr"]) {
1753
+ insertBeforeNode = refNode;
1754
+ break;
1755
+ }
1756
+ }
1757
+ orgLocationNode = orgLocationNode.previousSibling;
1758
+ }
1759
+ }
1760
+ const parent = nodeToRelocate.__parentNode || nodeToRelocate.parentNode;
1761
+ const nextSibling = nodeToRelocate.__nextSibling || nodeToRelocate.nextSibling;
1762
+ if (!insertBeforeNode && parentNodeRef !== parent || nextSibling !== insertBeforeNode) {
1763
+ if (nodeToRelocate !== insertBeforeNode) {
1764
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode, isInitialLoad);
1765
+ if (nodeToRelocate.nodeType === 8 /* CommentNode */ && nodeToRelocate.nodeValue.startsWith("s-nt-")) {
1766
+ const textNode = win.document.createTextNode(nodeToRelocate.nodeValue.replace(/^s-nt-/, ""));
1767
+ textNode["s-hn"] = nodeToRelocate["s-hn"];
1768
+ textNode["s-sn"] = nodeToRelocate["s-sn"];
1769
+ textNode["s-sh"] = nodeToRelocate["s-sh"];
1770
+ textNode["s-sr"] = nodeToRelocate["s-sr"];
1771
+ textNode["s-ol"] = nodeToRelocate["s-ol"];
1772
+ textNode["s-ol"]["s-nr"] = textNode;
1773
+ insertBefore(nodeToRelocate.parentNode, textNode, nodeToRelocate, isInitialLoad);
1774
+ nodeToRelocate.parentNode.removeChild(nodeToRelocate);
1775
+ }
1776
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
1777
+ nodeToRelocate.hidden = (_d = nodeToRelocate["s-ih"]) != null ? _d : false;
1778
+ }
1779
+ }
1780
+ }
1781
+ nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](slotRefNode);
1782
+ } else if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1783
+ nodeToRelocate.hidden = true;
1784
+ }
1785
+ }
1786
+ }
1787
+ if (checkSlotFallbackVisibility) {
1788
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1789
+ }
1790
+ plt.$flags$ &= -2 /* isTmpDisconnected */;
1791
+ relocateNodes.length = 0;
1792
+ }
1793
+ if (!useNativeShadowDom && !(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && hostElm["s-cr"]) {
1794
+ const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
1795
+ for (const childNode of children) {
1796
+ if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
1797
+ if (isInitialLoad && childNode["s-ih"] == null) {
1798
+ childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
1799
+ }
1800
+ if (childNode.nodeType === 1 /* ElementNode */) {
1801
+ childNode.hidden = true;
1802
+ } else if (childNode.nodeType === 3 /* TextNode */ && !!childNode.nodeValue.trim()) {
1803
+ const textCommentNode = win.document.createComment("s-nt-" + childNode.nodeValue);
1804
+ textCommentNode["s-sn"] = childNode["s-sn"];
1805
+ insertBefore(childNode.parentNode, textCommentNode, childNode, isInitialLoad);
1806
+ childNode.parentNode.removeChild(childNode);
1807
+ }
1808
+ }
1809
+ }
1810
+ }
1811
+ contentRef = void 0;
1563
1812
  flushQueuedRefCallbacks();
1564
1813
  };
1565
1814
 
@@ -1606,6 +1855,10 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
1606
1855
  let maybePromise;
1607
1856
  if (isInitialLoad) {
1608
1857
  {
1858
+ if (hostRef.$deferredConnectedCallback$) {
1859
+ hostRef.$deferredConnectedCallback$ = false;
1860
+ safeCall(instance, "connectedCallback", void 0, elm);
1861
+ }
1609
1862
  if (hostRef.$fetchedCbList$.length) {
1610
1863
  hostRef.$fetchedCbList$.forEach((cb) => cb(elm));
1611
1864
  }
@@ -1954,8 +2207,11 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1954
2207
  hostRef.$flags$ &= -9 /* isConstructingInstance */;
1955
2208
  }
1956
2209
  endNewInstance();
1957
- {
2210
+ const needsDeferredCallback = cmpMeta.$flags$ & 4 /* hasSlotRelocation */;
2211
+ if (!needsDeferredCallback) {
1958
2212
  fireConnectedCallback(hostRef.$lazyInstance$, elm);
2213
+ } else {
2214
+ hostRef.$deferredConnectedCallback$ = true;
1959
2215
  }
1960
2216
  } else {
1961
2217
  Cstr = elm.constructor;
@@ -2014,13 +2270,15 @@ var connectedCallback = (elm) => {
2014
2270
  {
2015
2271
  hostId = elm.getAttribute(HYDRATE_ID);
2016
2272
  if (hostId) {
2017
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2018
- const scopeId2 = addStyle(elm.shadowRoot, cmpMeta);
2019
- elm.classList.remove(scopeId2 + "-h", scopeId2 + "-s");
2020
- }
2021
2273
  initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2022
2274
  }
2023
2275
  }
2276
+ if (!hostId) {
2277
+ if (// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
2278
+ cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */)) {
2279
+ setContentReference(elm);
2280
+ }
2281
+ }
2024
2282
  {
2025
2283
  let ancestorComponent = elm;
2026
2284
  while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
@@ -2052,6 +2310,16 @@ var connectedCallback = (elm) => {
2052
2310
  endConnected();
2053
2311
  }
2054
2312
  };
2313
+ var setContentReference = (elm) => {
2314
+ if (!win.document) {
2315
+ return;
2316
+ }
2317
+ const contentRefElm = elm["s-cr"] = win.document.createComment(
2318
+ ""
2319
+ );
2320
+ contentRefElm["s-cn"] = true;
2321
+ insertBefore(elm, contentRefElm, elm.firstChild);
2322
+ };
2055
2323
  var disconnectInstance = (instance, elm) => {
2056
2324
  {
2057
2325
  safeCall(instance, "disconnectedCallback", void 0, elm || instance);
@@ -2096,9 +2364,7 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2096
2364
  {
2097
2365
  plt.$flags$ |= 2 /* appLoaded */;
2098
2366
  }
2099
- {
2100
- hydrateScopedToShadow();
2101
- }
2367
+ let hasSlotRelocation = false;
2102
2368
  lazyBundles.map((lazyBundle) => {
2103
2369
  lazyBundle[1].map((compactMeta) => {
2104
2370
  const cmpMeta = {
@@ -2107,6 +2373,9 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2107
2373
  $members$: compactMeta[2],
2108
2374
  $listeners$: compactMeta[3]
2109
2375
  };
2376
+ if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
2377
+ hasSlotRelocation = true;
2378
+ }
2110
2379
  {
2111
2380
  cmpMeta.$members$ = compactMeta[2];
2112
2381
  }
@@ -2120,19 +2389,6 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2120
2389
  super(self);
2121
2390
  self = this;
2122
2391
  registerHost(self, cmpMeta);
2123
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2124
- {
2125
- if (!self.shadowRoot) {
2126
- createShadowRoot.call(self, cmpMeta);
2127
- } else {
2128
- if (self.shadowRoot.mode !== "open") {
2129
- throw new Error(
2130
- `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but Stencil only supports open shadow roots.`
2131
- );
2132
- }
2133
- }
2134
- }
2135
- }
2136
2392
  }
2137
2393
  connectedCallback() {
2138
2394
  const hostRef = getHostRef(this);
@@ -2185,6 +2441,9 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2185
2441
  });
2186
2442
  });
2187
2443
  if (cmpTags.length > 0) {
2444
+ if (hasSlotRelocation) {
2445
+ dataStyles.textContent += SLOT_FB_CSS;
2446
+ }
2188
2447
  {
2189
2448
  dataStyles.textContent += cmpTags.sort() + HYDRATED_CSS;
2190
2449
  }