@stencil/core 4.18.3 → 4.19.0

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 (47) hide show
  1. package/cli/index.cjs +43 -16
  2. package/cli/index.js +43 -16
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/stencil.js +175 -72
  6. package/dev-server/client/index.js +1 -1
  7. package/dev-server/client/package.json +1 -1
  8. package/dev-server/connector.html +3 -3
  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/dev-server/ws.js +1 -1
  13. package/internal/app-data/package.json +1 -1
  14. package/internal/client/index.js +534 -507
  15. package/internal/client/package.json +3 -1
  16. package/internal/client/patch-browser.js +1 -1
  17. package/internal/hydrate/index.js +108 -50
  18. package/internal/hydrate/package.json +1 -1
  19. package/internal/hydrate/runner.d.ts +29 -11
  20. package/internal/hydrate/runner.js +239 -260
  21. package/internal/package.json +1 -1
  22. package/internal/stencil-private.d.ts +39 -14
  23. package/internal/stencil-public-compiler.d.ts +21 -0
  24. package/internal/stencil-public-runtime.d.ts +0 -2
  25. package/internal/testing/index.js +439 -407
  26. package/internal/testing/package.json +1 -1
  27. package/mock-doc/index.cjs +137 -131
  28. package/mock-doc/index.d.ts +18 -4
  29. package/mock-doc/index.js +137 -131
  30. package/mock-doc/package.json +1 -1
  31. package/package.json +34 -6
  32. package/screenshot/index.js +1 -1
  33. package/screenshot/package.json +1 -1
  34. package/screenshot/pixel-match.js +1 -1
  35. package/sys/node/index.js +10 -10
  36. package/sys/node/package.json +1 -1
  37. package/sys/node/worker.js +1 -1
  38. package/testing/index.js +95 -16
  39. package/testing/jest/jest-27-and-under/matchers/events.d.ts +4 -0
  40. package/testing/jest/jest-27-and-under/matchers/index.d.ts +2 -1
  41. package/testing/jest/jest-28/matchers/events.d.ts +4 -0
  42. package/testing/jest/jest-28/matchers/index.d.ts +2 -1
  43. package/testing/jest/jest-29/matchers/events.d.ts +4 -0
  44. package/testing/jest/jest-29/matchers/index.d.ts +2 -1
  45. package/testing/mocks.d.ts +9 -9
  46. package/testing/package.json +1 -1
  47. package/testing/puppeteer/puppeteer-declarations.d.ts +11 -0
@@ -113,6 +113,275 @@ var queuedLoadModules = [];
113
113
  var caughtErrors = [];
114
114
  var hostRefs = /* @__PURE__ */ new Map();
115
115
 
