@stencil/core 4.18.0 → 4.18.1-dev.1715749302.3cfbb8d

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 (43) hide show
  1. package/cli/index.cjs +106 -215
  2. package/cli/index.js +107 -217
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/stencil.js +1686 -2826
  6. package/dev-server/client/index.js +1 -1
  7. package/dev-server/client/package.json +1 -1
  8. package/dev-server/connector.html +2 -2
  9. package/dev-server/index.js +1 -1
  10. package/dev-server/package.json +1 -1
  11. package/dev-server/server-process.js +117 -227
  12. package/internal/app-data/index.cjs +1 -0
  13. package/internal/app-data/index.js +1 -0
  14. package/internal/app-data/package.json +1 -1
  15. package/internal/client/index.js +58 -36
  16. package/internal/client/package.json +1 -1
  17. package/internal/client/patch-browser.js +1 -1
  18. package/internal/client/shadow-css.js +1 -2
  19. package/internal/hydrate/index.js +58 -36
  20. package/internal/hydrate/package.json +1 -1
  21. package/internal/hydrate/runner.js +52 -89
  22. package/internal/package.json +1 -1
  23. package/internal/stencil-public-compiler.d.ts +12 -1
  24. package/internal/stencil-public-runtime.d.ts +3 -8
  25. package/internal/testing/index.js +57 -35
  26. package/internal/testing/package.json +1 -1
  27. package/mock-doc/index.cjs +378 -493
  28. package/mock-doc/index.d.ts +1 -1
  29. package/mock-doc/index.js +378 -493
  30. package/mock-doc/package.json +1 -1
  31. package/package.json +5 -6
  32. package/screenshot/index.js +43 -85
  33. package/screenshot/package.json +1 -1
  34. package/screenshot/pixel-match.js +14 -27
  35. package/sys/node/glob.js +1 -1
  36. package/sys/node/index.js +42 -42
  37. package/sys/node/package.json +1 -1
  38. package/sys/node/worker.js +1 -1
  39. package/testing/index.js +168 -270
  40. package/testing/jest/jest-27-and-under/jest-facade.d.ts +1 -1
  41. package/testing/jest/jest-28/jest-facade.d.ts +5 -5
  42. package/testing/jest/jest-29/jest-facade.d.ts +5 -5
  43. package/testing/package.json +1 -1
