@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
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Hydrate Runner v4.18.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Hydrate Runner v4.18.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -115,10 +115,8 @@ function cloneAttributes(srcAttrs, sortByName = false) {
115
115
  return dstAttrs;
116
116
  }
117
117
  function sortAttributes(a, b) {
118
- if (a.name < b.name)
119
- return -1;
120
- if (a.name > b.name)
121
- return 1;
118
+ if (a.name < b.name) return -1;
119
+ if (a.name > b.name) return 1;
122
120
  return 0;
123
121
  }
124
122
  var MockAttr = class {
@@ -11200,13 +11198,13 @@ Testing components with ElementInternals is fully supported in e2e tests.`
11200
11198
  setTextContent(this, value);
11201
11199
  }
11202
11200
  insertAdjacentElement(position, elm) {
11203
- if (position === "beforebegin") {
11201
+ if (position === "beforebegin" && this.parentNode) {
11204
11202
  insertBefore(this.parentNode, elm, this);
11205
11203
  } else if (position === "afterbegin") {
11206
11204
  this.prepend(elm);
11207
11205
  } else if (position === "beforeend") {
11208
11206
  this.appendChild(elm);
11209
- } else if (position === "afterend") {
11207
+ } else if (position === "afterend" && this.parentNode) {
11210
11208
  insertBefore(this.parentNode, elm, this.nextSibling);
11211
11209
  }
11212
11210
  return elm;
@@ -11215,7 +11213,9 @@ Testing components with ElementInternals is fully supported in e2e tests.`
11215
11213
  const frag = parseFragmentUtil(this.ownerDocument, html);
11216
11214
  if (position === "beforebegin") {
11217
11215
  while (frag.childNodes.length > 0) {
11218
- insertBefore(this.parentNode, frag.childNodes[0], this);
11216
+ if (this.parentNode) {
11217
+ insertBefore(this.parentNode, frag.childNodes[0], this);
11218
+ }
11219
11219
  }
11220
11220
  } else if (position === "afterbegin") {
11221
11221
  while (frag.childNodes.length > 0) {
@@ -11227,19 +11227,21 @@ Testing components with ElementInternals is fully supported in e2e tests.`
11227
11227
  }
11228
11228
  } else if (position === "afterend") {
11229
11229
  while (frag.childNodes.length > 0) {
11230
- insertBefore(this.parentNode, frag.childNodes[frag.childNodes.length - 1], this.nextSibling);
11230
+ if (this.parentNode) {
11231
+ insertBefore(this.parentNode, frag.childNodes[frag.childNodes.length - 1], this.nextSibling);
11232
+ }
11231
11233
  }
11232
11234
  }
11233
11235
  }
11234
11236
  insertAdjacentText(position, text) {
11235
11237
  const elm = this.ownerDocument.createTextNode(text);
11236
- if (position === "beforebegin") {
11238
+ if (position === "beforebegin" && this.parentNode) {
11237
11239
  insertBefore(this.parentNode, elm, this);
11238
11240
  } else if (position === "afterbegin") {
11239
11241
  this.prepend(elm);
11240
11242
  } else if (position === "beforeend") {
11241
11243
  this.appendChild(elm);
11242
- } else if (position === "afterend") {
11244
+ } else if (position === "afterend" && this.parentNode) {
11243
11245
  insertBefore(this.parentNode, elm, this.nextSibling);
11244
11246
  }
11245
11247
  }
@@ -14126,8 +14128,7 @@ var parseCss = (css, filePath) => {
14126
14128
  const diagnostics = [];
14127
14129
  const updatePosition = (str) => {
14128
14130
  const lines = str.match(/\n/g);
14129
- if (lines)
14130
- lineno += lines.length;
14131
+ if (lines) lineno += lines.length;
14131
14132
  const i = str.lastIndexOf("\n");
14132
14133
  column = ~i ? str.length - i : column + str.length;
14133
14134
  };
@@ -14194,8 +14195,7 @@ var parseCss = (css, filePath) => {
14194
14195
  const close = () => match(/^}/);
14195
14196
  const match = (re) => {
14196
14197
  const m = re.exec(css);
14197
- if (!m)
14198
- return;
14198
+ if (!m) return;
14199
14199
  const str = m[0];
14200
14200
  updatePosition(str);
14201
14201
  css = css.slice(str.length);
@@ -14223,11 +14223,9 @@ var parseCss = (css, filePath) => {
14223
14223
  };
14224
14224
  const comment = () => {
14225
14225
  const pos = position();
14226
- if ("/" !== css.charAt(0) || "*" !== css.charAt(1))
14227
- return null;
14226
+ if ("/" !== css.charAt(0) || "*" !== css.charAt(1)) return null;
14228
14227
  let i = 2;
14229
- while ("" !== css.charAt(i) && ("*" !== css.charAt(i) || "/" !== css.charAt(i + 1)))
14230
- ++i;
14228
+ while ("" !== css.charAt(i) && ("*" !== css.charAt(i) || "/" !== css.charAt(i + 1))) ++i;
14231
14229
  i += 2;
14232
14230
  if ("" === css.charAt(i - 1)) {
14233
14231
  return error("End of comment missing");
@@ -14244,8 +14242,7 @@ var parseCss = (css, filePath) => {
14244
14242
  };
14245
14243
  const selector = () => {
14246
14244
  const m = match(/^([^{]+)/);
14247
- if (!m)
14248
- return null;
14245
+ if (!m) return null;
14249
14246
  return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, "").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(m2) {
14250
14247
  return m2.replace(/,/g, "\u200C");
14251
14248
  }).split(/\s*(?![^(]*\)),\s*/).map(function(s) {
@@ -14255,11 +14252,9 @@ var parseCss = (css, filePath) => {
14255
14252
  const declaration = () => {
14256
14253
  const pos = position();
14257
14254
  let prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
14258
- if (!prop)
14259
- return null;
14255
+ if (!prop) return null;
14260
14256
  prop = trim(prop[0]);
14261
- if (!match(/^:\s*/))
14262
- return error(`property missing ':'`);
14257
+ if (!match(/^:\s*/)) return error(`property missing ':'`);
14263
14258
  const val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
14264
14259
  const ret = pos({
14265
14260
  type: 4 /* Declaration */,
@@ -14271,16 +14266,14 @@ var parseCss = (css, filePath) => {
14271
14266
  };
14272
14267
  const declarations = () => {
14273
14268
  const decls = [];
14274
- if (!open())
14275
- return error(`missing '{'`);
14269
+ if (!open()) return error(`missing '{'`);
14276
14270
  comments(decls);
14277
14271
  let decl;
14278
14272
  while (decl = declaration()) {
14279
14273
  decls.push(decl);
14280
14274
  comments(decls);
14281
14275
  }
14282
- if (!close())
14283
- return error(`missing '}'`);
14276
+ if (!close()) return error(`missing '}'`);
14284
14277
  return decls;
14285
14278
  };
14286
14279
  const keyframe = () => {
@@ -14291,8 +14284,7 @@ var parseCss = (css, filePath) => {
14291
14284
  values.push(m[1]);
14292
14285
  match(/^,\s*/);
14293
14286
  }
14294
- if (!values.length)
14295
- return null;
14287
+ if (!values.length) return null;
14296
14288
  return pos({
14297
14289
  type: 9 /* KeyFrame */,
14298
14290
  values,
@@ -14302,23 +14294,19 @@ var parseCss = (css, filePath) => {
14302
14294
  const atkeyframes = () => {
14303
14295
  const pos = position();
14304
14296
  let m = match(/^@([-\w]+)?keyframes\s*/);
14305
- if (!m)
14306
- return null;
14297
+ if (!m) return null;
14307
14298
  const vendor = m[1];
14308
14299
  m = match(/^([-\w]+)\s*/);
14309
- if (!m)
14310
- return error(`@keyframes missing name`);
14300
+ if (!m) return error(`@keyframes missing name`);
14311
14301
  const name = m[1];
14312
- if (!open())
14313
- return error(`@keyframes missing '{'`);
14302
+ if (!open()) return error(`@keyframes missing '{'`);
14314
14303
  let frame;
14315
14304
  let frames = comments();
14316
14305
  while (frame = keyframe()) {
14317
14306
  frames.push(frame);
14318
14307
  frames = frames.concat(comments());
14319
14308
  }
14320
- if (!close())
14321
- return error(`@keyframes missing '}'`);
14309
+ if (!close()) return error(`@keyframes missing '}'`);
14322
14310
  return pos({
14323
14311
  type: 8 /* KeyFrames */,
14324
14312
  name,
@@ -14329,14 +14317,11 @@ var parseCss = (css, filePath) => {
14329
14317
  const atsupports = () => {
14330
14318
  const pos = position();
14331
14319
  const m = match(/^@supports *([^{]+)/);
14332
- if (!m)
14333
- return null;
14320
+ if (!m) return null;
14334
14321
  const supports = trim(m[1]);
14335
- if (!open())
14336
- return error(`@supports missing '{'`);
14322
+ if (!open()) return error(`@supports missing '{'`);
14337
14323
  const style = comments().concat(rules());
14338
- if (!close())
14339
- return error(`@supports missing '}'`);
14324
+ if (!close()) return error(`@supports missing '}'`);
14340
14325
  return pos({
14341
14326
  type: 15 /* Supports */,
14342
14327
  supports,
@@ -14346,13 +14331,10 @@ var parseCss = (css, filePath) => {
14346
14331
  const athost = () => {
14347
14332
  const pos = position();
14348
14333
  const m = match(/^@host\s*/);
14349
- if (!m)
14350
- return null;
14351
- if (!open())
14352
- return error(`@host missing '{'`);
14334
+ if (!m) return null;
14335
+ if (!open()) return error(`@host missing '{'`);
14353
14336
  const style = comments().concat(rules());
14354
- if (!close())
14355
- return error(`@host missing '}'`);
14337
+ if (!close()) return error(`@host missing '}'`);
14356
14338
  return pos({
14357
14339
  type: 6 /* Host */,
14358
14340
  rules: style
@@ -14361,14 +14343,11 @@ var parseCss = (css, filePath) => {
14361
14343
  const atmedia = () => {
14362
14344
  const pos = position();
14363
14345
  const m = match(/^@media *([^{]+)/);
14364
- if (!m)
14365
- return null;
14346
+ if (!m) return null;
14366
14347
  const media = trim(m[1]);
14367
- if (!open())
14368
- return error(`@media missing '{'`);
14348
+ if (!open()) return error(`@media missing '{'`);
14369
14349
  const style = comments().concat(rules());
14370
- if (!close())
14371
- return error(`@media missing '}'`);
14350
+ if (!close()) return error(`@media missing '}'`);
14372
14351
  return pos({
14373
14352
  type: 10 /* Media */,
14374
14353
  media,
@@ -14378,8 +14357,7 @@ var parseCss = (css, filePath) => {
14378
14357
  const atcustommedia = () => {
14379
14358
  const pos = position();
14380
14359
  const m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
14381
- if (!m)
14382
- return null;
14360
+ if (!m) return null;
14383
14361
  return pos({
14384
14362
  type: 2 /* CustomMedia */,
14385
14363
  name: trim(m[1]),
@@ -14389,19 +14367,16 @@ var parseCss = (css, filePath) => {
14389
14367
  const atpage = () => {
14390
14368
  const pos = position();
14391
14369
  const m = match(/^@page */);
14392
- if (!m)
14393
- return null;
14370
+ if (!m) return null;
14394
14371
  const sel = selector() || [];
14395
- if (!open())
14396
- return error(`@page missing '{'`);
14372
+ if (!open()) return error(`@page missing '{'`);
14397
14373
  let decls = comments();
14398
14374
  let decl;
14399
14375
  while (decl = declaration()) {
14400
14376
  decls.push(decl);
14401
14377
  decls = decls.concat(comments());
14402
14378
  }
14403
- if (!close())
14404
- return error(`@page missing '}'`);
14379
+ if (!close()) return error(`@page missing '}'`);
14405
14380
  return pos({
14406
14381
  type: 12 /* Page */,
14407
14382
  selectors: sel,
@@ -14411,15 +14386,12 @@ var parseCss = (css, filePath) => {
14411
14386
  const atdocument = () => {
14412
14387
  const pos = position();
14413
14388
  const m = match(/^@([-\w]+)?document *([^{]+)/);
14414
- if (!m)
14415
- return null;
14389
+ if (!m) return null;
14416
14390
  const vendor = trim(m[1]);
14417
14391
  const doc = trim(m[2]);
14418
- if (!open())
14419
- return error(`@document missing '{'`);
14392
+ if (!open()) return error(`@document missing '{'`);
14420
14393
  const style = comments().concat(rules());
14421
- if (!close())
14422
- return error(`@document missing '}'`);
14394
+ if (!close()) return error(`@document missing '}'`);
14423
14395
  return pos({
14424
14396
  type: 3 /* Document */,
14425
14397
  document: doc,
@@ -14430,18 +14402,15 @@ var parseCss = (css, filePath) => {
14430
14402
  const atfontface = () => {
14431
14403
  const pos = position();
14432
14404
  const m = match(/^@font-face\s*/);
14433
- if (!m)
14434
- return null;
14435
- if (!open())
14436
- return error(`@font-face missing '{'`);
14405
+ if (!m) return null;
14406
+ if (!open()) return error(`@font-face missing '{'`);
14437
14407
  let decls = comments();
14438
14408
  let decl;
14439
14409
  while (decl = declaration()) {
14440
14410
  decls.push(decl);
14441
14411
  decls = decls.concat(comments());
14442
14412
  }
14443
- if (!close())
14444
- return error(`@font-face missing '}'`);
14413
+ if (!close()) return error(`@font-face missing '}'`);
14445
14414
  return pos({
14446
14415
  type: 5 /* FontFace */,
14447
14416
  declarations: decls
@@ -14452,8 +14421,7 @@ var parseCss = (css, filePath) => {
14452
14421
  return () => {
14453
14422
  const pos = position();
14454
14423
  const m = match(re);
14455
- if (!m)
14456
- return null;
14424
+ if (!m) return null;
14457
14425
  const node = {
14458
14426
  type: nodeType
14459
14427
  };
@@ -14465,15 +14433,13 @@ var parseCss = (css, filePath) => {
14465
14433
  const atcharset = compileAtrule("charset", 0 /* Charset */);
14466
14434
  const atnamespace = compileAtrule("namespace", 11 /* Namespace */);
14467
14435
  const atrule = () => {
14468
- if (css[0] !== "@")
14469
- return null;
14436
+ if (css[0] !== "@") return null;
14470
14437
  return atkeyframes() || atmedia() || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface();
14471
14438
  };
14472
14439
  const rule = () => {
14473
14440
  const pos = position();
14474
14441
  const sel = selector();
14475
- if (!sel)
14476
- return error("selector missing");
14442
+ if (!sel) return error("selector missing");
14477
14443
  comments();
14478
14444
  return pos({
14479
14445
  type: 13 /* Rule */,
@@ -14527,8 +14493,7 @@ var getCssSelectors = (sel) => {
14527
14493
  const items = sel.split(" ");
14528
14494
  for (let i = 0, l = items.length; i < l; i++) {
14529
14495
  items[i] = items[i].split(":")[0];
14530
- if (items[i].length === 0)
14531
- continue;
14496
+ if (items[i].length === 0) continue;
14532
14497
  if (items[i].charAt(0) === ".") {
14533
14498
  SELECTORS.classNames.push(items[i].slice(1));
14534
14499
  } else if (items[i].charAt(0) === "#") {
@@ -14541,10 +14506,8 @@ var getCssSelectors = (sel) => {
14541
14506
  }
14542
14507
  }
14543
14508
  SELECTORS.classNames = SELECTORS.classNames.sort((a, b) => {
14544
- if (a.length < b.length)
14545
- return -1;
14546
- if (a.length > b.length)
14547
- return 1;
14509
+ if (a.length < b.length) return -1;
14510
+ if (a.length > b.length) return 1;
14548
14511
  return 0;
14549
14512
  });
14550
14513
  return SELECTORS;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal",
3
- "version": "4.18.0",
3
+ "version": "4.18.1",
4
4
  "description": "Stencil internals only to be imported by the Stencil Compiler. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -1,5 +1,6 @@
1
1
  import type { ConfigFlags } from '../cli/config-flags';
2
2
  import type { PrerenderUrlResults, PrintLine } from '../internal';
3
+ import type { BuildCtx, CompilerCtx } from './stencil-private';
3
4
  import type { JsonDocs } from './stencil-public-docs';
4
5
  export * from './stencil-public-docs';
5
6
  /**
@@ -300,6 +301,7 @@ interface ConfigExtrasBase {
300
301
  * It is possible to assign data to the actual `<script>` element's `data-opts` property,
301
302
  * which then gets passed to Stencil's initial bootstrap. This feature is only required
302
303
  * for very special cases and rarely needed. Defaults to `false`.
304
+ * @deprecated This option has been deprecated and will be removed in a future major version of Stencil.
303
305
  */
304
306
  scriptDataOpts?: boolean;
305
307
  /**
@@ -2031,8 +2033,17 @@ export interface OutputTargetHydrate extends OutputTargetBase {
2031
2033
  export interface OutputTargetCustom extends OutputTargetBase {
2032
2034
  type: 'custom';
2033
2035
  name: string;
2036
+ /**
2037
+ * Indicate when the output target should be executed.
2038
+ *
2039
+ * - `"onBuildOnly"`: Executed only when `stencil build` is called without `--watch`.
2040
+ * - `"always"`: Executed on every build, including in `watch` mode.
2041
+ *
2042
+ * Defaults to "always".
2043
+ */
2044
+ taskShouldRun?: 'onBuildOnly' | 'always';
2034
2045
  validate?: (config: Config, diagnostics: Diagnostic[]) => void;
2035
- generator: (config: Config, compilerCtx: any, buildCtx: any, docs: any) => Promise<void>;
2046
+ generator: (config: Config, compilerCtx: CompilerCtx, buildCtx: BuildCtx, docs: JsonDocs) => Promise<void>;
2036
2047
  copy?: CopyTask[];
2037
2048
  }
2038
2049
  /**
@@ -768,6 +768,7 @@ export declare namespace JSXBase {
768
768
  hrefLang?: string;
769
769
  hreflang?: string;
770
770
  media?: string;
771
+ ping?: string;
771
772
  rel?: string;
772
773
  target?: string;
773
774
  referrerPolicy?: ReferrerPolicy;
@@ -927,7 +927,7 @@ var checkSlotFallbackVisibility = false;
927
927
  var checkSlotRelocate = false;
928
928
  var isSvgMode = false;
929
929
  var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
930
- var _a, _b, _c, _d;
930
+ var _a;
931
931
  const newVNode2 = newParentVNode.$children$[childIndex];
932
932
  let i2 = 0;
933
933
  let elm;
@@ -979,13 +979,6 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
979
979
  if ((import_app_data10.BUILD.shadowDom || import_app_data10.BUILD.scoped) && isDef(scopeId) && elm["s-si"] !== scopeId) {
980
980
  elm.classList.add(elm["s-si"] = scopeId);
981
981
  }
982
- if (import_app_data10.BUILD.scoped) {
983
- 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"]);
984
- if (rootScopeId) {
985
- elm["s-rsc"] = rootScopeId;
986
- !elm.classList.contains(rootScopeId) && elm.classList.add(rootScopeId);
987
- }
988
- }
989
982
  if (newVNode2.$children$) {
990
983
  for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
991
984
  childNode = createElm(oldParentVNode, newVNode2, i2, elm);
@@ -1008,7 +1001,7 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
1008
1001
  elm["s-sr"] = true;
1009
1002
  elm["s-cr"] = contentRef;
1010
1003
  elm["s-sn"] = newVNode2.$name$ || "";
1011
- elm["s-rf"] = (_d = newVNode2.$attrs$) == null ? void 0 : _d.ref;
1004
+ elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
1012
1005
  oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
1013
1006
  if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
1014
1007
  if (import_app_data10.BUILD.experimentalSlotFixes) {
@@ -1029,7 +1022,7 @@ var relocateToHostRoot = (parentElm) => {
1029
1022
  const childNodeArray = Array.from(parentElm.childNodes);
1030
1023
  for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
1031
1024
  if (childNode["s-sh"] != null) {
1032
- host.insertBefore(childNode, contentRefNode != null ? contentRefNode : null);
1025
+ insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
1033
1026
  childNode["s-sh"] = void 0;
1034
1027
  checkSlotRelocate = true;
1035
1028
  }
@@ -1051,7 +1044,7 @@ var putBackInOriginalLocation = (parentElm, recursive) => {
1051
1044
  for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
1052
1045
  const childNode = oldSlotChildNodes[i2];
1053
1046
  if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
1054
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
1047
+ insertBefore(parentReferenceNode(childNode), childNode, referenceNode(childNode));
1055
1048
  childNode["s-ol"].remove();
1056
1049
  childNode["s-ol"] = void 0;
1057
1050
  childNode["s-sh"] = void 0;
@@ -1074,7 +1067,7 @@ var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1074
1067
  childNode = createElm(null, parentVNode, startIdx, parentElm);
1075
1068
  if (childNode) {
1076
1069
  vnodes[startIdx].$elm$ = childNode;
1077
- containerElm.insertBefore(childNode, import_app_data10.BUILD.slotRelocation ? referenceNode(before) : before);
1070
+ insertBefore(containerElm, childNode, import_app_data10.BUILD.slotRelocation ? referenceNode(before) : before);
1078
1071
  }
1079
1072
  }
1080
1073
  }
@@ -1134,7 +1127,7 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
1134
1127
  putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1135
1128
  }
1136
1129
  patch(oldStartVnode, newEndVnode, isInitialRender);
1137
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1130
+ insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1138
1131
  oldStartVnode = oldCh[++oldStartIdx];
1139
1132
  newEndVnode = newCh[--newEndIdx];
1140
1133
  } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
@@ -1142,7 +1135,7 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
1142
1135
  putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1143
1136
  }
1144
1137
  patch(oldEndVnode, newStartVnode, isInitialRender);
1145
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1138
+ insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
1146
1139
  oldEndVnode = oldCh[--oldEndIdx];
1147
1140
  newStartVnode = newCh[++newStartIdx];
1148
1141
  } else {
@@ -1171,9 +1164,9 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
1171
1164
  }
1172
1165
  if (node) {
1173
1166
  if (import_app_data10.BUILD.slotRelocation) {
1174
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
1167
+ insertBefore(parentReferenceNode(oldStartVnode.$elm$), node, referenceNode(oldStartVnode.$elm$));
1175
1168
  } else {
1176
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1169
+ insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1177
1170
  }
1178
1171
  }
1179
1172
  }
@@ -1344,6 +1337,28 @@ var nullifyVNodeRefs = (vNode) => {
1344
1337
  vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1345
1338
  }
1346
1339
  };
1340
+ var insertBefore = (parent, newNode, reference) => {
1341
+ const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
1342
+ if (import_app_data10.BUILD.scoped) {
1343
+ setParentScopeIdAsClassName(newNode, parent);
1344
+ }
1345
+ return inserted;
1346
+ };
1347
+ var findParentScopeId = (element) => {
1348
+ return element ? element["s-rsc"] || element["s-si"] || element["s-sc"] || findParentScopeId(element.parentElement) : void 0;
1349
+ };
1350
+ var setParentScopeIdAsClassName = (element, parent) => {
1351
+ var _a, _b, _c;
1352
+ if (element && parent) {
1353
+ const oldRootScopeId = element["s-rsc"];
1354
+ const newRootScopeId = findParentScopeId(parent);
1355
+ oldRootScopeId && ((_a = element.classList) == null ? void 0 : _a.contains(oldRootScopeId)) && element.classList.remove(oldRootScopeId);
1356
+ if (newRootScopeId) {
1357
+ element["s-rsc"] = newRootScopeId;
1358
+ !((_b = element.classList) == null ? void 0 : _b.contains(newRootScopeId)) && ((_c = element.classList) == null ? void 0 : _c.add(newRootScopeId));
1359
+ }
1360
+ }
1361
+ };
1347
1362
  var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1348
1363
  var _a, _b, _c, _d, _e;
1349
1364
  const hostElm = hostRef.$hostElement$;
@@ -1400,7 +1415,7 @@ render() {
1400
1415
  if (!nodeToRelocate["s-ol"]) {
1401
1416
  const orgLocationNode = import_app_data10.BUILD.isDebug || import_app_data10.BUILD.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
1402
1417
  orgLocationNode["s-nr"] = nodeToRelocate;
1403
- nodeToRelocate.parentNode.insertBefore(nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
1418
+ insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
1404
1419
  }
1405
1420
  }
1406
1421
  for (const relocateData of relocateNodes) {
@@ -1431,7 +1446,7 @@ render() {
1431
1446
  if (!import_app_data10.BUILD.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
1432
1447
  nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
1433
1448
  }
1434
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1449
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
1435
1450
  if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1436
1451
  nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
1437
1452
  }
@@ -1743,6 +1758,11 @@ var serverSideConnected = (elm) => {
1743
1758
  var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1744
1759
  var setValue = (ref, propName, newVal, cmpMeta) => {
1745
1760
  const hostRef = getHostRef(ref);
1761
+ if (import_app_data12.BUILD.lazyLoad && !hostRef) {
1762
+ throw new Error(
1763
+ `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).`
1764
+ );
1765
+ }
1746
1766
  const elm = import_app_data12.BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
1747
1767
  const oldVal = hostRef.$instanceValues$.get(propName);
1748
1768
  const flags = hostRef.$flags$;
@@ -2065,7 +2085,7 @@ var setContentReference = (elm) => {
2065
2085
  import_app_data15.BUILD.isDebug ? `content-ref (host=${elm.localName})` : ""
2066
2086
  );
2067
2087
  contentRefElm["s-cn"] = true;
2068
- elm.insertBefore(contentRefElm, elm.firstChild);
2088
+ insertBefore(elm, contentRefElm, elm.firstChild);
2069
2089
  };
2070
2090
 
2071
2091
  // src/runtime/disconnected-callback.ts
@@ -2134,7 +2154,8 @@ var patchCloneNode = (HostElementPrototype) => {
2134
2154
  "s-ol",
2135
2155
  "s-nr",
2136
2156
  "s-si",
2137
- "s-rf"
2157
+ "s-rf",
2158
+ "s-rsc"
2138
2159
  ];
2139
2160
  for (; i2 < srcNode.childNodes.length; i2++) {
2140
2161
  slotted = srcNode.childNodes[i2]["s-nr"];
@@ -2162,7 +2183,7 @@ var patchSlotAppendChild = (HostElementPrototype) => {
2162
2183
  if (slotNode) {
2163
2184
  const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2164
2185
  const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2165
- const insertedNode = appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2186
+ const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
2166
2187
  updateFallbackSlotVisibility(this);
2167
2188
  return insertedNode;
2168
2189
  }
@@ -2203,7 +2224,7 @@ var patchSlotPrepend = (HostElementPrototype) => {
2203
2224
  newChild["s-ol"] = slotPlaceholder;
2204
2225
  const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2205
2226
  const appendAfter = slotChildNodes[0];
2206
- return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2227
+ return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
2207
2228
  }
2208
2229
  if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
2209
2230
  newChild.hidden = true;
@@ -2301,7 +2322,7 @@ var patchTextContent = (hostElementPrototype) => {
2301
2322
  if (node["s-sn"] === "") {
2302
2323
  const textNode = this.ownerDocument.createTextNode(value);
2303
2324
  textNode["s-sn"] = "";
2304
- node.parentElement.insertBefore(textNode, node.nextSibling);
2325
+ insertBefore(node.parentElement, textNode, node.nextSibling);
2305
2326
  } else {
2306
2327
  node.remove();
2307
2328
  }
@@ -2332,7 +2353,7 @@ var patchTextContent = (hostElementPrototype) => {
2332
2353
  this.__textContent = value;
2333
2354
  const contentRefElm = this["s-cr"];
2334
2355
  if (contentRefElm) {
2335
- this.insertBefore(contentRefElm, this.firstChild);
2356
+ insertBefore(this, contentRefElm, this.firstChild);
2336
2357
  }
2337
2358
  }
2338
2359
  }
@@ -2726,14 +2747,10 @@ var hostListenerProxy = (hostRef, methodName) => (ev) => {
2726
2747
  }
2727
2748
  };
2728
2749
  var getHostListenerTarget = (elm, flags) => {
2729
- if (import_app_data20.BUILD.hostListenerTargetDocument && flags & 4 /* TargetDocument */)
2730
- return doc;
2731
- if (import_app_data20.BUILD.hostListenerTargetWindow && flags & 8 /* TargetWindow */)
2732
- return win;
2733
- if (import_app_data20.BUILD.hostListenerTargetBody && flags & 16 /* TargetBody */)
2734
- return doc.body;
2735
- if (import_app_data20.BUILD.hostListenerTargetParent && flags & 32 /* TargetParent */)
2736
- return elm.parentElement;
2750
+ if (import_app_data20.BUILD.hostListenerTargetDocument && flags & 4 /* TargetDocument */) return doc;
2751
+ if (import_app_data20.BUILD.hostListenerTargetWindow && flags & 8 /* TargetWindow */) return win;
2752
+ if (import_app_data20.BUILD.hostListenerTargetBody && flags & 16 /* TargetBody */) return doc.body;
2753
+ if (import_app_data20.BUILD.hostListenerTargetParent && flags & 32 /* TargetParent */) return elm.parentElement;
2737
2754
  return elm;
2738
2755
  };
2739
2756
  var hostListenerOpts = (flags) => supportsListenerOptions ? {
@@ -2758,7 +2775,7 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
2758
2775
  const orgLocationNodes = [];
2759
2776
  parseVNodeAnnotations(doc2, doc2.body, docData, orgLocationNodes);
2760
2777
  orgLocationNodes.forEach((orgLocationNode) => {
2761
- var _a, _b;
2778
+ var _a;
2762
2779
  if (orgLocationNode != null && orgLocationNode["s-nr"]) {
2763
2780
  const nodeRef = orgLocationNode["s-nr"];
2764
2781
  let hostId = nodeRef["s-host-id"];
@@ -2781,7 +2798,7 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
2781
2798
  }
2782
2799
  const commentBeforeTextNode = doc2.createComment(childId);
2783
2800
  commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2784
- (_b = nodeRef.parentNode) == null ? void 0 : _b.insertBefore(commentBeforeTextNode, nodeRef);
2801
+ insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
2785
2802
  }
2786
2803
  }
2787
2804
  let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
@@ -2866,7 +2883,7 @@ var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, ind
2866
2883
  if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
2867
2884
  const textNodeId = `${TEXT_NODE_ID}.${childId}`;
2868
2885
  const commentBeforeTextNode = doc2.createComment(textNodeId);
2869
- parentNode == null ? void 0 : parentNode.insertBefore(commentBeforeTextNode, childElm);
2886
+ insertBefore(parentNode, commentBeforeTextNode, childElm);
2870
2887
  }
2871
2888
  } else if (childElm.nodeType === 8 /* CommentNode */) {
2872
2889
  if (childElm["s-sr"]) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/testing",
3
- "version": "4.18.0",
3
+ "version": "4.18.1",
4
4
  "description": "Stencil internal testing 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