116
+ // src/testing/platform/testing-host-ref.ts
117
+ var getHostRef = (elm) => {
118
+ return hostRefs.get(elm);
119
+ };
120
+ var registerInstance = (lazyInstance, hostRef) => {
121
+ if (lazyInstance == null || lazyInstance.constructor == null) {
122
+ throw new Error(`Invalid component constructor`);
123
+ }
124
+ if (hostRef == null) {
125
+ const Cstr = lazyInstance.constructor;
126
+ const tagName = Cstr.COMPILER_META && Cstr.COMPILER_META.tagName ? Cstr.COMPILER_META.tagName : "div";
127
+ const elm = document.createElement(tagName);
128
+ registerHost(elm, { $flags$: 0, $tagName$: tagName });
129
+ hostRef = getHostRef(elm);
130
+ }
131
+ hostRef.$lazyInstance$ = lazyInstance;
132
+ return hostRefs.set(lazyInstance, hostRef);
133
+ };
134
+ var registerHost = (elm, cmpMeta) => {
135
+ const hostRef = {
136
+ $flags$: 0,
137
+ $hostElement$: elm,
138
+ $cmpMeta$: cmpMeta,
139
+ $instanceValues$: /* @__PURE__ */ new Map(),
140
+ $renderCount$: 0
141
+ };
142
+ hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
143
+ hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
144
+ elm["s-p"] = [];
145
+ elm["s-rc"] = [];
146
+ hostRefs.set(elm, hostRef);
147
+ };
148
+
149
+ // src/testing/platform/testing-log.ts
150
+ var customError;
151
+ var defaultConsoleError = (e) => {
152
+ caughtErrors.push(e);
153
+ };
154
+ var consoleError = (e, el) => (customError || defaultConsoleError)(e, el);
155
+ var consoleDevError = (...e) => {
156
+ caughtErrors.push(new Error(e.join(", ")));
157
+ };
158
+ var consoleDevWarn = (...args) => {
159
+ const params = args.filter((a) => typeof a === "string" || typeof a === "number" || typeof a === "boolean");
160
+ console.warn(...params);
161
+ };
162
+ var consoleDevInfo = (..._) => {
163
+ };
164
+ var setErrorHandler = (handler) => customError = handler;
165
+
166
+ // src/testing/platform/testing-task-queue.ts
167
+ function resetTaskQueue() {
168
+ queuedTicks.length = 0;
169
+ queuedWriteTasks.length = 0;
170
+ queuedReadTasks.length = 0;
171
+ moduleLoaded.clear();
172
+ queuedLoadModules.length = 0;
173
+ caughtErrors.length = 0;
174
+ }
175
+ var nextTick = (cb) => {
176
+ queuedTicks.push(cb);
177
+ };
178
+ function flushTicks() {
179
+ return new Promise((resolve, reject) => {
180
+ function drain() {
181
+ try {
182
+ if (queuedTicks.length > 0) {
183
+ const writeTasks = queuedTicks.slice();
184
+ queuedTicks.length = 0;
185
+ let cb;
186
+ while (cb = writeTasks.shift()) {
187
+ cb(Date.now());
188
+ }
189
+ }
190
+ if (queuedTicks.length > 0) {
191
+ process.nextTick(drain);
192
+ } else {
193
+ resolve();
194
+ }
195
+ } catch (e) {
196
+ reject(`flushTicks: ${e}`);
197
+ }
198
+ }
199
+ process.nextTick(drain);
200
+ });
201
+ }
202
+ function writeTask(cb) {
203
+ queuedWriteTasks.push(cb);
204
+ }
205
+ function readTask(cb) {
206
+ queuedReadTasks.push(cb);
207
+ }
208
+ function flushQueue() {
209
+ return new Promise((resolve, reject) => {
210
+ async function drain() {
211
+ try {
212
+ if (queuedReadTasks.length > 0) {
213
+ const readTasks = queuedReadTasks.slice();
214
+ queuedReadTasks.length = 0;
215
+ let cb;
216
+ while (cb = readTasks.shift()) {
217
+ const result = cb(Date.now());
218
+ if (result != null && typeof result.then === "function") {
219
+ await result;
220
+ }
221
+ }
222
+ }
223
+ if (queuedWriteTasks.length > 0) {
224
+ const writeTasks = queuedWriteTasks.slice();
225
+ queuedWriteTasks.length = 0;
226
+ let cb;
227
+ while (cb = writeTasks.shift()) {
228
+ const result = cb(Date.now());
229
+ if (result != null && typeof result.then === "function") {
230
+ await result;
231
+ }
232
+ }
233
+ }
234
+ if (queuedReadTasks.length + queuedWriteTasks.length > 0) {
235
+ process.nextTick(drain);
236
+ } else {
237
+ resolve();
238
+ }
239
+ } catch (e) {
240
+ reject(`flushQueue: ${e}`);
241
+ }
242
+ }
243
+ process.nextTick(drain);
244
+ });
245
+ }
246
+ async function flushAll() {
247
+ while (queuedTicks.length + queuedLoadModules.length + queuedWriteTasks.length + queuedReadTasks.length > 0) {
248
+ await flushTicks();
249
+ await flushLoadModule();
250
+ await flushQueue();
251
+ }
252
+ if (caughtErrors.length > 0) {
253
+ const err2 = caughtErrors[0];
254
+ if (err2 == null) {
255
+ throw new Error("Error!");
256
+ }
257
+ if (typeof err2 === "string") {
258
+ throw new Error(err2);
259
+ }
260
+ throw err2;
261
+ }
262
+ return new Promise((resolve) => process.nextTick(resolve));
263
+ }
264
+ function loadModule(cmpMeta, _hostRef, _hmrVersionId) {
265
+ return new Promise((resolve) => {
266
+ queuedLoadModules.push({
267
+ bundleId: cmpMeta.$lazyBundleId$,
268
+ resolve: () => resolve(moduleLoaded.get(cmpMeta.$lazyBundleId$))
269
+ });
270
+ });
271
+ }
272
+ function flushLoadModule(bundleId) {
273
+ return new Promise((resolve, reject) => {
274
+ try {
275
+ process.nextTick(() => {
276
+ if (bundleId != null) {
277
+ for (let i2 = 0; i2 < queuedLoadModules.length; i2++) {
278
+ if (queuedLoadModules[i2].bundleId === bundleId) {
279
+ queuedLoadModules[i2].resolve();
280
+ queuedLoadModules.splice(i2, 1);
281
+ i2--;
282
+ }
283
+ }
284
+ } else {
285
+ let queuedLoadModule;
286
+ while (queuedLoadModule = queuedLoadModules.shift()) {
287
+ queuedLoadModule.resolve();
288
+ }
289
+ }
290
+ resolve();
291
+ });
292
+ } catch (e) {
293
+ reject(`flushLoadModule: ${e}`);
294
+ }
295
+ });
296
+ }
297
+
298
+ // src/testing/platform/testing-window.ts
299
+ var import_mock_doc = require("../../mock-doc/index.cjs");
300
+ var win = (0, import_mock_doc.setupGlobal)(global);
301
+ var doc = win.document;
302
+
303
+ // src/testing/platform/testing-platform.ts
304
+ var supportsShadow = true;
305
+ var plt = {
306
+ $flags$: 0,
307
+ $resourcesUrl$: "",
308
+ jmp: (h2) => h2(),
309
+ raf: (h2) => requestAnimationFrame(h2),
310
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
311
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
312
+ ce: (eventName, opts) => new win.CustomEvent(eventName, opts)
313
+ };
314
+ var setPlatformHelpers = (helpers) => {
315
+ Object.assign(plt, helpers);
316
+ };
317
+ var supportsListenerOptions = true;
318
+ var supportsConstructableStylesheets = false;
319
+ var setSupportsShadowDom = (supports) => {
320
+ supportsShadow = supports;
321
+ };
322
+ function resetPlatform(defaults = {}) {
323
+ if (win && typeof win.close === "function") {
324
+ win.close();
325
+ }
326
+ hostRefs.clear();
327
+ styles.clear();
328
+ plt.$flags$ = 0;
329
+ Object.assign(plt, defaults);
330
+ if (plt.$orgLocNodes$ != null) {
331
+ plt.$orgLocNodes$.clear();
332
+ plt.$orgLocNodes$ = void 0;
333
+ }
334
+ win.location.href = plt.$resourcesUrl$ = `http://testing.stenciljs.com/`;
335
+ resetTaskQueue();
336
+ stopAutoApplyChanges();
337
+ cstrs.clear();
338
+ }
339
+ var isAutoApplyingChanges = false;
340
+ var autoApplyTimer = void 0;
341
+ function stopAutoApplyChanges() {
342
+ isAutoApplyingChanges = false;
343
+ if (autoApplyTimer) {
344
+ clearTimeout(autoApplyTimer);
345
+ autoApplyTimer = void 0;
346
+ }
347
+ }
348
+ async function startAutoApplyChanges() {
349
+ isAutoApplyingChanges = true;
350
+ flushAll().then(() => {
351
+ if (isAutoApplyingChanges) {
352
+ autoApplyTimer = setTimeout(() => {
353
+ startAutoApplyChanges();
354
+ }, 100);
355
+ }
356
+ });
357
+ }
358
+ var registerComponents = (Cstrs) => {
359
+ Cstrs.filter((Cstr) => Cstr.COMPILER_META).forEach((Cstr) => {
360
+ cstrs.set(Cstr.COMPILER_META.tagName, Cstr);
361
+ });
362
+ };
363
+ function registerModule(bundleId, Cstr) {
364
+ moduleLoaded.set(bundleId, Cstr);
365
+ }
366
+ var isMemberInElement = (elm, memberName) => {
367
+ if (elm != null) {
368
+ if (memberName in elm) {
369
+ return true;
370
+ }
371
+ const nodeName = elm.nodeName;
372
+ if (nodeName) {
373
+ const cstr = cstrs.get(nodeName.toLowerCase());
374
+ if (cstr != null && cstr.COMPILER_META != null && cstr.COMPILER_META.properties != null) {
375
+ return cstr.COMPILER_META.properties.some((p) => p.name === memberName);
376
+ }
377
+ }
378
+ }
379
+ return false;
380
+ };
381
+
382
+ // src/testing/platform/index.ts
383
+ var import_app_data21 = require("@stencil/core/internal/app-data");
384
+
116
385
  // src/runtime/asset-path.ts