@@ -91,6 +91,7 @@ var BUILD = {
91
91
  cloneNodeFix: false,
92
92
  hydratedAttribute: false,
93
93
  hydratedClass: true,
94
+ // TODO(STENCIL-1305): remove this option
94
95
  scriptDataOpts: false,
95
96
  // TODO(STENCIL-914): remove this option when `experimentalSlotFixes` is the default behavior
96
97
  scopedSlotTextContentFix: false,
@@ -65,6 +65,7 @@ var BUILD = {
65
65
  cloneNodeFix: false,
66
66
  hydratedAttribute: false,
67
67
  hydratedClass: true,
68
+ // TODO(STENCIL-1305): remove this option
68
69
  scriptDataOpts: false,
69
70
  // TODO(STENCIL-914): remove this option when `experimentalSlotFixes` is the default behavior
70
71
  scopedSlotTextContentFix: false,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/app-data",
3
- "version": "4.18.0",
3
+ "version": "4.18.1-dev.1715749302.3cfbb8d",
4
4
  "description": "Used for default app data and build conditionals within builds.",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Client Platform v4.18.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Platform v4.18.1-dev.1715749302.3cfbb8d | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -833,7 +833,7 @@ var checkSlotFallbackVisibility = false;
833
833
  var checkSlotRelocate = false;
834
834
  var isSvgMode = false;
835
835
  var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
836
- var _a, _b, _c, _d;
836
+ var _a;
837
837
  const newVNode2 = newParentVNode.$children$[childIndex];
838
838
  let i2 = 0;
839
839
  let elm;
@@ -885,13 +885,6 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
885
885
  if ((BUILD11.shadowDom || BUILD11.scoped) && isDef(scopeId) && elm["s-si"] !== scopeId) {
886
886
  elm.classList.add(elm["s-si"] = scopeId);
887
887
  }
888
- if (BUILD11.scoped) {
889
- const rootScopeId = ((_a = newParentVNode.$elm$) == null ? void 0 : _a["s-rsc"]) || ((_b = newParentVNode.$elm$) == null ? void 0 : _b["s-si"]) || ((_c = newParentVNode.$elm$) == null ? void 0 : _c["s-sc"]);
890
- if (rootScopeId) {
891
- elm["s-rsc"] = rootScopeId;
892
- !elm.classList.contains(rootScopeId) && elm.classList.add(rootScopeId);
893
- }
894
- }
895
888
  if (newVNode2.$children$) {
896
889
  for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
897
890
  childNode = createElm(oldParentVNode, newVNode2, i2, elm);
@@ -914,7 +907,7 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
914
907
  elm["s-sr"] = true;
915
908
  elm["s-cr"] = contentRef;
916
909
  elm["s-sn"] = newVNode2.$name$ || "";
917
- elm["s-rf"] = (_d = newVNode2.$attrs$) == null ? void 0 : _d.ref;
910
+ elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
918
911
  oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
919
912
  if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
920
913
  if (BUILD11.experimentalSlotFixes) {
@@ -935,7 +928,7 @@ var relocateToHostRoot = (parentElm) => {
935
928
  const childNodeArray = Array.from(parentElm.childNodes);
936
929
  for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
937
930
  if (childNode["s-sh"] != null) {
938
- host.insertBefore(childNode, contentRefNode != null ? contentRefNode : null);
931
+ insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
939
932
  childNode["s-sh"] = void 0;
940
933
  checkSlotRelocate = true;
941
934
  }
@@ -957,7 +950,7 @@ var putBackInOriginalLocation = (parentElm, recursive) => {
957
950
  for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
958
951
  const childNode = oldSlotChildNodes[i2];
959
952
  if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
960
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
953
+ insertBefore(parentReferenceNode(childNode), childNode, referenceNode(childNode));
961
954
  childNode["s-ol"].remove();
962
955
  childNode["s-ol"] = void 0;
963
956
  childNode["s-sh"] = void 0;
@@ -980,7 +973,7 @@ var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
980
973
  childNode = createElm(null, parentVNode, startIdx, parentElm);
981
974
  if (childNode) {
982
975
  vnodes[startIdx].$elm$ = childNode;
983
- containerElm.insertBefore(childNode, BUILD11.slotRelocation ? referenceNode(before) : before);
976
+ insertBefore(containerElm, childNode, BUILD11.slotRelocation ? referenceNode(before) : before);
984
977
  }
985
978
  }
986
979
  }
@@ -1040,7 +1033,7 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
1040
1033
  putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1041
1034
  }
1042
1035
  patch(oldStartVnode, newEndVnode, isInitialRender);
1043
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1036
+ insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1044
1037
  oldStartVnode = oldCh[++oldStartIdx];
1045
1038
  newEndVnode = newCh[--newEndIdx];
1046
1039
  } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
@@ -1048,7 +1041,7 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
1048
1041
  putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1049
1042
  }
1050
1043
  patch(oldEndVnode, newStartVnode, isInitialRender);
1051
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1044
+ insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
1052
1045
  oldEndVnode = oldCh[--oldEndIdx];
1053
1046
  newStartVnode = newCh[++newStartIdx];
1054
1047
  } else {
@@ -1077,9 +1070,9 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
1077
1070
  }
1078
1071
  if (node) {
1079
1072
  if (BUILD11.slotRelocation) {
1080
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
1073
+ insertBefore(parentReferenceNode(oldStartVnode.$elm$), node, referenceNode(oldStartVnode.$elm$));
1081
1074
  } else {
1082
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1075
+ insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1083
1076
  }
1084
1077
  }
1085
1078
  }
