@stencil/core 4.18.0 → 4.18.1

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 +53 -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 +53 -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 +1 -0
  25. package/internal/testing/index.js +52 -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 +148 -268
  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",
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 | 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
  }
@@ -1649,6 +1664,11 @@ var serverSideConnected = (elm) => {
1649
1664
  var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1650
1665
  var setValue = (ref, propName, newVal, cmpMeta) => {
1651
1666
  const hostRef = getHostRef(ref);
1667
+ if (BUILD13.lazyLoad && !hostRef) {
1668
+ throw new Error(
1669
+ `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).`
1670
+ );
1671
+ }
1652
1672
  const elm = BUILD13.lazyLoad ? hostRef.$hostElement$ : ref;
1653
1673
  const oldVal = hostRef.$instanceValues$.get(propName);
1654
1674
  const flags = hostRef.$flags$;
@@ -1971,7 +1991,7 @@ var setContentReference = (elm) => {
1971
1991
  BUILD16.isDebug ? `content-ref (host=${elm.localName})` : ""
1972
1992
  );
1973
1993
  contentRefElm["s-cn"] = true;
1974
- elm.insertBefore(contentRefElm, elm.firstChild);
1994
+ insertBefore(elm, contentRefElm, elm.firstChild);
1975
1995
  };
1976
1996
 
1977
1997
  // src/runtime/disconnected-callback.ts
@@ -2040,7 +2060,8 @@ var patchCloneNode = (HostElementPrototype) => {
2040
2060
  "s-ol",
2041
2061
  "s-nr",
2042
2062
  "s-si",
2043
- "s-rf"
2063
+ "s-rf",
2064
+ "s-rsc"
2044
2065
  ];
2045
2066
  for (; i2 < srcNode.childNodes.length; i2++) {
2046
2067
  slotted = srcNode.childNodes[i2]["s-nr"];
@@ -2068,7 +2089,7 @@ var patchSlotAppendChild = (HostElementPrototype) => {
2068
2089
  if (slotNode) {
2069
2090
  const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2070
2091
  const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2071
- const insertedNode = appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2092
+ const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
2072
2093
  updateFallbackSlotVisibility(this);
2073
2094
  return insertedNode;
2074
2095
  }
@@ -2109,7 +2130,7 @@ var patchSlotPrepend = (HostElementPrototype) => {
2109
2130
  newChild["s-ol"] = slotPlaceholder;
2110
2131
  const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2111
2132
  const appendAfter = slotChildNodes[0];
2112
- return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2133
+ return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
2113
2134
  }
2114
2135
  if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
2115
2136
  newChild.hidden = true;
@@ -2207,7 +2228,7 @@ var patchTextContent = (hostElementPrototype) => {
2207
2228
  if (node["s-sn"] === "") {
2208
2229
  const textNode = this.ownerDocument.createTextNode(value);
2209
2230
  textNode["s-sn"] = "";
2210
- node.parentElement.insertBefore(textNode, node.nextSibling);
2231
+ insertBefore(node.parentElement, textNode, node.nextSibling);
2211
2232
  } else {
2212
2233
  node.remove();
2213
2234
  }
@@ -2238,7 +2259,7 @@ var patchTextContent = (hostElementPrototype) => {
2238
2259
  this.__textContent = value;
2239
2260
  const contentRefElm = this["s-cr"];
2240
2261
  if (contentRefElm) {
2241
- this.insertBefore(contentRefElm, this.firstChild);
2262
+ insertBefore(this, contentRefElm, this.firstChild);
2242
2263
  }
2243
2264
  }
2244
2265
  }
@@ -2632,14 +2653,10 @@ var hostListenerProxy = (hostRef, methodName) => (ev) => {
2632
2653
  }
2633
2654
  };
2634
2655
  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;
2656
+ if (BUILD21.hostListenerTargetDocument && flags & 4 /* TargetDocument */) return doc;
2657
+ if (BUILD21.hostListenerTargetWindow && flags & 8 /* TargetWindow */) return win;
2658
+ if (BUILD21.hostListenerTargetBody && flags & 16 /* TargetBody */) return doc.body;
2659
+ if (BUILD21.hostListenerTargetParent && flags & 32 /* TargetParent */) return elm.parentElement;
2643
2660
  return elm;
2644
2661
  };
2645
2662
  var hostListenerOpts = (flags) => supportsListenerOptions ? {
@@ -2664,7 +2681,7 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
2664
2681
  const orgLocationNodes = [];
2665
2682
  parseVNodeAnnotations(doc2, doc2.body, docData, orgLocationNodes);
2666
2683
  orgLocationNodes.forEach((orgLocationNode) => {
2667
- var _a, _b;
2684
+ var _a;
2668
2685
  if (orgLocationNode != null && orgLocationNode["s-nr"]) {
2669
2686
  const nodeRef = orgLocationNode["s-nr"];
2670
2687
  let hostId = nodeRef["s-host-id"];
@@ -2687,7 +2704,7 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
2687
2704
  }
2688
2705
  const commentBeforeTextNode = doc2.createComment(childId);
2689
2706
  commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2690
- (_b = nodeRef.parentNode) == null ? void 0 : _b.insertBefore(commentBeforeTextNode, nodeRef);
2707
+ insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
2691
2708
  }
2692
2709
  }
2693
2710
  let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
@@ -2772,7 +2789,7 @@ var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, ind
2772
2789
  if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
2773
2790
  const textNodeId = `${TEXT_NODE_ID}.${childId}`;
2774
2791
  const commentBeforeTextNode = doc2.createComment(textNodeId);
2775
- parentNode == null ? void 0 : parentNode.insertBefore(commentBeforeTextNode, childElm);
2792
+ insertBefore(parentNode, commentBeforeTextNode, childElm);
2776
2793
  }
2777
2794
  } else if (childElm.nodeType === 8 /* CommentNode */) {
2778
2795
  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",
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 | 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 | 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
  }