117
386
  var getAssetPath = (path) => {
118
387
  const assetUrl = new URL(path, plt.$resourcesUrl$);
@@ -718,6 +987,8 @@ var registerStyle = (scopeId2, cssText, allowCS) => {
718
987
  };
719
988
  var addStyle = (styleContainerNode, cmpMeta, mode) => {
720
989
  var _a;
990
+ const styleContainerDocument = styleContainerNode;
991
+ const styleContainerShadowRoot = styleContainerNode;
721
992
  const scopeId2 = getScopeId(cmpMeta, mode);
722
993
  const style = styles.get(scopeId2);
723
994
  if (!import_app_data7.BUILD.attachStyles) {
@@ -726,14 +997,14 @@ var addStyle = (styleContainerNode, cmpMeta, mode) => {
726
997
  styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
727
998
  if (style) {
728
999
  if (typeof style === "string") {
729
- styleContainerNode = styleContainerNode.head || styleContainerNode;
1000
+ styleContainerNode = styleContainerDocument.head || styleContainerNode;
730
1001
  let appliedStyles = rootAppliedStyles.get(styleContainerNode);
731
1002
  let styleElm;
732
1003
  if (!appliedStyles) {
733
1004
  rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
734
1005
  }
735
1006
  if (!appliedStyles.has(scopeId2)) {
736
- if (import_app_data7.BUILD.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
1007
+ if (import_app_data7.BUILD.hydrateClientSide && styleContainerShadowRoot.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
737
1008
  styleElm.innerHTML = style;
738
1009
  } else {
739
1010
  styleElm = doc.createElement("style");
@@ -754,8 +1025,8 @@ var addStyle = (styleContainerNode, cmpMeta, mode) => {
754
1025
  appliedStyles.add(scopeId2);
755
1026
  }
756
1027
  }
757
- } else if (import_app_data7.BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
758
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
1028
+ } else if (import_app_data7.BUILD.constructableCSS && !styleContainerDocument.adoptedStyleSheets.includes(style)) {
1029
+ styleContainerDocument.adoptedStyleSheets = [...styleContainerDocument.adoptedStyleSheets, style];
759
1030
  }
760
1031
  }
761
1032
  return scopeId2;
@@ -966,9 +1237,9 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
966
1237
  }
967
1238
  elm = newVNode2.$elm$ = import_app_data10.BUILD.svg ? doc.createElementNS(
968
1239
  isSvgMode ? SVG_NS : HTML_NS,
969
- import_app_data10.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1240
+ !useNativeShadowDom && import_app_data10.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
970
1241
  ) : doc.createElement(
971
- import_app_data10.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1242
+ !useNativeShadowDom && import_app_data10.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
972
1243
  );
973
1244
  if (import_app_data10.BUILD.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
974
1245
  isSvgMode = false;
@@ -1555,7 +1826,10 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
1555
1826
  endSchedule();
1556
1827
  return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1557
1828
  };
1558
- var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
1829
+ var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err2) => {
1830
+ console.error(err2);
1831
+ fn();
1832
+ }) : fn();
1559
1833
  var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
1560
1834
  var updateComponent = async (hostRef, instance, isInitialLoad) => {
1561
1835
  var _a;
@@ -1844,7 +2118,7 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
1844
2118
 
1845
2119
  // src/runtime/proxy-component.ts
1846
2120
  var proxyComponent = (Cstr, cmpMeta, flags) => {
1847
- var _a;
2121
+ var _a, _b;
1848
2122
  const prototype = Cstr.prototype;
1849
2123
  if (import_app_data13.BUILD.formAssociated && cmpMeta.$flags$ & 64 /* formAssociated */ && flags & 1 /* isElementConstructor */) {
1850
2124
  FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS.forEach(
@@ -1866,11 +2140,11 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1866
2140
  })
1867
2141
  );
1868
2142
  }
1869
- if (import_app_data13.BUILD.member && cmpMeta.$members$) {
1870
- if (import_app_data13.BUILD.watchCallback && Cstr.watchers) {
2143
+ if (import_app_data13.BUILD.member && cmpMeta.$members$ || import_app_data13.BUILD.watchCallback && (cmpMeta.$watchers$ || Cstr.watchers)) {
2144
+ if (import_app_data13.BUILD.watchCallback && Cstr.watchers && !cmpMeta.$watchers$) {
1871
2145
  cmpMeta.$watchers$ = Cstr.watchers;
1872
2146
  }
1873
- const members = Object.entries(cmpMeta.$members$);
2147
+ const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
1874
2148
  members.map(([memberName, [memberFlags]]) => {
1875
2149
  if ((import_app_data13.BUILD.prop || import_app_data13.BUILD.state) && (memberFlags & 31 /* Prop */ || (!import_app_data13.BUILD.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
1876
2150
  Object.defineProperty(prototype, memberName, {
@@ -1942,7 +2216,7 @@ More information: https://stenciljs.com/docs/properties#prop-mutability`
1942
2216
  };
1943
2217
  Cstr.observedAttributes = Array.from(
1944
2218
  /* @__PURE__ */ new Set([
1945
- ...Object.keys((_a = cmpMeta.$watchers$) != null ? _a : {}),
2219
+ ...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
1946
2220
  ...members.filter(([_, m]) => m[0] & 15 /* HasAttribute */).map(([propName, m]) => {
1947
2221
  var _a2;
1948
2222
  const attrName = m[1] || propName;
@@ -2010,11 +2284,13 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2010
2284
  customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
2011
2285
  }
2012
2286
  if (import_app_data14.BUILD.style && Cstr && Cstr.style) {
2013
- let style = Cstr.style;
2014
- if (import_app_data14.BUILD.mode && typeof style !== "string") {
2287
+ let style;
2288
+ if (typeof Cstr.style === "string") {
2289
+ style = Cstr.style;
2290
+ } else if (import_app_data14.BUILD.mode && typeof Cstr.style !== "string") {
2015
2291
  hostRef.$modeName$ = computeMode(elm);
2016
2292
  if (hostRef.$modeName$) {
2017
- style = style[hostRef.$modeName$];
2293
+ style = Cstr.style[hostRef.$modeName$];
2018
2294
  }
2019
2295
  if (import_app_data14.BUILD.hydrateServerSide && hostRef.$modeName$) {
2020
2296
  elm.setAttribute("s-mode", hostRef.$modeName$);
@@ -2507,6 +2783,8 @@ var proxyCustomElement = (Cstr, compactMeta) => {
2507
2783
  registerHost(this, cmpMeta);
2508
2784
  },
2509
2785
  connectedCallback() {
2786
+ const hostRef = getHostRef(this);
2787
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
2510
2788
  connectedCallback(this);
2511
2789
  if (import_app_data18.BUILD.connectedCallback && originalConnectedCallback) {
2512
2790
  originalConnectedCallback.call(this);
@@ -2520,13 +2798,21 @@ var proxyCustomElement = (Cstr, compactMeta) => {
2520
2798
  },
2521
2799
  __attachShadow() {
2522
2800
  if (supportsShadow) {
2523
- if (import_app_data18.BUILD.shadowDelegatesFocus) {
2524
- this.attachShadow({
2525
- mode: "open",
2526
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2527
- });
2801
+ if (!this.shadowRoot) {
2802
+ if (import_app_data18.BUILD.shadowDelegatesFocus) {
2803
+ this.attachShadow({
2804
+ mode: "open",
2805
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2806
+ });
2807
+ } else {
2808
+ this.attachShadow({ mode: "open" });
2809
+ }
2528
2810
  } else {
2529
- this.attachShadow({ mode: "open" });
2811
+ if (this.shadowRoot.mode !== "open") {
2812
+ throw new Error(
2813
+ `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`
2814
+ );
2815
+ }
2530
2816
  }
2531
2817
  } else {
2532
2818
  this.shadowRoot = this;
@@ -2636,17 +2922,26 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2636
2922
  // StencilLazyHost
2637
2923
  constructor(self) {
2638
2924
  super(self);
2925
+ this.hasRegisteredEventListeners = false;
2639
2926
  self = this;
2640
2927
  registerHost(self, cmpMeta);
2641
2928
  if (import_app_data19.BUILD.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2642
2929
  if (supportsShadow) {
2643
- if (import_app_data19.BUILD.shadowDelegatesFocus) {
2644
- self.attachShadow({
2645
- mode: "open",
2646
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2647
- });
2930
+ if (!self.shadowRoot) {
2931
+ if (import_app_data19.BUILD.shadowDelegatesFocus) {
2932
+ self.attachShadow({
2933
+ mode: "open",
2934
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2935
+ });
2936
+ } else {
2937
+ self.attachShadow({ mode: "open" });
2938
+ }
2648
2939
  } else {
2649
- self.attachShadow({ mode: "open" });
2940
+ if (self.shadowRoot.mode !== "open") {
2941
+ throw new Error(
2942
+ `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but Stencil only supports open shadow roots.`
2943
+ );
2944
+ }
2650
2945
  }
2651
2946
  } else if (!import_app_data19.BUILD.hydrateServerSide && !("shadowRoot" in self)) {
2652
2947
  self.shadowRoot = self;
@@ -2654,6 +2949,11 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2654
2949
  }
2655
2950
  }
2656
2951
  connectedCallback() {
2952
+ const hostRef = getHostRef(this);
2953
+ if (!this.hasRegisteredEventListeners) {
2954
+ this.hasRegisteredEventListeners = true;
2955
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
2956
+ }
2657
2957
  if (appLoadFallback) {
2658
2958
  clearTimeout(appLoadFallback);
2659
2959
  appLoadFallback = null;
@@ -2712,7 +3012,7 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2712
3012
  dataStyles.textContent += SLOT_FB_CSS;
2713
3013
  }
2714
3014
  if (import_app_data19.BUILD.invisiblePrehydration && (import_app_data19.BUILD.hydratedClass || import_app_data19.BUILD.hydratedAttribute)) {
2715
- dataStyles.textContent += cmpTags + HYDRATED_CSS;
3015
+ dataStyles.textContent += cmpTags.sort() + HYDRATED_CSS;
2716
3016
  }
2717
3017
  if (dataStyles.innerHTML.length) {
2718
3018
  dataStyles.setAttribute("data-styles", "");
@@ -2803,402 +3103,134 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
2803
3103
  staticComponents: new Set(staticComponents)
2804
3104
  };
2805
3105
  const orgLocationNodes = [];
2806
- parseVNodeAnnotations(doc2, doc2.body, docData, orgLocationNodes);
2807
- orgLocationNodes.forEach((orgLocationNode) => {
2808
- var _a;
2809
- if (orgLocationNode != null && orgLocationNode["s-nr"]) {
2810
- const nodeRef = orgLocationNode["s-nr"];
2811
- let hostId = nodeRef["s-host-id"];
2812
- let nodeId = nodeRef["s-node-id"];
2813
- let childId = `${hostId}.${nodeId}`;
2814
- if (hostId == null) {
2815
- hostId = 0;
2816
- docData.rootLevelIds++;
2817
- nodeId = docData.rootLevelIds;
2818
- childId = `${hostId}.${nodeId}`;
2819
- if (nodeRef.nodeType === 1 /* ElementNode */) {
2820
- nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
2821
- } else if (nodeRef.nodeType === 3 /* TextNode */) {
2822
- if (hostId === 0) {
2823
- const textContent = (_a = nodeRef.nodeValue) == null ? void 0 : _a.trim();
2824
- if (textContent === "") {
2825
- orgLocationNode.remove();
2826
- return;
2827
- }
2828
- }
2829
- const commentBeforeTextNode = doc2.createComment(childId);
2830
- commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2831
- insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
2832
- }
2833
- }
2834
- let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
2835
- const orgLocationParentNode = orgLocationNode.parentElement;
2836
- if (orgLocationParentNode) {
2837
- if (orgLocationParentNode["s-en"] === "") {
2838
- orgLocationNodeId += `.`;
2839
- } else if (orgLocationParentNode["s-en"] === "c") {
2840
- orgLocationNodeId += `.c`;
2841
- }
2842
- }
2843
- orgLocationNode.nodeValue = orgLocationNodeId;
2844
- }
2845
- });
2846
- }
2847
- };
2848
- var parseVNodeAnnotations = (doc2, node, docData, orgLocationNodes) => {
2849
- if (node == null) {
2850
- return;
2851
- }
2852
- if (node["s-nr"] != null) {
2853
- orgLocationNodes.push(node);
2854
- }
2855
- if (node.nodeType === 1 /* ElementNode */) {
2856
- node.childNodes.forEach((childNode) => {
2857
- const hostRef = getHostRef(childNode);
2858
- if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
2859
- const cmpData = {
2860
- nodeIds: 0
2861
- };
2862
- insertVNodeAnnotations(doc2, childNode, hostRef.$vnode$, docData, cmpData);
2863
- }
2864
- parseVNodeAnnotations(doc2, childNode, docData, orgLocationNodes);
2865
- });
2866
- }
2867
- };
2868
- var insertVNodeAnnotations = (doc2, hostElm, vnode, docData, cmpData) => {
2869
- if (vnode != null) {
2870
- const hostId = ++docData.hostIds;
2871
- hostElm.setAttribute(HYDRATE_ID, hostId);
2872
- if (hostElm["s-cr"] != null) {
2873
- hostElm["s-cr"].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
2874
- }
2875
- if (vnode.$children$ != null) {
2876
- const depth = 0;
2877
- vnode.$children$.forEach((vnodeChild, index) => {
2878
- insertChildVNodeAnnotations(doc2, vnodeChild, cmpData, hostId, depth, index);
2879
- });
2880
- }
2881
- if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute(HYDRATE_CHILD_ID)) {
2882
- const parent = hostElm.parentElement;
2883
- if (parent && parent.childNodes) {
2884
- const parentChildNodes = Array.from(parent.childNodes);
2885
- const comment = parentChildNodes.find(
2886
- (node) => node.nodeType === 8 /* CommentNode */ && node["s-sr"]
2887
- );
2888
- if (comment) {
2889
- const index = parentChildNodes.indexOf(hostElm) - 1;
2890
- vnode.$elm$.setAttribute(
2891
- HYDRATE_CHILD_ID,
2892
- `${comment["s-host-id"]}.${comment["s-node-id"]}.0.${index}`
2893
- );
2894
- }
2895
- }
2896
- }
2897
- }
2898
- };
2899
- var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, index) => {
2900
- const childElm = vnodeChild.$elm$;
2901
- if (childElm == null) {
2902
- return;
2903
- }
2904
- const nodeId = cmpData.nodeIds++;
2905
- const childId = `${hostId}.${nodeId}.${depth}.${index}`;
2906
- childElm["s-host-id"] = hostId;
2907
- childElm["s-node-id"] = nodeId;
2908
- if (childElm.nodeType === 1 /* ElementNode */) {
2909
- childElm.setAttribute(HYDRATE_CHILD_ID, childId);
2910
- } else if (childElm.nodeType === 3 /* TextNode */) {
2911
- const parentNode = childElm.parentNode;
2912
- const nodeName = parentNode == null ? void 0 : parentNode.nodeName;
2913
- if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
2914
- const textNodeId = `${TEXT_NODE_ID}.${childId}`;
2915
- const commentBeforeTextNode = doc2.createComment(textNodeId);
2916
- insertBefore(parentNode, commentBeforeTextNode, childElm);
2917
- }
2918
- } else if (childElm.nodeType === 8 /* CommentNode */) {
2919
- if (childElm["s-sr"]) {
2920
- const slotName = childElm["s-sn"] || "";
2921
- const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
2922
- childElm.nodeValue = slotNodeId;
2923
- }
2924
- }
2925
- if (vnodeChild.$children$ != null) {
2926
- const childDepth = depth + 1;
2927
- vnodeChild.$children$.forEach((vnode, index2) => {
2928
- insertChildVNodeAnnotations(doc2, vnode, cmpData, hostId, childDepth, index2);
2929
- });
2930
- }
2931
- };
2932
-
2933
- // src/testing/platform/testing-host-ref.ts
2934
- var getHostRef = (elm) => {
2935
- return hostRefs.get(elm);
2936
- };
2937
- var registerInstance = (lazyInstance, hostRef) => {
2938
- if (lazyInstance == null || lazyInstance.constructor == null) {
2939
- throw new Error(`Invalid component constructor`);
2940
- }
2941
- if (hostRef == null) {
2942
- const Cstr = lazyInstance.constructor;
2943
- const tagName = Cstr.COMPILER_META && Cstr.COMPILER_META.tagName ? Cstr.COMPILER_META.tagName : "div";
2944
- const elm = document.createElement(tagName);
2945
- registerHost(elm, { $flags$: 0, $tagName$: tagName });
2946
- hostRef = getHostRef(elm);
2947
- }
2948
- hostRef.$lazyInstance$ = lazyInstance;
2949
- return hostRefs.set(lazyInstance, hostRef);
2950
- };
2951
- var registerHost = (elm, cmpMeta) => {
2952
- const hostRef = {
2953
- $flags$: 0,
2954
- $hostElement$: elm,
2955
- $cmpMeta$: cmpMeta,
2956
- $instanceValues$: /* @__PURE__ */ new Map(),
2957
- $renderCount$: 0
2958
- };
2959
- hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
2960
- hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
2961
- elm["s-p"] = [];
2962
- elm["s-rc"] = [];
2963
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2964
- hostRefs.set(elm, hostRef);
2965
- };
2966
-
2967
- // src/testing/platform/testing-log.ts
2968
- var customError;
2969
- var defaultConsoleError = (e) => {
2970
- caughtErrors.push(e);
2971
- };
2972
- var consoleError = (e, el) => (customError || defaultConsoleError)(e, el);
2973
- var consoleDevError = (...e) => {
2974
- caughtErrors.push(new Error(e.join(", ")));
2975
- };
2976
- var consoleDevWarn = (...args) => {
2977
- const params = args.filter((a) => typeof a === "string" || typeof a === "number" || typeof a === "boolean");
2978
- console.warn(...params);
2979
- };
2980
- var consoleDevInfo = (..._) => {
2981
- };
2982
- var setErrorHandler = (handler) => customError = handler;
2983
-
2984
- // src/testing/platform/testing-task-queue.ts
2985
- function resetTaskQueue() {
2986
- queuedTicks.length = 0;
2987
- queuedWriteTasks.length = 0;
2988
- queuedReadTasks.length = 0;
2989
- moduleLoaded.clear();
2990
- queuedLoadModules.length = 0;
2991
- caughtErrors.length = 0;
2992
- }
2993
- var nextTick = (cb) => {
2994
- queuedTicks.push(cb);
2995
- };
2996
- function flushTicks() {
2997
- return new Promise((resolve, reject) => {
2998
- function drain() {
2999
- try {
3000
- if (queuedTicks.length > 0) {
3001
- const writeTasks = queuedTicks.slice();
3002
- queuedTicks.length = 0;
3003
- let cb;
3004
- while (cb = writeTasks.shift()) {
3005
- cb(Date.now());
3006
- }
3007
- }
3008
- if (queuedTicks.length > 0) {
3009
- process.nextTick(drain);
3010
- } else {
3011
- resolve();
3012
- }
3013
- } catch (e) {
3014
- reject(`flushTicks: ${e}`);
3015
- }
3016
- }
3017
- process.nextTick(drain);
3018
- });
3019
- }
3020
- function writeTask(cb) {
3021
- queuedWriteTasks.push(cb);
3022
- }
3023
- function readTask(cb) {
3024
- queuedReadTasks.push(cb);
3025
- }
3026
- function flushQueue() {
3027
- return new Promise((resolve, reject) => {
3028
- async function drain() {
3029
- try {
3030
- if (queuedReadTasks.length > 0) {
3031
- const readTasks = queuedReadTasks.slice();
3032
- queuedReadTasks.length = 0;
3033
- let cb;
3034
- while (cb = readTasks.shift()) {
3035
- const result = cb(Date.now());
3036
- if (result != null && typeof result.then === "function") {
3037
- await result;
3106
+ parseVNodeAnnotations(doc2, doc2.body, docData, orgLocationNodes);
3107
+ orgLocationNodes.forEach((orgLocationNode) => {
3108
+ var _a;
3109
+ if (orgLocationNode != null && orgLocationNode["s-nr"]) {
3110
+ const nodeRef = orgLocationNode["s-nr"];
3111
+ let hostId = nodeRef["s-host-id"];
3112
+ let nodeId = nodeRef["s-node-id"];
3113
+ let childId = `${hostId}.${nodeId}`;
3114
+ if (hostId == null) {
3115
+ hostId = 0;
3116
+ docData.rootLevelIds++;
3117
+ nodeId = docData.rootLevelIds;
3118
+ childId = `${hostId}.${nodeId}`;
3119
+ if (nodeRef.nodeType === 1 /* ElementNode */) {
3120
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
3121
+ } else if (nodeRef.nodeType === 3 /* TextNode */) {
3122
+ if (hostId === 0) {
3123
+ const textContent = (_a = nodeRef.nodeValue) == null ? void 0 : _a.trim();
3124
+ if (textContent === "") {
3125
+ orgLocationNode.remove();
3126
+ return;
3127
+ }
3038
3128
  }
3129
+ const commentBeforeTextNode = doc2.createComment(childId);
3130
+ commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
3131
+ insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
3039
3132
  }
3040
3133
  }
3041
- if (queuedWriteTasks.length > 0) {
3042
- const writeTasks = queuedWriteTasks.slice();
3043
- queuedWriteTasks.length = 0;
3044
- let cb;
3045
- while (cb = writeTasks.shift()) {
3046
- const result = cb(Date.now());
3047
- if (result != null && typeof result.then === "function") {
3048
- await result;
3049
- }
3134
+ let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
3135
+ const orgLocationParentNode = orgLocationNode.parentElement;
3136
+ if (orgLocationParentNode) {
3137
+ if (orgLocationParentNode["s-en"] === "") {
3138
+ orgLocationNodeId += `.`;
3139
+ } else if (orgLocationParentNode["s-en"] === "c") {
3140
+ orgLocationNodeId += `.c`;
3050
3141
  }
3051
3142
  }
3052
- if (queuedReadTasks.length + queuedWriteTasks.length > 0) {
3053
- process.nextTick(drain);
3054
- } else {
3055
- resolve();
3056
- }
3057
- } catch (e) {
3058
- reject(`flushQueue: ${e}`);
3143
+ orgLocationNode.nodeValue = orgLocationNodeId;
3059
3144
  }
3060
- }
3061
- process.nextTick(drain);
3062
- });
3063
- }
3064
- async function flushAll() {
3065
- while (queuedTicks.length + queuedLoadModules.length + queuedWriteTasks.length + queuedReadTasks.length > 0) {
3066
- await flushTicks();
3067
- await flushLoadModule();
3068
- await flushQueue();
3069
- }
3070
- if (caughtErrors.length > 0) {
3071
- const err2 = caughtErrors[0];
3072
- if (err2 == null) {
3073
- throw new Error("Error!");
3074
- }
3075
- if (typeof err2 === "string") {
3076
- throw new Error(err2);
3077
- }
3078
- throw err2;
3079
- }
3080
- return new Promise((resolve) => process.nextTick(resolve));
3081
- }
3082
- function loadModule(cmpMeta, _hostRef, _hmrVersionId) {
3083
- return new Promise((resolve) => {
3084
- queuedLoadModules.push({
3085
- bundleId: cmpMeta.$lazyBundleId$,
3086
- resolve: () => resolve(moduleLoaded.get(cmpMeta.$lazyBundleId$))
3087
3145
  });
3088
- });
3089
- }
3090
- function flushLoadModule(bundleId) {
3091
- return new Promise((resolve, reject) => {
3092
- try {
3093
- process.nextTick(() => {
3094
- if (bundleId != null) {
3095
- for (let i2 = 0; i2 < queuedLoadModules.length; i2++) {
3096
- if (queuedLoadModules[i2].bundleId === bundleId) {
3097
- queuedLoadModules[i2].resolve();
3098
- queuedLoadModules.splice(i2, 1);
3099
- i2--;
3100
- }
3101
- }
3102
- } else {
3103
- let queuedLoadModule;
3104
- while (queuedLoadModule = queuedLoadModules.shift()) {
3105
- queuedLoadModule.resolve();
3106
- }
3107
- }
3108
- resolve();
3109
- });
3110
- } catch (e) {
3111
- reject(`flushLoadModule: ${e}`);
3112
- }
3113
- });
3114
- }
3115
-
3116
- // src/testing/platform/testing-window.ts
3117
- var import_mock_doc = require("../../mock-doc/index.cjs");
3118
- var win = (0, import_mock_doc.setupGlobal)(global);
3119
- var doc = win.document;
3120
-
3121
- // src/testing/platform/testing-platform.ts
3122
- var supportsShadow = true;
3123
- var plt = {
3124
- $flags$: 0,
3125
- $resourcesUrl$: "",
3126
- jmp: (h2) => h2(),
3127
- raf: (h2) => requestAnimationFrame(h2),
3128
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
3129
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
3130
- ce: (eventName, opts) => new win.CustomEvent(eventName, opts)
3131
- };
3132
- var setPlatformHelpers = (helpers) => {
3133
- Object.assign(plt, helpers);
3134
- };
3135
- var supportsListenerOptions = true;
3136
- var supportsConstructableStylesheets = false;
3137
- var setSupportsShadowDom = (supports) => {
3138
- supportsShadow = supports;
3146
+ }
3139
3147
  };
3140
- function resetPlatform(defaults = {}) {
3141
- if (win && typeof win.close === "function") {
3142
- win.close();
3148
+ var parseVNodeAnnotations = (doc2, node, docData, orgLocationNodes) => {
3149
+ var _a;
3150
+ if (node == null) {
3151
+ return;
3143
3152
  }
3144
- hostRefs.clear();
3145
- styles.clear();
3146
- plt.$flags$ = 0;
3147
- Object.assign(plt, defaults);
3148
- if (plt.$orgLocNodes$ != null) {
3149
- plt.$orgLocNodes$.clear();
3150
- plt.$orgLocNodes$ = void 0;
3153
+ if (node["s-nr"] != null) {
3154
+ orgLocationNodes.push(node);
3151
3155
  }
3152
- win.location.href = plt.$resourcesUrl$ = `http://testing.stenciljs.com/`;
3153
- resetTaskQueue();
3154
- stopAutoApplyChanges();
3155
- cstrs.clear();
3156
- }
3157
- var isAutoApplyingChanges = false;
3158
- var autoApplyTimer = void 0;
3159
- function stopAutoApplyChanges() {
3160
- isAutoApplyingChanges = false;
3161
- if (autoApplyTimer) {
3162
- clearTimeout(autoApplyTimer);
3163
- autoApplyTimer = void 0;
3156
+ if (node.nodeType === 1 /* ElementNode */) {
3157
+ const childNodes = [...Array.from(node.childNodes), ...Array.from(((_a = node.shadowRoot) == null ? void 0 : _a.childNodes) || [])];
3158
+ childNodes.forEach((childNode) => {
3159
+ const hostRef = getHostRef(childNode);
3160
+ if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
3161
+ const cmpData = {
3162
+ nodeIds: 0
3163
+ };
3164
+ insertVNodeAnnotations(doc2, childNode, hostRef.$vnode$, docData, cmpData);
3165
+ }
3166
+ parseVNodeAnnotations(doc2, childNode, docData, orgLocationNodes);
3167
+ });
3164
3168
  }
3165
- }
3166
- async function startAutoApplyChanges() {
3167
- isAutoApplyingChanges = true;
3168
- flushAll().then(() => {
3169
- if (isAutoApplyingChanges) {
3170
- autoApplyTimer = setTimeout(() => {
3171
- startAutoApplyChanges();
3172
- }, 100);
3173
- }
3174
- });
3175
- }
3176
- var registerComponents = (Cstrs) => {
3177
- Cstrs.filter((Cstr) => Cstr.COMPILER_META).forEach((Cstr) => {
3178
- cstrs.set(Cstr.COMPILER_META.tagName, Cstr);
3179
- });
3180
3169
  };
3181
- function registerModule(bundleId, Cstr) {
3182
- moduleLoaded.set(bundleId, Cstr);
3183
- }
3184
- var isMemberInElement = (elm, memberName) => {
3185
- if (elm != null) {
3186
- if (memberName in elm) {
3187
- return true;
3170
+ var insertVNodeAnnotations = (doc2, hostElm, vnode, docData, cmpData) => {
3171
+ if (vnode != null) {
3172
+ const hostId = ++docData.hostIds;
3173
+ hostElm.setAttribute(HYDRATE_ID, hostId);
3174
+ if (hostElm["s-cr"] != null) {
3175
+ hostElm["s-cr"].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
3188
3176
  }
3189
- const nodeName = elm.nodeName;
3190
- if (nodeName) {
3191
- const cstr = cstrs.get(nodeName.toLowerCase());
3192
- if (cstr != null && cstr.COMPILER_META != null && cstr.COMPILER_META.properties != null) {
3193
- return cstr.COMPILER_META.properties.some((p) => p.name === memberName);
3177
+ if (vnode.$children$ != null) {
3178
+ const depth = 0;
3179
+ vnode.$children$.forEach((vnodeChild, index) => {
3180
+ insertChildVNodeAnnotations(doc2, vnodeChild, cmpData, hostId, depth, index);
3181
+ });
3182
+ }
3183
+ if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute(HYDRATE_CHILD_ID)) {
3184
+ const parent = hostElm.parentElement;
3185
+ if (parent && parent.childNodes) {
3186
+ const parentChildNodes = Array.from(parent.childNodes);
3187
+ const comment = parentChildNodes.find(
3188
+ (node) => node.nodeType === 8 /* CommentNode */ && node["s-sr"]
3189
+ );
3190
+ if (comment) {
3191
+ const index = parentChildNodes.indexOf(hostElm) - 1;
3192
+ vnode.$elm$.setAttribute(
3193
+ HYDRATE_CHILD_ID,
3194
+ `${comment["s-host-id"]}.${comment["s-node-id"]}.0.${index}`
3195
+ );
3196
+ }
3194
3197
  }
3195
3198
  }
3196
3199
  }
3197
- return false;
3198
3200
  };
3199
-
3200
- // src/testing/platform/index.ts
3201
- var import_app_data21 = require("@stencil/core/internal/app-data");
3201
+ var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, index) => {
3202
+ const childElm = vnodeChild.$elm$;
3203
+ if (childElm == null) {
3204
+ return;
3205
+ }
3206
+ const nodeId = cmpData.nodeIds++;
3207
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
3208
+ childElm["s-host-id"] = hostId;
3209
+ childElm["s-node-id"] = nodeId;
3210
+ if (childElm.nodeType === 1 /* ElementNode */) {
3211
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
3212
+ } else if (childElm.nodeType === 3 /* TextNode */) {
3213
+ const parentNode = childElm.parentNode;
3214
+ const nodeName = parentNode == null ? void 0 : parentNode.nodeName;
3215
+ if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
3216
+ const textNodeId = `${TEXT_NODE_ID}.${childId}`;
3217
+ const commentBeforeTextNode = doc2.createComment(textNodeId);
3218
+ insertBefore(parentNode, commentBeforeTextNode, childElm);
3219
+ }
3220
+ } else if (childElm.nodeType === 8 /* CommentNode */) {
3221
+ if (childElm["s-sr"]) {
3222
+ const slotName = childElm["s-sn"] || "";
3223
+ const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
3224
+ childElm.nodeValue = slotNodeId;
3225
+ }
3226
+ }
3227
+ if (vnodeChild.$children$ != null) {
3228
+ const childDepth = depth + 1;
3229
+ vnodeChild.$children$.forEach((vnode, index2) => {
3230
+ insertChildVNodeAnnotations(doc2, vnode, cmpData, hostId, childDepth, index2);
3231
+ });
3232
+ }
3233
+ };
3202
3234
  // Annotate the CommonJS export names for ESM import in node:
3203
3235
  0 && (module.exports = {
3204
3236
  Build,