@@ -1250,6 +1243,28 @@ var nullifyVNodeRefs = (vNode) => {
1250
1243
  vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1251
1244
  }
1252
1245
  };
1246
+ var insertBefore = (parent, newNode, reference) => {
1247
+ const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
1248
+ if (BUILD11.scoped) {
1249
+ setParentScopeIdAsClassName(newNode, parent);
1250
+ }
1251
+ return inserted;
1252
+ };
1253
+ var findParentScopeId = (element) => {
1254
+ return element ? element["s-rsc"] || element["s-si"] || element["s-sc"] || findParentScopeId(element.parentElement) : void 0;
1255
+ };
1256
+ var setParentScopeIdAsClassName = (element, parent) => {
1257
+ var _a, _b, _c;
1258
+ if (element && parent) {
1259
+ const oldRootScopeId = element["s-rsc"];
1260
+ const newRootScopeId = findParentScopeId(parent);
1261
+ oldRootScopeId && ((_a = element.classList) == null ? void 0 : _a.contains(oldRootScopeId)) && element.classList.remove(oldRootScopeId);
1262
+ if (newRootScopeId) {
1263
+ element["s-rsc"] = newRootScopeId;
1264
+ !((_b = element.classList) == null ? void 0 : _b.contains(newRootScopeId)) && ((_c = element.classList) == null ? void 0 : _c.add(newRootScopeId));
1265
+ }
1266
+ }
1267
+ };
1253
1268
  var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1254
1269
  var _a, _b, _c, _d, _e;
1255
1270
  const hostElm = hostRef.$hostElement$;