@@ -1638,6 +1653,11 @@ var serverSideConnected = (elm) => {
1638
1653
  var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1639
1654
  var setValue = (ref, propName, newVal, cmpMeta) => {
1640
1655
  const hostRef = getHostRef(ref);
1656
+ if (BUILD12.lazyLoad && !hostRef) {
1657
+ throw new Error(
1658
+ `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).`
1659
+ );
1660
+ }
1641
1661
  const elm = BUILD12.lazyLoad ? hostRef.$hostElement$ : ref;
1642
1662
  const oldVal = hostRef.$instanceValues$.get(propName);
1643
1663
  const flags = hostRef.$flags$;
@@ -1960,7 +1980,7 @@ var setContentReference = (elm) => {
1960
1980
  BUILD15.isDebug ? `content-ref (host=${elm.localName})` : ""
1961
1981
  );
1962
1982
  contentRefElm["s-cn"] = true;
1963
- elm.insertBefore(contentRefElm, elm.firstChild);
1983
+ insertBefore(elm, contentRefElm, elm.firstChild);
1964
1984
  };
1965
1985
 
1966
1986
  // src/runtime/disconnected-callback.ts
@@ -2029,7 +2049,8 @@ var patchCloneNode = (HostElementPrototype) => {
2029
2049
  "s-ol",
2030
2050
  "s-nr",
2031
2051
  "s-si",
2032
- "s-rf"
2052
+ "s-rf",
2053
+ "s-rsc"
2033
2054
  ];
2034
2055
  for (; i2 < srcNode.childNodes.length; i2++) {
2035
2056
  slotted = srcNode.childNodes[i2]["s-nr"];
@@ -2057,7 +2078,7 @@ var patchSlotAppendChild = (HostElementPrototype) => {
2057
2078
  if (slotNode) {
2058
2079
  const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2059
2080
  const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2060
- const insertedNode = appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2081
+ const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
2061
2082
  updateFallbackSlotVisibility(this);
2062
2083
  return insertedNode;
2063
2084
  }
@@ -2098,7 +2119,7 @@ var patchSlotPrepend = (HostElementPrototype) => {
2098
2119
  newChild["s-ol"] = slotPlaceholder;
2099
2120
  const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2100
2121
  const appendAfter = slotChildNodes[0];
2101
- return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2122
+ return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
2102
2123
  }
2103
2124
  if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
2104
2125
  newChild.hidden = true;
@@ -2196,7 +2217,7 @@ var patchTextContent = (hostElementPrototype) => {
2196
2217
  if (node["s-sn"] === "") {
2197
2218
  const textNode = this.ownerDocument.createTextNode(value);
2198
2219
  textNode["s-sn"] = "";
2199
- node.parentElement.insertBefore(textNode, node.nextSibling);
2220
+ insertBefore(node.parentElement, textNode, node.nextSibling);
2200
2221
  } else {
2201
2222
  node.remove();
2202
2223
  }
@@ -2227,7 +2248,7 @@ var patchTextContent = (hostElementPrototype) => {
2227
2248
  this.__textContent = value;
2228
2249
  const contentRefElm = this["s-cr"];
2229
2250
  if (contentRefElm) {
2230
- this.insertBefore(contentRefElm, this.firstChild);
2251
+ insertBefore(this, contentRefElm, this.firstChild);
2231
2252
  }
2232
2253
  }
2233
2254
  }
@@ -2621,14 +2642,10 @@ var hostListenerProxy = (hostRef, methodName) => (ev) => {
2621
2642
  }
2622
2643
  };
2623
2644
  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;
2645
+ if (BUILD20.hostListenerTargetDocument && flags & 4 /* TargetDocument */) return doc;
2646
+ if (BUILD20.hostListenerTargetWindow && flags & 8 /* TargetWindow */) return win;
2647
+ if (BUILD20.hostListenerTargetBody && flags & 16 /* TargetBody */) return doc.body;
2648
+ if (BUILD20.hostListenerTargetParent && flags & 32 /* TargetParent */) return elm.parentElement;
2632
2649
  return elm;
2633
2650
  };
2634
2651
  var hostListenerOpts = (flags) => supportsListenerOptions ? {
@@ -2650,7 +2667,7 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
2650
2667
  const orgLocationNodes = [];
2651
2668
  parseVNodeAnnotations(doc2, doc2.body, docData, orgLocationNodes);
2652
2669
  orgLocationNodes.forEach((orgLocationNode) => {
2653
- var _a, _b;
2670
+ var _a;
2654
2671
  if (orgLocationNode != null && orgLocationNode["s-nr"]) {
2655
2672
  const nodeRef = orgLocationNode["s-nr"];
2656
2673
  let hostId = nodeRef["s-host-id"];
@@ -2673,7 +2690,7 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
2673
2690
  }
2674
2691
  const commentBeforeTextNode = doc2.createComment(childId);
2675
2692
  commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2676
- (_b = nodeRef.parentNode) == null ? void 0 : _b.insertBefore(commentBeforeTextNode, nodeRef);
2693
+ insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
2677
2694
  }
2678
2695
  }
2679
2696
  let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
@@ -2758,7 +2775,7 @@ var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, ind
2758
2775
  if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
2759
2776
  const textNodeId = `${TEXT_NODE_ID}.${childId}`;
2760
2777
  const commentBeforeTextNode = doc2.createComment(textNodeId);
2761
- parentNode == null ? void 0 : parentNode.insertBefore(commentBeforeTextNode, childElm);
2778
+ insertBefore(parentNode, commentBeforeTextNode, childElm);
2762
2779
  }
2763
2780
  } else if (childElm.nodeType === 8 /* CommentNode */) {
2764
2781
  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",
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