@stencil/core 4.26.0-dev.1739854908.eafe1f9 → 4.26.0-dev.1739941303.2a1038e

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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Client Platform v4.26.0-dev.1739854908.eafe1f9 | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Platform v4.26.0-dev.1739941303.2a1038e | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -386,12 +386,12 @@ import { BUILD as BUILD9 } from "@stencil/core/internal/app-data";
386
386
  // src/runtime/slot-polyfill-utils.ts
387
387
  import { BUILD as BUILD8 } from "@stencil/core/internal/app-data";
388
388
  var updateFallbackSlotVisibility = (elm) => {
389
- const childNodes = elm.__childNodes || elm.childNodes;
389
+ const childNodes = internalCall(elm, "childNodes");
390
390
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
391
391
  getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
392
392
  var _a;
393
393
  if (slotNode.nodeType === 1 /* ElementNode */ && slotNode.tagName === "SLOT-FB") {
394
- if ((_a = getHostSlotChildNodes(slotNode, slotNode["s-sn"], false)) == null ? void 0 : _a.length) {
394
+ if ((_a = getSlotChildSiblings(slotNode, getSlotName(slotNode), false)) == null ? void 0 : _a.length) {
395
395
  slotNode.hidden = true;
396
396
  } else {
397
397
  slotNode.hidden = false;
@@ -399,8 +399,10 @@ var updateFallbackSlotVisibility = (elm) => {
399
399
  }
400
400
  });
401
401
  }
402
- for (const childNode of childNodes) {
403
- if (childNode.nodeType === 1 /* ElementNode */ && (childNode.__childNodes || childNode.childNodes).length) {
402
+ let i2 = 0;
403
+ for (i2 = 0; i2 < childNodes.length; i2++) {
404
+ const childNode = childNodes[i2];
405
+ if (childNode.nodeType === 1 /* ElementNode */ && internalCall(childNode, "childNodes").length) {
404
406
  updateFallbackSlotVisibility(childNode);
405
407
  }
406
408
  }
@@ -421,7 +423,7 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
421
423
  let childNode;
422
424
  for (; i2 < childNodes.length; i2++) {
423
425
  childNode = childNodes[i2];
424
- if (childNode["s-sr"] && childNode["s-hn"] === hostName && (slotName === void 0 || childNode["s-sn"] === slotName)) {
426
+ if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0 || getSlotName(childNode) === slotName)) {
425
427
  slottedNodes.push(childNode);
426
428
  if (typeof slotName !== "undefined") return slottedNodes;
427
429
  }
@@ -429,11 +431,12 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
429
431
  }
430
432
  return slottedNodes;
431
433
  }
432
- var getHostSlotChildNodes = (node, slotName, includeSlot = true) => {
434
+ var getSlotChildSiblings = (slot, slotName, includeSlot = true) => {
433
435
  const childNodes = [];
434
- if (includeSlot && node["s-sr"] || !node["s-sr"]) childNodes.push(node);
435
- while ((node = node.nextSibling) && node["s-sn"] === slotName) {
436
- childNodes.push(node);
436
+ if (includeSlot && slot["s-sr"] || !slot["s-sr"]) childNodes.push(slot);
437
+ let node = slot;
438
+ while (node = node.nextSibling) {
439
+ if (getSlotName(node) === slotName) childNodes.push(node);
437
440
  }
438
441
  return childNodes;
439
442
  };
@@ -453,38 +456,73 @@ var isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
453
456
  return slotName === "";
454
457
  };
455
458
  var addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
456
- let slottedNodeLocation;
457
459
  if (newChild["s-ol"] && newChild["s-ol"].isConnected) {
458
- slottedNodeLocation = newChild["s-ol"];
459
- } else {
460
- slottedNodeLocation = document.createTextNode("");
461
- slottedNodeLocation["s-nr"] = newChild;
460
+ return;
462
461
  }
462
+ const slottedNodeLocation = document.createTextNode("");
463
+ slottedNodeLocation["s-nr"] = newChild;
463
464
  if (!slotNode["s-cr"] || !slotNode["s-cr"].parentNode) return;
464
465
  const parent = slotNode["s-cr"].parentNode;
465
- const appendMethod = prepend ? parent.__prepend || parent.prepend : parent.__appendChild || parent.appendChild;
466
- if (typeof position !== "undefined") {
467
- if (BUILD8.hydrateClientSide) {
468
- slottedNodeLocation["s-oo"] = position;
469
- const childNodes = parent.__childNodes || parent.childNodes;
470
- const slotRelocateNodes = [slottedNodeLocation];
471
- childNodes.forEach((n) => {
472
- if (n["s-nr"]) slotRelocateNodes.push(n);
473
- });
474
- slotRelocateNodes.sort((a, b) => {
475
- if (!a["s-oo"] || a["s-oo"] < b["s-oo"]) return -1;
476
- else if (!b["s-oo"] || b["s-oo"] < a["s-oo"]) return 1;
477
- return 0;
478
- });
479
- slotRelocateNodes.forEach((n) => appendMethod.call(parent, n));
480
- }
466
+ const appendMethod = prepend ? internalCall(parent, "prepend") : internalCall(parent, "appendChild");
467
+ if (BUILD8.hydrateClientSide && typeof position !== "undefined") {
468
+ slottedNodeLocation["s-oo"] = position;
469
+ const childNodes = internalCall(parent, "childNodes");
470
+ const slotRelocateNodes = [slottedNodeLocation];
471
+ childNodes.forEach((n) => {
472
+ if (n["s-nr"]) slotRelocateNodes.push(n);
473
+ });
474
+ slotRelocateNodes.sort((a, b) => {
475
+ if (!a["s-oo"] || a["s-oo"] < (b["s-oo"] || 0)) return -1;
476
+ else if (!b["s-oo"] || b["s-oo"] < a["s-oo"]) return 1;
477
+ return 0;
478
+ });
479
+ slotRelocateNodes.forEach((n) => appendMethod.call(parent, n));
481
480
  } else {
482
481
  appendMethod.call(parent, slottedNodeLocation);
483
482
  }
484
483
  newChild["s-ol"] = slottedNodeLocation;
485
484
  newChild["s-sh"] = slotNode["s-hn"];
486
485
  };
487
- var getSlotName = (node) => node["s-sn"] || node.nodeType === 1 && node.getAttribute("slot") || "";
486
+ var getSlotName = (node) => typeof node["s-sn"] === "string" ? node["s-sn"] : node.nodeType === 1 && node.getAttribute("slot") || void 0;
487
+ function patchSlotNode(node) {
488
+ if (node.assignedElements || node.assignedNodes || !node["s-sr"]) return;
489
+ const assignedFactory = (elementsOnly) => (function(opts) {
490
+ const toReturn = [];
491
+ const slotName = this["s-sn"];
492
+ if (opts == null ? void 0 : opts.flatten) {
493
+ console.error(`
494
+ Flattening is not supported for Stencil non-shadow slots.
495
+ You can use \`.childNodes\` to nested slot fallback content.
496
+ If you have a particular use case, please open an issue on the Stencil repo.
497
+ `);
498
+ }
499
+ const parent = this["s-cr"].parentElement;
500
+ const slottedNodes = parent.__childNodes ? parent.childNodes : getSlottedChildNodes(parent.childNodes);
501
+ slottedNodes.forEach((n) => {
502
+ if (slotName === getSlotName(n)) {
503
+ toReturn.push(n);
504
+ }
505
+ });
506
+ if (elementsOnly) {
507
+ return toReturn.filter((n) => n.nodeType === 1 /* ElementNode */);
508
+ }
509
+ return toReturn;
510
+ }).bind(node);
511
+ node.assignedElements = assignedFactory(true);
512
+ node.assignedNodes = assignedFactory(false);
513
+ }
514
+ function dispatchSlotChangeEvent(elm) {
515
+ elm.dispatchEvent(new CustomEvent("slotchange", { bubbles: false, cancelable: false, composed: false }));
516
+ }
517
+ function findSlotFromSlottedNode(slottedNode, parentHost) {
518
+ var _a;
519
+ parentHost = parentHost || ((_a = slottedNode["s-ol"]) == null ? void 0 : _a.parentElement);
520
+ if (!parentHost) return { slotNode: null, slotName: "" };
521
+ const slotName = slottedNode["s-sn"] = getSlotName(slottedNode) || "";
522
+ const childNodes = internalCall(parentHost, "childNodes");
523
+ const slotNode = getHostSlotNodes(childNodes, parentHost.tagName, slotName)[0];
524
+ return { slotNode, slotName };
525
+ }
488
526
 
489
527
  // src/runtime/dom-extras.ts
490
528
  var patchPseudoShadowDom = (hostElementPrototype) => {
@@ -548,19 +586,14 @@ var patchCloneNode = (HostElementPrototype) => {
548
586
  var patchSlotAppendChild = (HostElementPrototype) => {
549
587
  HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
550
588
  HostElementPrototype.appendChild = function(newChild) {
551
- const slotName = newChild["s-sn"] = getSlotName(newChild);
552
- const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, slotName)[0];
589
+ const { slotName, slotNode } = findSlotFromSlottedNode(newChild, this);
553
590
  if (slotNode) {
554
591
  addSlotRelocateNode(newChild, slotNode);
555
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
592
+ const slotChildNodes = getSlotChildSiblings(slotNode, slotName);
556
593
  const appendAfter = slotChildNodes[slotChildNodes.length - 1];
557
- const parent = intrnlCall(appendAfter, "parentNode");
558
- let insertedNode;
559
- if (parent.__insertBefore) {
560
- insertedNode = parent.__insertBefore(newChild, appendAfter.nextSibling);
561
- } else {
562
- insertedNode = parent.insertBefore(newChild, appendAfter.nextSibling);
563
- }
594
+ const parent = internalCall(appendAfter, "parentNode");
595
+ const insertedNode = internalCall(parent, "insertBefore")(newChild, appendAfter.nextSibling);
596
+ dispatchSlotChangeEvent(slotNode);
564
597
  updateFallbackSlotVisibility(this);
565
598
  return insertedNode;
566
599
  }
@@ -589,19 +622,17 @@ var patchSlotPrepend = (HostElementPrototype) => {
589
622
  if (typeof newChild === "string") {
590
623
  newChild = this.ownerDocument.createTextNode(newChild);
591
624
  }
592
- const slotName = newChild["s-sn"] = getSlotName(newChild);
593
- const childNodes = this.__childNodes || this.childNodes;
625
+ const slotName = (newChild["s-sn"] = getSlotName(newChild)) || "";
626
+ const childNodes = internalCall(this, "childNodes");
594
627
  const slotNode = getHostSlotNodes(childNodes, this.tagName, slotName)[0];
595
628
  if (slotNode) {
596
629
  addSlotRelocateNode(newChild, slotNode, true);
597
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
630
+ const slotChildNodes = getSlotChildSiblings(slotNode, slotName);
598
631
  const appendAfter = slotChildNodes[0];
599
- const parent = intrnlCall(appendAfter, "parentNode");
600
- if (parent.__insertBefore) {
601
- return parent.__insertBefore(newChild, intrnlCall(appendAfter, "nextSibling"));
602
- } else {
603
- return parent.insertBefore(newChild, intrnlCall(appendAfter, "nextSibling"));
604
- }
632
+ const parent = internalCall(appendAfter, "parentNode");
633
+ const toReturn = internalCall(parent, "insertBefore")(newChild, internalCall(appendAfter, "nextSibling"));
634
+ dispatchSlotChangeEvent(slotNode);
635
+ return toReturn;
605
636
  }
606
637
  if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
607
638
  newChild.hidden = true;
@@ -651,8 +682,7 @@ var patchInsertBefore = (HostElementPrototype) => {
651
682
  if (eleProto.__insertBefore) return;
652
683
  eleProto.__insertBefore = HostElementPrototype.insertBefore;
653
684
  HostElementPrototype.insertBefore = function(newChild, currentChild) {
654
- const slotName = newChild["s-sn"] = getSlotName(newChild);
655
- const slotNode = getHostSlotNodes(this.__childNodes, this.tagName, slotName)[0];
685
+ const { slotName, slotNode } = findSlotFromSlottedNode(newChild, this);
656
686
  const slottedNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
657
687
  if (slotNode) {
658
688
  let found = false;
@@ -665,12 +695,9 @@ var patchInsertBefore = (HostElementPrototype) => {
665
695
  }
666
696
  if (slotName === currentChild["s-sn"]) {
667
697
  addSlotRelocateNode(newChild, slotNode);
668
- const parent = intrnlCall(currentChild, "parentNode");
669
- if (parent.__insertBefore) {
670
- parent.__insertBefore(newChild, currentChild);
671
- } else {
672
- parent.insertBefore(newChild, currentChild);
673
- }
698
+ const parent = internalCall(currentChild, "parentNode");
699
+ internalCall(parent, "insertBefore")(newChild, currentChild);
700
+ dispatchSlotChangeEvent(slotNode);
674
701
  }
675
702
  return;
676
703
  }
@@ -758,7 +785,7 @@ var patchChildSlotNodes = (elm) => {
758
785
  });
759
786
  };
760
787
  var patchSlottedNode = (node) => {
761
- if (!node || node.__nextSibling || !globalThis.Node) return;
788
+ if (!node || node.__nextSibling !== void 0 || !globalThis.Node) return;
762
789
  patchNextSibling(node);
763
790
  patchPreviousSibling(node);
764
791
  patchParentNode(node);
@@ -862,11 +889,14 @@ function patchHostOriginalAccessor(accessorName, node) {
862
889
  }
863
890
  if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
864
891
  }
865
- function intrnlCall(node, method) {
892
+ function internalCall(node, method) {
866
893
  if ("__" + method in node) {
867
- return node["__" + method];
894
+ const toReturn = node["__" + method];
895
+ if (typeof toReturn !== "function") return toReturn;
896
+ return toReturn.bind(node);
868
897
  } else {
869
- return node[method];
898
+ if (typeof node[method] !== "function") return node[method];
899
+ return node[method].bind(node);
870
900
  }
871
901
  }
872
902
 
@@ -1462,6 +1492,7 @@ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNod
1462
1492
  const slot = childVNode.$elm$;
1463
1493
  const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
1464
1494
  addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
1495
+ patchSlotNode(node);
1465
1496
  if (shouldMove) {
1466
1497
  parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1467
1498
  }
@@ -2126,7 +2157,7 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
2126
2157
  elm.removeAttribute(memberName);
2127
2158
  }
2128
2159
  }
2129
- } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
2160
+ } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex && elm.nodeType === 1 /* ElementNode */) {
2130
2161
  newValue = newValue === true ? "" : newValue;
2131
2162
  if (BUILD17.vdomXlink && xlink) {
2132
2163
  elm.setAttributeNS(XLINK_NS, memberName, newValue);
@@ -2231,6 +2262,9 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2231
2262
  elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
2232
2263
  } else if (BUILD19.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
2233
2264
  elm = newVNode2.$elm$ = BUILD19.isDebug || BUILD19.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
2265
+ if (BUILD19.vdomAttribute) {
2266
+ updateElement(null, newVNode2, isSvgMode);
2267
+ }
2234
2268
  } else {
2235
2269
  if (BUILD19.svg && !isSvgMode) {
2236
2270
  isSvgMode = newVNode2.$tag$ === "svg";
@@ -2273,6 +2307,7 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2273
2307
  elm["s-cr"] = contentRef;
2274
2308
  elm["s-sn"] = newVNode2.$name$ || "";
2275
2309
  elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
2310
+ patchSlotNode(elm);
2276
2311
  oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
2277
2312
  if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
2278
2313
  if (BUILD19.experimentalSlotFixes) {
@@ -2499,9 +2534,8 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
2499
2534
  newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
2500
2535
  relocateToHostRoot(newVNode2.$elm$.parentElement);
2501
2536
  }
2502
- } else {
2503
- updateElement(oldVNode, newVNode2, isSvgMode, isInitialRender);
2504
2537
  }
2538
+ updateElement(oldVNode, newVNode2, isSvgMode, isInitialRender);
2505
2539
  }
2506
2540
  if (BUILD19.updatable && oldChildren !== null && newChildren !== null) {
2507
2541
  updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
@@ -2588,7 +2622,10 @@ var insertBefore = (parent, newNode, reference) => {
2588
2622
  if (parent.getRootNode().nodeType !== 11 /* DOCUMENT_FRAGMENT_NODE */) {
2589
2623
  patchParentNode(newNode);
2590
2624
  }
2591
- return parent.insertBefore(newNode, reference);
2625
+ parent.insertBefore(newNode, reference);
2626
+ const { slotNode } = findSlotFromSlottedNode(newNode);
2627
+ if (slotNode) dispatchSlotChangeEvent(slotNode);
2628
+ return newNode;
2592
2629
  }
2593
2630
  if (BUILD19.experimentalSlotFixes && parent.__insertBefore) {
2594
2631
  return parent.__insertBefore(newNode, reference);
@@ -2712,7 +2749,7 @@ render() {
2712
2749
  }
2713
2750
  }
2714
2751
  }
2715
- nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
2752
+ nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](slotRefNode);
2716
2753
  } else {
2717
2754
  if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
2718
2755
  if (isInitialLoad) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/client",
3
- "version": "4.26.0-dev.1739854908.eafe1f9",
3
+ "version": "4.26.0-dev.1739941303.2a1038e",
4
4
  "description": "Stencil internal client platform to be imported by the Stencil Compiler and internal runtime. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "exports": "./index.js",
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Client Patch Browser v4.26.0-dev.1739854908.eafe1f9 | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Patch Browser v4.26.0-dev.1739941303.2a1038e | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
 
5
5
  // src/client/client-patch-browser.ts