@@ -1306,7 +1321,7 @@ render() {
1306
1321
  if (!nodeToRelocate["s-ol"]) {
1307
1322
  const orgLocationNode = BUILD11.isDebug || BUILD11.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
1308
1323
  orgLocationNode["s-nr"] = nodeToRelocate;
1309
- nodeToRelocate.parentNode.insertBefore(nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
1324
+ insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
1310
1325
  }
1311
1326
  }
1312
1327
  for (const relocateData of relocateNodes) {
@@ -1337,7 +1352,7 @@ render() {
1337
1352
  if (!BUILD11.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
1338
1353
  nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
1339
1354
  }
1340
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1355
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
1341
1356
  if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1342
1357
  nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
1343
1358
  }
@@ -1401,6 +1416,11 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
1401
1416
  const elm = hostRef.$hostElement$;
1402
1417
  const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
1403
1418
  const instance = BUILD12.lazyLoad ? hostRef.$lazyInstance$ : elm;
1419
+ if (!instance) {
1420
+ throw new Error(
1421
+ `Can't render component <${elm.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`
1422
+ );
1423
+ }
1404
1424
  let maybePromise;
1405
1425
  if (isInitialLoad) {
1406
1426
  if (BUILD12.lazyLoad && BUILD12.hostListener) {
@@ -1649,6 +1669,11 @@ var serverSideConnected = (elm) => {
1649
1669
  var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1650
1670
  var setValue = (ref, propName, newVal, cmpMeta) => {
1651
1671
  const hostRef = getHostRef(ref);
1672
+ if (BUILD13.lazyLoad && !hostRef) {
1673
+ throw new Error(
1674
+ `Couldn't find host element for "${cmpMeta.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/ionic-team/stencil/issues/5457).`
1675
+ );
1676
+ }
1652
1677
  const elm = BUILD13.lazyLoad ? hostRef.$hostElement$ : ref;
1653
1678
  const oldVal = hostRef.$instanceValues$.get(propName);
1654
1679
  const flags = hostRef.$flags$;
@@ -1971,7 +1996,7 @@ var setContentReference = (elm) => {
1971
1996
  BUILD16.isDebug ? `content-ref (host=${elm.localName})` : ""
1972
1997
  );
1973
1998
  contentRefElm["s-cn"] = true;
1974
- elm.insertBefore(contentRefElm, elm.firstChild);
1999
+ insertBefore(elm, contentRefElm, elm.firstChild);
1975
2000
  };
1976
2001
 
1977
2002
  // src/runtime/disconnected-callback.ts
@@ -2040,7 +2065,8 @@ var patchCloneNode = (HostElementPrototype) => {
2040
2065
  "s-ol",
2041
2066
  "s-nr",
2042
2067
  "s-si",
2043
- "s-rf"
2068
+ "s-rf",
2069
+ "s-rsc"
2044
2070
  ];
2045
2071
  for (; i2 < srcNode.childNodes.length; i2++) {
2046
2072
  slotted = srcNode.childNodes[i2]["s-nr"];
@@ -2068,7 +2094,7 @@ var patchSlotAppendChild = (HostElementPrototype) => {
2068
2094
  if (slotNode) {
2069
2095
  const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2070
2096
  const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2071
- const insertedNode = appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2097
+ const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
2072
2098
  updateFallbackSlotVisibility(this);
2073
2099
  return insertedNode;
2074
2100
  }
@@ -2109,7 +2135,7 @@ var patchSlotPrepend = (HostElementPrototype) => {
2109
2135
  newChild["s-ol"] = slotPlaceholder;
2110
2136
  const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2111
2137
  const appendAfter = slotChildNodes[0];
2112
- return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2138
+ return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
2113
2139
  }
2114
2140
  if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
2115
2141
  newChild.hidden = true;
@@ -2207,7 +2233,7 @@ var patchTextContent = (hostElementPrototype) => {
2207
2233
  if (node["s-sn"] === "") {
2208
2234
  const textNode = this.ownerDocument.createTextNode(value);
2209
2235
  textNode["s-sn"] = "";
2210
- node.parentElement.insertBefore(textNode, node.nextSibling);
2236
+ insertBefore(node.parentElement, textNode, node.nextSibling);
2211
2237
  } else {
2212
2238
  node.remove();
2213
2239
  }
@@ -2238,7 +2264,7 @@ var patchTextContent = (hostElementPrototype) => {
2238
2264
  this.__textContent = value;
2239
2265
  const contentRefElm = this["s-cr"];
2240
2266
  if (contentRefElm) {
2241
- this.insertBefore(contentRefElm, this.firstChild);
2267
+ insertBefore(this, contentRefElm, this.firstChild);
2242
2268
  }
2243
2269
  }
2244
2270
  }
@@ -2632,14 +2658,10 @@ var hostListenerProxy = (hostRef, methodName) => (ev) => {
2632
2658
  }
2633
2659
  };
2634
2660
  var getHostListenerTarget = (elm, flags) => {
2635
- if (BUILD21.hostListenerTargetDocument && flags & 4 /* TargetDocument */)
2636
- return doc;
2637
- if (BUILD21.hostListenerTargetWindow && flags & 8 /* TargetWindow */)
2638
- return win;
2639
- if (BUILD21.hostListenerTargetBody && flags & 16 /* TargetBody */)
2640
- return doc.body;
2641
- if (BUILD21.hostListenerTargetParent && flags & 32 /* TargetParent */)
2642
- return elm.parentElement;
2661
+ if (BUILD21.hostListenerTargetDocument && flags & 4 /* TargetDocument */) return doc;
2662
+ if (BUILD21.hostListenerTargetWindow && flags & 8 /* TargetWindow */) return win;
2663
+ if (BUILD21.hostListenerTargetBody && flags & 16 /* TargetBody */) return doc.body;
2664
+ if (BUILD21.hostListenerTargetParent && flags & 32 /* TargetParent */) return elm.parentElement;
2643
2665
  return elm;
2644
2666
  };
2645
2667
  var hostListenerOpts = (flags) => supportsListenerOptions ? {
@@ -2664,7 +2686,7 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
2664
2686
  const orgLocationNodes = [];
2665
2687
  parseVNodeAnnotations(doc2, doc2.body, docData, orgLocationNodes);
2666
2688
  orgLocationNodes.forEach((orgLocationNode) => {
2667
- var _a, _b;
2689
+ var _a;
2668
2690
  if (orgLocationNode != null && orgLocationNode["s-nr"]) {
2669
2691
  const nodeRef = orgLocationNode["s-nr"];
2670
2692
  let hostId = nodeRef["s-host-id"];
@@ -2687,7 +2709,7 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
2687
2709
  }
2688
2710
  const commentBeforeTextNode = doc2.createComment(childId);
2689
2711
  commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2690
- (_b = nodeRef.parentNode) == null ? void 0 : _b.insertBefore(commentBeforeTextNode, nodeRef);
2712
+ insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
2691
2713
  }
2692
2714
  }
2693
2715
  let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
@@ -2772,7 +2794,7 @@ var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, ind
2772
2794
  if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
2773
2795
  const textNodeId = `${TEXT_NODE_ID}.${childId}`;
2774
2796
  const commentBeforeTextNode = doc2.createComment(textNodeId);
2775
- parentNode == null ? void 0 : parentNode.insertBefore(commentBeforeTextNode, childElm);
2797
+ insertBefore(parentNode, commentBeforeTextNode, childElm);
2776
2798
  }
2777
2799
  } else if (childElm.nodeType === 8 /* CommentNode */) {
2778
2800
  if (childElm["s-sr"]) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/client",
3
- "version": "4.18.0",
3
+ "version": "4.18.1-dev.1715749302.3cfbb8d",
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
  "private": true,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Client Patch Browser v4.18.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Patch Browser v4.18.1-dev.1715749302.3cfbb8d | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
 
5
5
  // src/client/client-patch-browser.ts
@@ -136,8 +136,7 @@ var convertColonRule = (cssText, regExp, partReplacer) => {
136
136
  const r = [];
137
137
  for (let i = 0; i < parts.length; i++) {
138
138
  const p = parts[i].trim();
139
- if (!p)
140
- break;
139
+ if (!p) break;
141
140
  r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
142
141
  }
143
142
  return r.join(",");
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Hydrate Platform v4.18.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Hydrate Platform v4.18.1-dev.1715749302.3cfbb8d | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -822,7 +822,7 @@ var checkSlotFallbackVisibility = false;
822
822
  var checkSlotRelocate = false;
823
823
  var isSvgMode = false;
824
824
  var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
825
- var _a, _b, _c, _d;
825
+ var _a;
826
826
  const newVNode2 = newParentVNode.$children$[childIndex];
827
827
  let i2 = 0;
828
828
  let elm;
@@ -874,13 +874,6 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
874
874
  if ((BUILD10.shadowDom || BUILD10.scoped) && isDef(scopeId) && elm["s-si"] !== scopeId) {
875
875
  elm.classList.add(elm["s-si"] = scopeId);
876
876
  }
877
- if (BUILD10.scoped) {
878
- const rootScopeId = ((_a = newParentVNode.$elm$) == null ? void 0 : _a["s-rsc"]) || ((_b = newParentVNode.$elm$) == null ? void 0 : _b["s-si"]) || ((_c = newParentVNode.$elm$) == null ? void 0 : _c["s-sc"]);
879
- if (rootScopeId) {
880
- elm["s-rsc"] = rootScopeId;
881
- !elm.classList.contains(rootScopeId) && elm.classList.add(rootScopeId);
882
- }
883
- }
884
877
  if (newVNode2.$children$) {
885
878
  for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
886
879
  childNode = createElm(oldParentVNode, newVNode2, i2, elm);
@@ -903,7 +896,7 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
903
896
  elm["s-sr"] = true;
904
897
  elm["s-cr"] = contentRef;
905
898
  elm["s-sn"] = newVNode2.$name$ || "";
906
- elm["s-rf"] = (_d = newVNode2.$attrs$) == null ? void 0 : _d.ref;
899
+ elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
907
900
  oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
908
901
  if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
909
902
  if (BUILD10.experimentalSlotFixes) {
@@ -924,7 +917,7 @@ var relocateToHostRoot = (parentElm) => {
924
917
  const childNodeArray = Array.from(parentElm.childNodes);
925
918
  for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
926
919
  if (childNode["s-sh"] != null) {
927
- host.insertBefore(childNode, contentRefNode != null ? contentRefNode : null);
920
+ insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
928
921
  childNode["s-sh"] = void 0;
929
922
  checkSlotRelocate = true;
930
923
  }
@@ -946,7 +939,7 @@ var putBackInOriginalLocation = (parentElm, recursive) => {
946
939
  for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
947
940
  const childNode = oldSlotChildNodes[i2];
948
941
  if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
949
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
942
+ insertBefore(parentReferenceNode(childNode), childNode, referenceNode(childNode));
950
943
  childNode["s-ol"].remove();
951
944
  childNode["s-ol"] = void 0;
952
945
  childNode["s-sh"] = void 0;
@@ -969,7 +962,7 @@ var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
969
962
  childNode = createElm(null, parentVNode, startIdx, parentElm);
970
963
  if (childNode) {
971
964
  vnodes[startIdx].$elm$ = childNode;
972
- containerElm.insertBefore(childNode, BUILD10.slotRelocation ? referenceNode(before) : before);
965
+ insertBefore(containerElm, childNode, BUILD10.slotRelocation ? referenceNode(before) : before);
973
966
  }
974
967
  }
975
968
  }
@@ -1029,7 +1022,7 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
1029
1022
  putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1030
1023
  }
1031
1024
  patch(oldStartVnode, newEndVnode, isInitialRender);
1032
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1025
+ insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1033
1026
  oldStartVnode = oldCh[++oldStartIdx];
1034
1027
  newEndVnode = newCh[--newEndIdx];
1035
1028
  } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
@@ -1037,7 +1030,7 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
1037
1030
  putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1038
1031
  }
1039
1032
  patch(oldEndVnode, newStartVnode, isInitialRender);
1040
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1033
+ insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
1041
1034
  oldEndVnode = oldCh[--oldEndIdx];
1042
1035
  newStartVnode = newCh[++newStartIdx];
1043
1036
  } else {
@@ -1066,9 +1059,9 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
1066
1059
  }
1067
1060
  if (node) {
1068
1061
  if (BUILD10.slotRelocation) {
1069
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
1062
+ insertBefore(parentReferenceNode(oldStartVnode.$elm$), node, referenceNode(oldStartVnode.$elm$));
1070
1063
  } else {
1071
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1064
+ insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1072
1065
  }
1073
1066
  }
1074
1067
  }
@@ -1239,6 +1232,28 @@ var nullifyVNodeRefs = (vNode) => {
1239
1232
  vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1240
1233
  }
1241
1234
  };
1235
+ var insertBefore = (parent, newNode, reference) => {
1236
+ const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
1237
+ if (BUILD10.scoped) {
1238
+ setParentScopeIdAsClassName(newNode, parent);
1239
+ }
1240
+ return inserted;
1241
+ };
1242
+ var findParentScopeId = (element) => {
1243
+ return element ? element["s-rsc"] || element["s-si"] || element["s-sc"] || findParentScopeId(element.parentElement) : void 0;
1244
+ };
1245
+ var setParentScopeIdAsClassName = (element, parent) => {
1246
+ var _a, _b, _c;
1247
+ if (element && parent) {
1248
+ const oldRootScopeId = element["s-rsc"];
1249
+ const newRootScopeId = findParentScopeId(parent);
1250
+ oldRootScopeId && ((_a = element.classList) == null ? void 0 : _a.contains(oldRootScopeId)) && element.classList.remove(oldRootScopeId);
1251
+ if (newRootScopeId) {
1252
+ element["s-rsc"] = newRootScopeId;
1253
+ !((_b = element.classList) == null ? void 0 : _b.contains(newRootScopeId)) && ((_c = element.classList) == null ? void 0 : _c.add(newRootScopeId));
1254
+ }
1255
+ }
1256
+ };
1242
1257
  var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1243
1258
  var _a, _b, _c, _d, _e;
1244
1259
  const hostElm = hostRef.$hostElement$;
@@ -1295,7 +1310,7 @@ render() {
1295
1310
  if (!nodeToRelocate["s-ol"]) {
1296
1311
  const orgLocationNode = BUILD10.isDebug || BUILD10.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
1297
1312
  orgLocationNode["s-nr"] = nodeToRelocate;
1298
- nodeToRelocate.parentNode.insertBefore(nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
1313
+ insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
1299
1314
  }
1300
1315
  }
1301
1316
  for (const relocateData of relocateNodes) {
@@ -1326,7 +1341,7 @@ render() {
1326
1341
  if (!BUILD10.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
1327
1342
  nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
1328
1343
  }
1329
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1344
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
1330
1345
  if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1331
1346
  nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
1332
1347
  }
@@ -1390,6 +1405,11 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
1390
1405
  const elm = hostRef.$hostElement$;
1391
1406
  const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
1392
1407
  const instance = BUILD11.lazyLoad ? hostRef.$lazyInstance$ : elm;
1408
+ if (!instance) {
1409
+ throw new Error(
1410
+ `Can't render component <${elm.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`
1411
+ );
1412
+ }
1393
1413
  let maybePromise;
1394
1414
  if (isInitialLoad) {
1395
1415
  if (BUILD11.lazyLoad && BUILD11.hostListener) {
@@ -1638,6 +1658,11 @@ var serverSideConnected = (elm) => {
1638
1658
  var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1639
1659
  var setValue = (ref, propName, newVal, cmpMeta) => {
1640
1660
  const hostRef = getHostRef(ref);
1661
+ if (BUILD12.lazyLoad && !hostRef) {
1662
+ throw new Error(
1663
+ `Couldn't find host element for "${cmpMeta.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/ionic-team/stencil/issues/5457).`
1664
+ );
1665
+ }
1641
1666
  const elm = BUILD12.lazyLoad ? hostRef.$hostElement$ : ref;
1642
1667
  const oldVal = hostRef.$instanceValues$.get(propName);
1643
1668
  const flags = hostRef.$flags$;
@@ -1960,7 +1985,7 @@ var setContentReference = (elm) => {
1960
1985
  BUILD15.isDebug ? `content-ref (host=${elm.localName})` : ""
1961
1986
  );
1962
1987
  contentRefElm["s-cn"] = true;
1963
- elm.insertBefore(contentRefElm, elm.firstChild);
1988
+ insertBefore(elm, contentRefElm, elm.firstChild);
1964
1989
  };
1965
1990
 
1966
1991
  // src/runtime/disconnected-callback.ts
@@ -2029,7 +2054,8 @@ var patchCloneNode = (HostElementPrototype) => {
2029
2054
  "s-ol",
2030
2055
  "s-nr",
2031
2056
  "s-si",
2032
- "s-rf"
2057
+ "s-rf",
2058
+ "s-rsc"
2033
2059
  ];
2034
2060
  for (; i2 < srcNode.childNodes.length; i2++) {
2035
2061
  slotted = srcNode.childNodes[i2]["s-nr"];
@@ -2057,7 +2083,7 @@ var patchSlotAppendChild = (HostElementPrototype) => {
2057
2083
  if (slotNode) {
2058
2084
  const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2059
2085
  const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2060
- const insertedNode = appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2086
+ const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
2061
2087
  updateFallbackSlotVisibility(this);
2062
2088
  return insertedNode;
2063
2089
  }
@@ -2098,7 +2124,7 @@ var patchSlotPrepend = (HostElementPrototype) => {
2098
2124
  newChild["s-ol"] = slotPlaceholder;
2099
2125
  const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2100
2126
  const appendAfter = slotChildNodes[0];
2101
- return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2127
+ return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
2102
2128
  }
2103
2129
  if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
2104
2130
  newChild.hidden = true;
@@ -2196,7 +2222,7 @@ var patchTextContent = (hostElementPrototype) => {
2196
2222
  if (node["s-sn"] === "") {
2197
2223
  const textNode = this.ownerDocument.createTextNode(value);
2198
2224
  textNode["s-sn"] = "";
2199
- node.parentElement.insertBefore(textNode, node.nextSibling);
2225
+ insertBefore(node.parentElement, textNode, node.nextSibling);
2200
2226
  } else {
2201
2227
  node.remove();
2202
2228
  }
@@ -2227,7 +2253,7 @@ var patchTextContent = (hostElementPrototype) => {
2227
2253
  this.__textContent = value;
2228
2254
  const contentRefElm = this["s-cr"];
2229
2255
  if (contentRefElm) {
2230
- this.insertBefore(contentRefElm, this.firstChild);
2256
+ insertBefore(this, contentRefElm, this.firstChild);
2231
2257
  }
2232
2258
  }
2233
2259
  }
@@ -2621,14 +2647,10 @@ var hostListenerProxy = (hostRef, methodName) => (ev) => {
2621
2647
  }
2622
2648
  };
2623
2649
  var getHostListenerTarget = (elm, flags) => {
2624
- if (BUILD20.hostListenerTargetDocument && flags & 4 /* TargetDocument */)
2625
- return doc;
2626
- if (BUILD20.hostListenerTargetWindow && flags & 8 /* TargetWindow */)
2627
- return win;
2628
- if (BUILD20.hostListenerTargetBody && flags & 16 /* TargetBody */)
2629
- return doc.body;
2630
- if (BUILD20.hostListenerTargetParent && flags & 32 /* TargetParent */)
2631
- return elm.parentElement;
2650
+ if (BUILD20.hostListenerTargetDocument && flags & 4 /* TargetDocument */) return doc;
2651
+ if (BUILD20.hostListenerTargetWindow && flags & 8 /* TargetWindow */) return win;
2652
+ if (BUILD20.hostListenerTargetBody && flags & 16 /* TargetBody */) return doc.body;
2653
+ if (BUILD20.hostListenerTargetParent && flags & 32 /* TargetParent */) return elm.parentElement;
2632
2654
  return elm;
2633
2655
  };
2634
2656
  var hostListenerOpts = (flags) => supportsListenerOptions ? {
@@ -2650,7 +2672,7 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
2650
2672
  const orgLocationNodes = [];
2651
2673
  parseVNodeAnnotations(doc2, doc2.body, docData, orgLocationNodes);
2652
2674
  orgLocationNodes.forEach((orgLocationNode) => {
2653
- var _a, _b;
2675
+ var _a;
2654
2676
  if (orgLocationNode != null && orgLocationNode["s-nr"]) {
2655
2677
  const nodeRef = orgLocationNode["s-nr"];
2656
2678
  let hostId = nodeRef["s-host-id"];
@@ -2673,7 +2695,7 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
2673
2695
  }
2674
2696
  const commentBeforeTextNode = doc2.createComment(childId);
2675
2697
  commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2676
- (_b = nodeRef.parentNode) == null ? void 0 : _b.insertBefore(commentBeforeTextNode, nodeRef);
2698
+ insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
2677
2699
  }
2678
2700
  }
2679
2701
  let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
@@ -2758,7 +2780,7 @@ var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, ind
2758
2780
  if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
2759
2781
  const textNodeId = `${TEXT_NODE_ID}.${childId}`;
2760
2782
  const commentBeforeTextNode = doc2.createComment(textNodeId);
2761
- parentNode == null ? void 0 : parentNode.insertBefore(commentBeforeTextNode, childElm);
2783
+ insertBefore(parentNode, commentBeforeTextNode, childElm);
2762
2784
  }
2763
2785
  } else if (childElm.nodeType === 8 /* CommentNode */) {
2764
2786
  if (childElm["s-sr"]) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/hydrate",
3
- "version": "4.18.0",
3
+ "version": "4.18.1-dev.1715749302.3cfbb8d",
4
4
  "description": "Stencil internal hydrate platform to be imported by the Stencil Compiler. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "private": true