@stencil/core 4.35.1 → 4.35.2

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 (38) hide show
  1. package/cli/index.cjs +1 -1
  2. package/cli/index.js +1 -1
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/stencil.js +7 -7
  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 +2 -2
  12. package/internal/app-data/package.json +1 -1
  13. package/internal/app-globals/package.json +1 -1
  14. package/internal/client/index.js +216 -180
  15. package/internal/client/package.json +1 -1
  16. package/internal/client/patch-browser.js +1 -1
  17. package/internal/hydrate/index.js +216 -180
  18. package/internal/hydrate/package.json +1 -1
  19. package/internal/hydrate/runner.js +43 -13
  20. package/internal/package.json +1 -1
  21. package/internal/stencil-public-compiler.d.ts +1 -0
  22. package/internal/stencil-public-runtime.d.ts +5 -5
  23. package/internal/testing/index.js +213 -179
  24. package/internal/testing/package.json +1 -1
  25. package/mock-doc/index.cjs +35 -5
  26. package/mock-doc/index.d.ts +16 -0
  27. package/mock-doc/index.js +35 -5
  28. package/mock-doc/package.json +1 -1
  29. package/package.json +1 -1
  30. package/screenshot/index.js +1 -1
  31. package/screenshot/package.json +1 -1
  32. package/screenshot/pixel-match.js +1 -1
  33. package/sys/node/index.js +26 -26
  34. package/sys/node/package.json +1 -1
  35. package/sys/node/worker.js +1 -1
  36. package/testing/index.js +5 -5
  37. package/testing/package.json +1 -1
  38. package/testing/puppeteer/puppeteer-browser.d.ts +5 -5
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Hydrate Platform v4.35.1 | MIT Licensed | https://stenciljs.com
2
+ Stencil Hydrate Platform v4.35.2 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -248,16 +248,25 @@ function deserializeProperty(value) {
248
248
  // src/utils/shadow-root.ts
249
249
  import { BUILD as BUILD2 } from "@stencil/core/internal/app-data";
250
250
  import { globalStyles } from "@stencil/core/internal/app-globals";
251
+
252
+ // src/utils/style.ts
253
+ function createStyleSheetIfNeededAndSupported(styles2) {
254
+ if (!styles2 || !supportsConstructableStylesheets) return void 0;
255
+ const sheet = new CSSStyleSheet();
256
+ sheet.replaceSync(styles2);
257
+ return sheet;
258
+ }
259
+
260
+ // src/utils/shadow-root.ts
261
+ var globalStyleSheet;
251
262
  function createShadowRoot(cmpMeta) {
263
+ var _a;
252
264
  const shadowRoot = BUILD2.shadowDelegatesFocus ? this.attachShadow({
253
265
  mode: "open",
254
266
  delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
255
267
  }) : this.attachShadow({ mode: "open" });
256
- if (supportsConstructableStylesheets) {
257
- const sheet = new CSSStyleSheet();
258
- sheet.replaceSync(globalStyles);
259
- shadowRoot.adoptedStyleSheets.push(sheet);
260
- }
268
+ if (globalStyleSheet === void 0) globalStyleSheet = (_a = createStyleSheetIfNeededAndSupported(globalStyles)) != null ? _a : null;
269
+ if (globalStyleSheet) shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
261
270
  }
262
271
 
263
272
  // src/utils/util.ts
@@ -278,7 +287,7 @@ var isJsFile = lowerPathParam((p) => p.endsWith(".js") || p.endsWith(".mjs") ||
278
287
  import { BUILD as BUILD19 } from "@stencil/core/internal/app-data";
279
288
 
280
289
  // src/runtime/client-hydrate.ts
281
- import { BUILD as BUILD7 } from "@stencil/core/internal/app-data";
290
+ import { BUILD as BUILD8 } from "@stencil/core/internal/app-data";
282
291
 
283
292
  // src/runtime/dom-extras.ts
284
293
  import { BUILD as BUILD4 } from "@stencil/core/internal/app-data";
@@ -912,8 +921,125 @@ var installDevTools = () => {
912
921
  }
913
922
  };
914
923
 
915
- // src/runtime/vdom/h.ts
924
+ // src/runtime/styles.ts
916
925
  import { BUILD as BUILD6 } from "@stencil/core/internal/app-data";
926
+ var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
927
+ var registerStyle = (scopeId2, cssText, allowCS) => {
928
+ let style = styles.get(scopeId2);
929
+ if (supportsConstructableStylesheets && allowCS) {
930
+ style = style || new CSSStyleSheet();
931
+ if (typeof style === "string") {
932
+ style = cssText;
933
+ } else {
934
+ style.replaceSync(cssText);
935
+ }
936
+ } else {
937
+ style = cssText;
938
+ }
939
+ styles.set(scopeId2, style);
940
+ };
941
+ var addStyle = (styleContainerNode, cmpMeta, mode) => {
942
+ var _a;
943
+ const scopeId2 = getScopeId(cmpMeta, mode);
944
+ const style = styles.get(scopeId2);
945
+ if (!BUILD6.attachStyles || !win.document) {
946
+ return scopeId2;
947
+ }
948
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : win.document;
949
+ if (style) {
950
+ if (typeof style === "string") {
951
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
952
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
953
+ let styleElm;
954
+ if (!appliedStyles) {
955
+ rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
956
+ }
957
+ if (!appliedStyles.has(scopeId2)) {
958
+ if (BUILD6.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
959
+ styleElm.innerHTML = style;
960
+ } else {
961
+ styleElm = win.document.createElement("style");
962
+ styleElm.innerHTML = style;
963
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
964
+ if (nonce != null) {
965
+ styleElm.setAttribute("nonce", nonce);
966
+ }
967
+ if ((BUILD6.hydrateServerSide || BUILD6.hotModuleReplacement) && (cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */ || cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */)) {
968
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
969
+ }
970
+ if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
971
+ if (styleContainerNode.nodeName === "HEAD") {
972
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
973
+ const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
974
+ styleContainerNode.insertBefore(
975
+ styleElm,
976
+ (referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
977
+ );
978
+ } else if ("host" in styleContainerNode) {
979
+ if (supportsConstructableStylesheets) {
980
+ const stylesheet = new CSSStyleSheet();
981
+ stylesheet.replaceSync(style);
982
+ styleContainerNode.adoptedStyleSheets.unshift(stylesheet);
983
+ } else {
984
+ const existingStyleContainer = styleContainerNode.querySelector("style");
985
+ if (existingStyleContainer) {
986
+ existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
987
+ } else {
988
+ styleContainerNode.prepend(styleElm);
989
+ }
990
+ }
991
+ } else {
992
+ styleContainerNode.append(styleElm);
993
+ }
994
+ }
995
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
996
+ styleContainerNode.insertBefore(styleElm, null);
997
+ }
998
+ }
999
+ if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
1000
+ styleElm.innerHTML += SLOT_FB_CSS;
1001
+ }
1002
+ if (appliedStyles) {
1003
+ appliedStyles.add(scopeId2);
1004
+ }
1005
+ }
1006
+ } else if (BUILD6.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
1007
+ styleContainerNode.adoptedStyleSheets.push(style);
1008
+ }
1009
+ }
1010
+ return scopeId2;
1011
+ };
1012
+ var attachStyles = (hostRef) => {
1013
+ const cmpMeta = hostRef.$cmpMeta$;
1014
+ const elm = hostRef.$hostElement$;
1015
+ const flags = cmpMeta.$flags$;
1016
+ const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
1017
+ const scopeId2 = addStyle(
1018
+ BUILD6.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
1019
+ cmpMeta,
1020
+ hostRef.$modeName$
1021
+ );
1022
+ if ((BUILD6.shadowDom || BUILD6.scoped) && BUILD6.cssAnnotations && flags & 10 /* needsScopedEncapsulation */) {
1023
+ elm["s-sc"] = scopeId2;
1024
+ elm.classList.add(scopeId2 + "-h");
1025
+ }
1026
+ endAttachStyles();
1027
+ };
1028
+ var getScopeId = (cmp, mode) => "sc-" + (BUILD6.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
1029
+ var convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, "$1{");
1030
+ var hydrateScopedToShadow = () => {
1031
+ if (!win.document) {
1032
+ return;
1033
+ }
1034
+ const styles2 = win.document.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1035
+ let i2 = 0;
1036
+ for (; i2 < styles2.length; i2++) {
1037
+ registerStyle(styles2[i2].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles2[i2].innerHTML), true);
1038
+ }
1039
+ };
1040
+
1041
+ // src/runtime/vdom/h.ts
1042
+ import { BUILD as BUILD7 } from "@stencil/core/internal/app-data";
917
1043
  var h = (nodeName, vnodeData, ...children) => {
918
1044
  let child = null;
919
1045
  let key = null;
@@ -929,7 +1055,7 @@ var h = (nodeName, vnodeData, ...children) => {
929
1055
  } else if (child != null && typeof child !== "boolean") {
930
1056
  if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
931
1057
  child = String(child);
932
- } else if (BUILD6.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
1058
+ } else if (BUILD7.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
933
1059
  consoleDevError(`vNode passed as children has unexpected type.
934
1060
  Make sure it's using the correct h() function.
935
1061
  Empty objects can also be the cause, look for JSX comments that became objects.`);
@@ -945,28 +1071,28 @@ Empty objects can also be the cause, look for JSX comments that became objects.`
945
1071
  };
946
1072
  walk(children);
947
1073
  if (vnodeData) {
948
- if (BUILD6.isDev && nodeName === "input") {
1074
+ if (BUILD7.isDev && nodeName === "input") {
949
1075
  validateInputProperties(vnodeData);
950
1076
  }
951
- if (BUILD6.vdomKey && vnodeData.key) {
1077
+ if (BUILD7.vdomKey && vnodeData.key) {
952
1078
  key = vnodeData.key;
953
1079
  }
954
- if (BUILD6.slotRelocation && vnodeData.name) {
1080
+ if (BUILD7.slotRelocation && vnodeData.name) {
955
1081
  slotName = vnodeData.name;
956
1082
  }
957
- if (BUILD6.vdomClass) {
1083
+ if (BUILD7.vdomClass) {
958
1084
  const classData = vnodeData.className || vnodeData.class;
959
1085
  if (classData) {
960
1086
  vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
961
1087
  }
962
1088
  }
963
1089
  }
964
- if (BUILD6.isDev && vNodeChildren.some(isHost)) {
1090
+ if (BUILD7.isDev && vNodeChildren.some(isHost)) {
965
1091
  consoleDevError(`The <Host> must be the single root component. Make sure:
966
1092
  - You are NOT using hostData() and <Host> in the same component.
967
1093
  - <Host> is used once, and it's the single root component of the render() function.`);
968
1094
  }
969
- if (BUILD6.vdomFunctional && typeof nodeName === "function") {
1095
+ if (BUILD7.vdomFunctional && typeof nodeName === "function") {
970
1096
  return nodeName(
971
1097
  vnodeData === null ? {} : vnodeData,
972
1098
  vNodeChildren,
@@ -978,10 +1104,10 @@ Empty objects can also be the cause, look for JSX comments that became objects.`
978
1104
  if (vNodeChildren.length > 0) {
979
1105
  vnode.$children$ = vNodeChildren;
980
1106
  }
981
- if (BUILD6.vdomKey) {
1107
+ if (BUILD7.vdomKey) {
982
1108
  vnode.$key$ = key;
983
1109
  }
984
- if (BUILD6.slotRelocation) {
1110
+ if (BUILD7.slotRelocation) {
985
1111
  vnode.$name$ = slotName;
986
1112
  }
987
1113
  return vnode;
@@ -994,13 +1120,13 @@ var newVNode = (tag, text) => {
994
1120
  $elm$: null,
995
1121
  $children$: null
996
1122
  };
997
- if (BUILD6.vdomAttribute) {
1123
+ if (BUILD7.vdomAttribute) {
998
1124
  vnode.$attrs$ = null;
999
1125
  }
1000
- if (BUILD6.vdomKey) {
1126
+ if (BUILD7.vdomKey) {
1001
1127
  vnode.$key$ = null;
1002
1128
  }
1003
- if (BUILD6.slotRelocation) {
1129
+ if (BUILD7.slotRelocation) {
1004
1130
  vnode.$name$ = null;
1005
1131
  }
1006
1132
  return vnode;
@@ -1054,18 +1180,18 @@ var validateInputProperties = (inputElm) => {
1054
1180
 
1055
1181
  // src/runtime/client-hydrate.ts
1056
1182
  var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1057
- var _a;
1183
+ var _a, _b;
1058
1184
  const endHydrate = createTime("hydrateClient", tagName);
1059
1185
  const shadowRoot = hostElm.shadowRoot;
1060
1186
  const childRenderNodes = [];
1061
1187
  const slotNodes = [];
1062
1188
  const slottedNodes = [];
1063
- const shadowRootNodes = BUILD7.shadowDom && shadowRoot ? [] : null;
1189
+ const shadowRootNodes = BUILD8.shadowDom && shadowRoot ? [] : null;
1064
1190
  const vnode = newVNode(tagName, null);
1065
1191
  vnode.$elm$ = hostElm;
1066
1192
  const members = Object.entries(((_a = hostRef.$cmpMeta$) == null ? void 0 : _a.$members$) || {});
1067
1193
  members.forEach(([memberName, [memberFlags, metaAttributeName]]) => {
1068
- var _a2, _b;
1194
+ var _a2, _b2;
1069
1195
  if (!(memberFlags & 31 /* Prop */)) {
1070
1196
  return;
1071
1197
  }
@@ -1075,13 +1201,13 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1075
1201
  const attrPropVal = parsePropertyValue(
1076
1202
  attrVal,
1077
1203
  memberFlags,
1078
- BUILD7.formAssociated && !!(((_a2 = hostRef.$cmpMeta$) == null ? void 0 : _a2.$flags$) & 64 /* formAssociated */)
1204
+ BUILD8.formAssociated && !!(((_a2 = hostRef.$cmpMeta$) == null ? void 0 : _a2.$flags$) & 64 /* formAssociated */)
1079
1205
  );
1080
- (_b = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _b.set(memberName, attrPropVal);
1206
+ (_b2 = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _b2.set(memberName, attrPropVal);
1081
1207
  }
1082
1208
  });
1083
1209
  let scopeId2;
1084
- if (BUILD7.scoped) {
1210
+ if (BUILD8.scoped) {
1085
1211
  const cmpMeta = hostRef.$cmpMeta$;
1086
1212
  if (cmpMeta && cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */ && hostElm["s-sc"]) {
1087
1213
  scopeId2 = hostElm["s-sc"];
@@ -1118,6 +1244,16 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1118
1244
  if (childRenderNode.$tag$ === "slot") {
1119
1245
  node["s-cr"] = hostElm["s-cr"];
1120
1246
  }
1247
+ } else if (((_b = childRenderNode.$tag$) == null ? void 0 : _b.toString().includes("-")) && !childRenderNode.$elm$.shadowRoot) {
1248
+ const cmpMeta = getHostRef(childRenderNode.$elm$);
1249
+ const scopeId3 = getScopeId(
1250
+ cmpMeta.$cmpMeta$,
1251
+ BUILD8.mode ? childRenderNode.$elm$.getAttribute("s-mode") : void 0
1252
+ );
1253
+ const styleSheet = win.document.querySelector(`style[sty-id="${scopeId3}"]`);
1254
+ if (styleSheet) {
1255
+ hostElm.shadowRoot.append(styleSheet.cloneNode(true));
1256
+ }
1121
1257
  }
1122
1258
  if (childRenderNode.$tag$ === "slot") {
1123
1259
  childRenderNode.$name$ = childRenderNode.$elm$["s-sn"] || childRenderNode.$elm$["name"] || null;
@@ -1133,7 +1269,7 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1133
1269
  }
1134
1270
  }
1135
1271
  if (orgLocationNode && orgLocationNode.isConnected) {
1136
- if (shadowRoot && orgLocationNode["s-en"] === "") {
1272
+ if (orgLocationNode.parentElement.shadowRoot && orgLocationNode["s-en"] === "") {
1137
1273
  orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1138
1274
  }
1139
1275
  orgLocationNode.parentNode.removeChild(orgLocationNode);
@@ -1141,7 +1277,9 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1141
1277
  node["s-oo"] = parseInt(childRenderNode.$nodeId$);
1142
1278
  }
1143
1279
  }
1144
- plt.$orgLocNodes$.delete(orgLocationId);
1280
+ if (orgLocationNode && !orgLocationNode["s-id"]) {
1281
+ plt.$orgLocNodes$.delete(orgLocationId);
1282
+ }
1145
1283
  }
1146
1284
  const hosts = [];
1147
1285
  const snLen = slottedNodes.length;
@@ -1163,14 +1301,16 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1163
1301
  if (!hosts[slottedItem.hostId]) continue;
1164
1302
  const hostEle = hosts[slottedItem.hostId];
1165
1303
  if (!hostEle.shadowRoot || !shadowRoot) {
1166
- slottedItem.slot["s-cr"] = hostEle["s-cr"];
1167
- if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
1168
- slottedItem.slot["s-cr"] = hostEle;
1169
- } else {
1170
- slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
1304
+ if (!slottedItem.slot["s-cr"]) {
1305
+ slottedItem.slot["s-cr"] = hostEle["s-cr"];
1306
+ if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
1307
+ slottedItem.slot["s-cr"] = hostEle;
1308
+ } else {
1309
+ slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
1310
+ }
1171
1311
  }
1172
1312
  addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
1173
- if (BUILD7.experimentalSlotFixes) {
1313
+ if (BUILD8.experimentalSlotFixes) {
1174
1314
  patchSlottedNode(slottedItem.node);
1175
1315
  }
1176
1316
  }
@@ -1179,12 +1319,12 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1179
1319
  }
1180
1320
  }
1181
1321
  }
1182
- if (BUILD7.scoped && scopeId2 && slotNodes.length) {
1322
+ if (BUILD8.scoped && scopeId2 && slotNodes.length) {
1183
1323
  slotNodes.forEach((slot) => {
1184
1324
  slot.$elm$.parentElement.classList.add(scopeId2 + "-s");
1185
1325
  });
1186
1326
  }
1187
- if (BUILD7.shadowDom && shadowRoot && !shadowRoot.childNodes.length) {
1327
+ if (BUILD8.shadowDom && shadowRoot) {
1188
1328
  let rnIdex = 0;
1189
1329
  const rnLen = shadowRootNodes.length;
1190
1330
  if (rnLen) {
@@ -1195,14 +1335,13 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1195
1335
  if (typeof node["s-en"] !== "string" && typeof node["s-sn"] !== "string") {
1196
1336
  if (node.nodeType === 1 /* ElementNode */ && node.slot && node.hidden) {
1197
1337
  node.removeAttribute("hidden");
1198
- } else if (node.nodeType === 8 /* CommentNode */ || node.nodeType === 3 /* TextNode */ && !node.wholeText.trim()) {
1338
+ } else if (node.nodeType === 8 /* CommentNode */ && !node.nodeValue || node.nodeType === 3 /* TextNode */ && !node.wholeText.trim()) {
1199
1339
  node.parentNode.removeChild(node);
1200
1340
  }
1201
1341
  }
1202
1342
  });
1203
1343
  }
1204
1344
  }
1205
- plt.$orgLocNodes$.delete(hostElm["s-id"]);
1206
1345
  hostRef.$hostElement$ = hostElm;
1207
1346
  endHydrate();
1208
1347
  };
@@ -1234,7 +1373,7 @@ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes,
1234
1373
  if (!parentVNode.$children$) {
1235
1374
  parentVNode.$children$ = [];
1236
1375
  }
1237
- if (BUILD7.scoped && scopeId2) {
1376
+ if (BUILD8.scoped && scopeId2 && childIdSplt[0] === hostId) {
1238
1377
  node["s-si"] = scopeId2;
1239
1378
  childVNode.$attrs$.class += " " + scopeId2;
1240
1379
  }
@@ -1252,7 +1391,7 @@ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes,
1252
1391
  shadowRootNodes,
1253
1392
  slottedNodes
1254
1393
  );
1255
- if (BUILD7.scoped && scopeId2) {
1394
+ if (BUILD8.scoped && scopeId2) {
1256
1395
  node.classList.add(scopeId2);
1257
1396
  }
1258
1397
  }
@@ -1349,9 +1488,9 @@ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes,
1349
1488
  slottedNodes
1350
1489
  );
1351
1490
  } else if (childNodeType === CONTENT_REF_ID) {
1352
- if (BUILD7.shadowDom && shadowRootNodes) {
1491
+ if (BUILD8.shadowDom && shadowRootNodes) {
1353
1492
  node.remove();
1354
- } else if (BUILD7.slotRelocation) {
1493
+ } else if (BUILD8.slotRelocation) {
1355
1494
  hostElm["s-cr"] = node;
1356
1495
  node["s-cn"] = true;
1357
1496
  }
@@ -1364,7 +1503,7 @@ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes,
1364
1503
  vnode.$index$ = "0";
1365
1504
  parentVNode.$children$ = [vnode];
1366
1505
  } else {
1367
- if (node.nodeType === 3 /* TextNode */ && !node.wholeText.trim()) {
1506
+ if (node.nodeType === 3 /* TextNode */ && !node.wholeText.trim() && !node["s-nr"]) {
1368
1507
  node.remove();
1369
1508
  }
1370
1509
  }
@@ -1417,15 +1556,15 @@ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNod
1417
1556
  childVNode.$name$ = slotName || null;
1418
1557
  childVNode.$tag$ = "slot";
1419
1558
  const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
1420
- if (BUILD7.shadowDom && shadowRootNodes && win.document) {
1559
+ if (BUILD8.shadowDom && shadowRootNodes && win.document) {
1421
1560
  const slot = childVNode.$elm$ = win.document.createElement(childVNode.$tag$);
1422
1561
  if (childVNode.$name$) {
1423
1562
  childVNode.$elm$.setAttribute("name", slotName);
1424
1563
  }
1425
- if (parentNodeId && parentNodeId !== childVNode.$hostId$) {
1426
- parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1564
+ if (parentVNode.$elm$.shadowRoot && parentNodeId && parentNodeId !== childVNode.$hostId$) {
1565
+ internalCall(parentVNode.$elm$, "insertBefore")(slot, internalCall(parentVNode.$elm$, "children")[0]);
1427
1566
  } else {
1428
- node.parentNode.insertBefore(slot, node);
1567
+ internalCall(internalCall(node, "parentNode"), "insertBefore")(slot, node);
1429
1568
  }
1430
1569
  addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
1431
1570
  node.remove();
@@ -1451,7 +1590,7 @@ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNod
1451
1590
  var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
1452
1591
  let slottedNode = slotNode.nextSibling;
1453
1592
  slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
1454
- while (slottedNode && ((slottedNode["getAttribute"] && slottedNode.getAttribute("slot") || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && (slottedNode.nodeType === 8 /* CommentNode */ && slottedNode.nodeValue.indexOf(".") !== 1 || slottedNode.nodeType === 3 /* TextNode */))) {
1593
+ while (slottedNode && ((slottedNode["getAttribute"] && slottedNode.getAttribute("slot") || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && (slottedNode.nodeType === 8 /* CommentNode */ || slottedNode.nodeType === 3 /* TextNode */ || slottedNode.tagName === "SLOT"))) {
1455
1594
  slottedNode["s-sn"] = slotName;
1456
1595
  slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
1457
1596
  slottedNode = slottedNode.nextSibling;
@@ -1886,31 +2025,31 @@ import { BUILD as BUILD17 } from "@stencil/core/internal/app-data";
1886
2025
  import { BUILD as BUILD16 } from "@stencil/core/internal/app-data";
1887
2026
 
1888
2027
  // src/runtime/parse-property-value.ts
1889
- import { BUILD as BUILD8 } from "@stencil/core/internal/app-data";
2028
+ import { BUILD as BUILD9 } from "@stencil/core/internal/app-data";
1890
2029
  var parsePropertyValue = (propValue, propType, isFormAssociated) => {
1891
- if ((BUILD8.hydrateClientSide || BUILD8.hydrateServerSide) && typeof propValue === "string" && (propValue.startsWith("{") && propValue.endsWith("}") || propValue.startsWith("[") && propValue.endsWith("]"))) {
2030
+ if ((BUILD9.hydrateClientSide || BUILD9.hydrateServerSide) && typeof propValue === "string" && (propValue.startsWith("{") && propValue.endsWith("}") || propValue.startsWith("[") && propValue.endsWith("]"))) {
1892
2031
  try {
1893
2032
  propValue = JSON.parse(propValue);
1894
2033
  return propValue;
1895
2034
  } catch (e) {
1896
2035
  }
1897
2036
  }
1898
- if ((BUILD8.hydrateClientSide || BUILD8.hydrateServerSide) && typeof propValue === "string" && propValue.startsWith(SERIALIZED_PREFIX)) {
2037
+ if ((BUILD9.hydrateClientSide || BUILD9.hydrateServerSide) && typeof propValue === "string" && propValue.startsWith(SERIALIZED_PREFIX)) {
1899
2038
  propValue = deserializeProperty(propValue);
1900
2039
  return propValue;
1901
2040
  }
1902
2041
  if (propValue != null && !isComplexType(propValue)) {
1903
- if (BUILD8.propBoolean && propType & 4 /* Boolean */) {
1904
- if (BUILD8.formAssociated && isFormAssociated && typeof propValue === "string") {
2042
+ if (BUILD9.propBoolean && propType & 4 /* Boolean */) {
2043
+ if (BUILD9.formAssociated && isFormAssociated && typeof propValue === "string") {
1905
2044
  return propValue === "" || !!propValue;
1906
2045
  } else {
1907
2046
  return propValue === "false" ? false : propValue === "" || !!propValue;
1908
2047
  }
1909
2048
  }
1910
- if (BUILD8.propNumber && propType & 2 /* Number */) {
2049
+ if (BUILD9.propNumber && propType & 2 /* Number */) {
1911
2050
  return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
1912
2051
  }
1913
- if (BUILD8.propString && propType & 1 /* String */) {
2052
+ if (BUILD9.propString && propType & 1 /* String */) {
1914
2053
  return String(propValue);
1915
2054
  }
1916
2055
  return propValue;
@@ -1922,18 +2061,18 @@ var parsePropertyValue = (propValue, propType, isFormAssociated) => {
1922
2061
  import { BUILD as BUILD15, NAMESPACE } from "@stencil/core/internal/app-data";
1923
2062
 
1924
2063
  // src/runtime/event-emitter.ts
1925
- import { BUILD as BUILD10 } from "@stencil/core/internal/app-data";
2064
+ import { BUILD as BUILD11 } from "@stencil/core/internal/app-data";
1926
2065
 
1927
2066
  // src/runtime/element.ts
1928
- import { BUILD as BUILD9 } from "@stencil/core/internal/app-data";
1929
- var getElement = (ref) => BUILD9.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
2067
+ import { BUILD as BUILD10 } from "@stencil/core/internal/app-data";
2068
+ var getElement = (ref) => BUILD10.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
1930
2069
 
1931
2070
  // src/runtime/event-emitter.ts
1932
2071
  var createEvent = (ref, name, flags) => {
1933
2072
  const elm = getElement(ref);
1934
2073
  return {
1935
2074
  emit: (detail) => {
1936
- if (BUILD10.isDev && !elm.isConnected) {
2075
+ if (BUILD11.isDev && !elm.isConnected) {
1937
2076
  consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1938
2077
  }
1939
2078
  return emitEvent(elm, name, {
@@ -1951,123 +2090,6 @@ var emitEvent = (elm, name, opts) => {
1951
2090
  return ev;
1952
2091
  };
1953
2092
 
1954
- // src/runtime/styles.ts
1955
- import { BUILD as BUILD11 } from "@stencil/core/internal/app-data";
1956
- var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
1957
- var registerStyle = (scopeId2, cssText, allowCS) => {
1958
- let style = styles.get(scopeId2);
1959
- if (supportsConstructableStylesheets && allowCS) {
1960
- style = style || new CSSStyleSheet();
1961
- if (typeof style === "string") {
1962
- style = cssText;
1963
- } else {
1964
- style.replaceSync(cssText);
1965
- }
1966
- } else {
1967
- style = cssText;
1968
- }
1969
- styles.set(scopeId2, style);
1970
- };
1971
- var addStyle = (styleContainerNode, cmpMeta, mode) => {
1972
- var _a;
1973
- const scopeId2 = getScopeId(cmpMeta, mode);
1974
- const style = styles.get(scopeId2);
1975
- if (!BUILD11.attachStyles || !win.document) {
1976
- return scopeId2;
1977
- }
1978
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : win.document;
1979
- if (style) {
1980
- if (typeof style === "string") {
1981
- styleContainerNode = styleContainerNode.head || styleContainerNode;
1982
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
1983
- let styleElm;
1984
- if (!appliedStyles) {
1985
- rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
1986
- }
1987
- if (!appliedStyles.has(scopeId2)) {
1988
- if (BUILD11.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
1989
- styleElm.innerHTML = style;
1990
- } else {
1991
- styleElm = win.document.createElement("style");
1992
- styleElm.innerHTML = style;
1993
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
1994
- if (nonce != null) {
1995
- styleElm.setAttribute("nonce", nonce);
1996
- }
1997
- if ((BUILD11.hydrateServerSide || BUILD11.hotModuleReplacement) && (cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */ || cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */)) {
1998
- styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
1999
- }
2000
- if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
2001
- if (styleContainerNode.nodeName === "HEAD") {
2002
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
2003
- const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
2004
- styleContainerNode.insertBefore(
2005
- styleElm,
2006
- (referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
2007
- );
2008
- } else if ("host" in styleContainerNode) {
2009
- if (supportsConstructableStylesheets) {
2010
- const stylesheet = new CSSStyleSheet();
2011
- stylesheet.replaceSync(style);
2012
- styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
2013
- } else {
2014
- const existingStyleContainer = styleContainerNode.querySelector("style");
2015
- if (existingStyleContainer) {
2016
- existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
2017
- } else {
2018
- styleContainerNode.prepend(styleElm);
2019
- }
2020
- }
2021
- } else {
2022
- styleContainerNode.append(styleElm);
2023
- }
2024
- }
2025
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2026
- styleContainerNode.insertBefore(styleElm, null);
2027
- }
2028
- }
2029
- if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
2030
- styleElm.innerHTML += SLOT_FB_CSS;
2031
- }
2032
- if (appliedStyles) {
2033
- appliedStyles.add(scopeId2);
2034
- }
2035
- }
2036
- } else if (BUILD11.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
2037
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
2038
- }
2039
- }
2040
- return scopeId2;
2041
- };
2042
- var attachStyles = (hostRef) => {
2043
- const cmpMeta = hostRef.$cmpMeta$;
2044
- const elm = hostRef.$hostElement$;
2045
- const flags = cmpMeta.$flags$;
2046
- const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
2047
- const scopeId2 = addStyle(
2048
- BUILD11.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
2049
- cmpMeta,
2050
- hostRef.$modeName$
2051
- );
2052
- if ((BUILD11.shadowDom || BUILD11.scoped) && BUILD11.cssAnnotations && flags & 10 /* needsScopedEncapsulation */) {
2053
- elm["s-sc"] = scopeId2;
2054
- elm.classList.add(scopeId2 + "-h");
2055
- }
2056
- endAttachStyles();
2057
- };
2058
- var getScopeId = (cmp, mode) => "sc-" + (BUILD11.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
2059
- var convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, "$1{");
2060
- var hydrateScopedToShadow = () => {
2061
- if (!win.document) {
2062
- return;
2063
- }
2064
- const styles2 = win.document.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2065
- let i2 = 0;
2066
- for (; i2 < styles2.length; i2++) {
2067
- registerStyle(styles2[i2].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles2[i2].innerHTML), true);
2068
- }
2069
- };
2070
-
2071
2093
  // src/runtime/vdom/vdom-render.ts
2072
2094
  import { BUILD as BUILD14 } from "@stencil/core/internal/app-data";
2073
2095
 
@@ -2086,12 +2108,13 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
2086
2108
  const classList = elm.classList;
2087
2109
  const oldClasses = parseClassList(oldValue);
2088
2110
  let newClasses = parseClassList(newValue);
2089
- if (BUILD12.hydrateClientSide && elm["s-si"] && initialRender) {
2090
- newClasses.push(elm["s-si"]);
2111
+ if (BUILD12.hydrateClientSide && (elm["s-si"] || elm["s-sc"]) && initialRender) {
2112
+ const scopeId2 = elm["s-sc"] || elm["s-si"];
2113
+ newClasses.push(scopeId2);
2091
2114
  oldClasses.forEach((c) => {
2092
- if (c.startsWith(elm["s-si"])) newClasses.push(c);
2115
+ if (c.startsWith(scopeId2)) newClasses.push(c);
2093
2116
  });
2094
- newClasses = [...new Set(newClasses)];
2117
+ newClasses = [...new Set(newClasses)].filter((c) => c);
2095
2118
  classList.add(...newClasses);
2096
2119
  } else {
2097
2120
  classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
@@ -2573,6 +2596,8 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
2573
2596
  !isInitialRender && BUILD14.updatable && oldChildren !== null
2574
2597
  ) {
2575
2598
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
2599
+ } else if (BUILD14.hydrateClientSide && isInitialRender && BUILD14.updatable && oldChildren !== null && newChildren === null) {
2600
+ newVNode2.$children$ = oldChildren;
2576
2601
  }
2577
2602
  if (BUILD14.svg && isSvgMode && tag === "svg") {
2578
2603
  isSvgMode = false;
@@ -3040,10 +3065,16 @@ var forceUpdate = (ref) => {
3040
3065
  return false;
3041
3066
  };
3042
3067
  var appDidLoad = (who) => {
3068
+ var _a;
3043
3069
  if (BUILD15.asyncQueue) {
3044
3070
  plt.$flags$ |= 2 /* appLoaded */;
3045
3071
  }
3046
3072
  nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
3073
+ if (BUILD15.hydrateClientSide) {
3074
+ if ((_a = plt.$orgLocNodes$) == null ? void 0 : _a.size) {
3075
+ plt.$orgLocNodes$.clear();
3076
+ }
3077
+ }
3047
3078
  if (BUILD15.profile && performance.measure) {
3048
3079
  performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, "st:app:start");
3049
3080
  }
@@ -3475,6 +3506,11 @@ var connectedCallback = (elm) => {
3475
3506
  if (BUILD19.hydrateServerSide || (BUILD19.slot || BUILD19.shadowDom) && // TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
3476
3507
  cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */)) {
3477
3508
  setContentReference(elm);
3509
+ } else if (BUILD19.hydrateClientSide && !(cmpMeta.$flags$ & 4 /* hasSlotRelocation */)) {
3510
+ const commendPlaceholder = elm.firstChild;
3511
+ if ((commendPlaceholder == null ? void 0 : commendPlaceholder.nodeType) === 8 /* CommentNode */ && !commendPlaceholder["s-cn"] && !commendPlaceholder.nodeValue) {
3512
+ elm.removeChild(commendPlaceholder);
3513
+ }
3478
3514
  }
3479
3515
  }
3480
3516
  if (BUILD19.asyncLoading) {