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