@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/testing",
3
- "version": "4.18.3",
3
+ "version": "4.19.0",
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
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Mock Doc (CommonJS) v4.18.3 | MIT Licensed | https://stenciljs.com
2
+ Stencil Mock Doc (CommonJS) v4.19.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  "use strict";
5
5
  var __defProp = Object.defineProperty;
@@ -6270,67 +6270,50 @@ function humanReadableList(items) {
6270
6270
  }
6271
6271
 
6272
6272
  // src/mock-doc/serialize-node.ts
6273
- function serializeNodeToHtml(elm, opts = {}) {
6273
+ function normalizeSerializationOptions(opts = {}) {
6274
+ return {
6275
+ ...opts,
6276
+ outerHtml: typeof opts.outerHtml !== "boolean" ? false : opts.outerHtml,
6277
+ ...opts.prettyHtml ? {
6278
+ indentSpaces: typeof opts.indentSpaces !== "number" ? 2 : opts.indentSpaces,
6279
+ newLines: typeof opts.newLines !== "boolean" ? true : opts.newLines
6280
+ } : {
6281
+ prettyHtml: false,
6282
+ indentSpaces: typeof opts.indentSpaces !== "number" ? 0 : opts.indentSpaces,
6283
+ newLines: typeof opts.newLines !== "boolean" ? false : opts.newLines
6284
+ },
6285
+ approximateLineWidth: typeof opts.approximateLineWidth !== "number" ? -1 : opts.approximateLineWidth,
6286
+ removeEmptyAttributes: typeof opts.removeEmptyAttributes !== "boolean" ? true : opts.removeEmptyAttributes,
6287
+ removeAttributeQuotes: typeof opts.removeAttributeQuotes !== "boolean" ? false : opts.removeAttributeQuotes,
6288
+ removeBooleanAttributeQuotes: typeof opts.removeBooleanAttributeQuotes !== "boolean" ? false : opts.removeBooleanAttributeQuotes,
6289
+ removeHtmlComments: typeof opts.removeHtmlComments !== "boolean" ? false : opts.removeHtmlComments,
6290
+ serializeShadowRoot: typeof opts.serializeShadowRoot !== "boolean" ? false : opts.serializeShadowRoot,
6291
+ fullDocument: typeof opts.fullDocument !== "boolean" ? true : opts.fullDocument
6292
+ };
6293
+ }
6294
+ function serializeNodeToHtml(elm, serializationOptions = {}) {
6295
+ const opts = normalizeSerializationOptions(serializationOptions);
6274
6296
  const output = {
6275
6297
  currentLineWidth: 0,
6276
6298
  indent: 0,
6277
6299
  isWithinBody: false,
6278
6300
  text: []
6279
6301
  };
6280
- if (opts.prettyHtml) {
6281
- if (typeof opts.indentSpaces !== "number") {
6282
- opts.indentSpaces = 2;
6283
- }
6284
- if (typeof opts.newLines !== "boolean") {
6285
- opts.newLines = true;
6286
- }
6287
- opts.approximateLineWidth = -1;
6288
- } else {
6289
- opts.prettyHtml = false;
6290
- if (typeof opts.newLines !== "boolean") {
6291
- opts.newLines = false;
6292
- }
6293
- if (typeof opts.indentSpaces !== "number") {
6294
- opts.indentSpaces = 0;
6295
- }
6296
- }
6297
- if (typeof opts.approximateLineWidth !== "number") {
6298
- opts.approximateLineWidth = -1;
6299
- }
6300
- if (typeof opts.removeEmptyAttributes !== "boolean") {
6301
- opts.removeEmptyAttributes = true;
6302
- }
6303
- if (typeof opts.removeAttributeQuotes !== "boolean") {
6304
- opts.removeAttributeQuotes = false;
6305
- }
6306
- if (typeof opts.removeBooleanAttributeQuotes !== "boolean") {
6307
- opts.removeBooleanAttributeQuotes = false;
6308
- }
6309
- if (typeof opts.removeHtmlComments !== "boolean") {
6310
- opts.removeHtmlComments = false;
6311
- }
6312
- if (typeof opts.serializeShadowRoot !== "boolean") {
6313
- opts.serializeShadowRoot = false;
6314
- }
6315
- if (opts.outerHtml) {
6316
- serializeToHtml(elm, opts, output, false);
6317
- } else {
6318
- for (let i = 0, ii = elm.childNodes.length; i < ii; i++) {
6319
- serializeToHtml(elm.childNodes[i], opts, output, false);
6320
- }
6321
- }
6322
- if (output.text[0] === "\n") {
6323
- output.text.shift();
6324
- }
6325
- if (output.text[output.text.length - 1] === "\n") {
6326
- output.text.pop();
6302
+ let renderedNode = "";
6303
+ const children = !opts.fullDocument && elm.body ? Array.from(elm.body.childNodes) : opts.outerHtml ? [elm] : Array.from(elm.childNodes);
6304
+ for (let i = 0, ii = children.length; i < ii; i++) {
6305
+ const child = children[i];
6306
+ const chunks = Array.from(streamToHtml(child, opts, output));
6307
+ renderedNode += chunks.join("");
6327
6308
  }
6328
- return output.text.join("");
6309
+ return renderedNode.trim();
6329
6310
  }
6330
- function serializeToHtml(node, opts, output, isShadowRoot) {
6311
+ var shadowRootTag = "mock:shadow-root";
6312
+ function* streamToHtml(node, opts, output) {
6331
6313
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
6314
+ const isShadowRoot = node.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */;
6332
6315
  if (node.nodeType === 1 /* ELEMENT_NODE */ || isShadowRoot) {
6333
- const tagName = isShadowRoot ? "mock:shadow-root" : getTagName(node);
6316
+ const tagName = isShadowRoot ? shadowRootTag : getTagName(node);
6334
6317
  if (tagName === "body") {
6335
6318
  output.isWithinBody = true;
6336
6319
  }
@@ -6338,17 +6321,23 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
6338
6321
  if (ignoreTag === false) {
6339
6322
  const isWithinWhitespaceSensitiveNode = opts.newLines || ((_a = opts.indentSpaces) != null ? _a : 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
6340
6323
  if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
6341
- output.text.push("\n");
6324
+ yield "\n";
6342
6325
  output.currentLineWidth = 0;
6343
6326
  }
6344
6327
  if (((_b = opts.indentSpaces) != null ? _b : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
6345
6328
  for (let i = 0; i < output.indent; i++) {
6346
- output.text.push(" ");
6329
+ yield " ";
6347
6330
  }
6348
6331
  output.currentLineWidth += output.indent;
6349
6332
  }
6350
- output.text.push("<" + tagName);
6351
- output.currentLineWidth += tagName.length + 1;
6333
+ const tag = tagName === shadowRootTag ? "template" : tagName;
6334
+ yield "<" + tag;
6335
+ output.currentLineWidth += tag.length + 1;
6336
+ if (tag === "template") {
6337
+ const mode = ` shadowrootmode="open"`;
6338
+ yield mode;
6339
+ output.currentLineWidth += mode.length;
6340
+ }
6352
6341
  const attrsLength = node.attributes.length;
6353
6342
  const attributes = opts.prettyHtml && attrsLength > 1 ? cloneAttributes(node.attributes, true) : node.attributes;
6354
6343
  for (let i = 0; i < attrsLength; i++) {
@@ -6365,27 +6354,27 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
6365
6354
  if (attrNamespaceURI == null) {
6366
6355
  output.currentLineWidth += attrName.length + 1;
6367
6356
  if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth > opts.approximateLineWidth) {
6368
- output.text.push("\n" + attrName);
6357
+ yield "\n" + attrName;
6369
6358
  output.currentLineWidth = 0;
6370
6359
  } else {
6371
- output.text.push(" " + attrName);
6360
+ yield " " + attrName;
6372
6361
  }
6373
6362
  } else if (attrNamespaceURI === "http://www.w3.org/XML/1998/namespace") {
6374
- output.text.push(" xml:" + attrName);
6363
+ yield " xml:" + attrName;
6375
6364
  output.currentLineWidth += attrName.length + 5;
6376
6365
  } else if (attrNamespaceURI === "http://www.w3.org/2000/xmlns/") {
6377
6366
  if (attrName !== "xmlns") {
6378
- output.text.push(" xmlns:" + attrName);
6367
+ yield " xmlns:" + attrName;
6379
6368
  output.currentLineWidth += attrName.length + 7;
6380
6369
  } else {
6381
- output.text.push(" " + attrName);
6370
+ yield " " + attrName;
6382
6371
  output.currentLineWidth += attrName.length + 1;
6383
6372
  }
6384
6373
  } else if (attrNamespaceURI === XLINK_NS) {
6385
- output.text.push(" xlink:" + attrName);
6374
+ yield " xlink:" + attrName;
6386
6375
  output.currentLineWidth += attrName.length + 7;
6387
6376
  } else {
6388
- output.text.push(" " + attrNamespaceURI + ":" + attrName);
6377
+ yield " " + attrNamespaceURI + ":" + attrName;
6389
6378
  output.currentLineWidth += attrNamespaceURI.length + attrName.length + 2;
6390
6379
  }
6391
6380
  if (opts.prettyHtml && attrName === "class") {
@@ -6400,43 +6389,45 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
6400
6389
  }
6401
6390
  }
6402
6391
  if (opts.removeAttributeQuotes && CAN_REMOVE_ATTR_QUOTES.test(attrValue)) {
6403
- output.text.push("=" + escapeString(attrValue, true));
6392
+ yield "=" + escapeString(attrValue, true);
6404
6393
  output.currentLineWidth += attrValue.length + 1;
6405
6394
  } else {
6406
- output.text.push('="' + escapeString(attrValue, true) + '"');
6395
+ yield '="' + escapeString(attrValue, true) + '"';
6407
6396
  output.currentLineWidth += attrValue.length + 3;
6408
6397
  }
6409
6398
  }
6410
6399
  if (node.hasAttribute("style")) {
6411
6400
  const cssText = node.style.cssText;
6412
6401
  if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth + cssText.length + 10 > opts.approximateLineWidth) {
6413
- output.text.push(`
6414
- style="${cssText}">`);
6402
+ yield `
6403
+ style="${cssText}">`;
6415
6404
  output.currentLineWidth = 0;
6416
6405
  } else {
6417
- output.text.push(` style="${cssText}">`);
6406
+ yield ` style="${cssText}">`;
6418
6407
  output.currentLineWidth += cssText.length + 10;
6419
6408
  }
6420
6409
  } else {
6421
- output.text.push(">");
6410
+ yield ">";
6422
6411
  output.currentLineWidth += 1;
6423
6412
  }
6424
6413
  }
6425
6414
  if (EMPTY_ELEMENTS.has(tagName) === false) {
6426
- if (opts.serializeShadowRoot && node.shadowRoot != null) {
6415
+ const shadowRoot = node.shadowRoot;
6416
+ if (opts.serializeShadowRoot && shadowRoot != null) {
6427
6417
  output.indent = output.indent + ((_c = opts.indentSpaces) != null ? _c : 0);
6428
- serializeToHtml(node.shadowRoot, opts, output, true);
6418
+ yield* streamToHtml(shadowRoot, opts, output);
6429
6419
  output.indent = output.indent - ((_d = opts.indentSpaces) != null ? _d : 0);
6430
6420
  if (opts.newLines && (node.childNodes.length === 0 || node.childNodes.length === 1 && node.childNodes[0].nodeType === 3 /* TEXT_NODE */ && ((_e = node.childNodes[0].nodeValue) == null ? void 0 : _e.trim()) === "")) {
6431
- output.text.push("\n");
6421
+ yield "\n";
6432
6422
  output.currentLineWidth = 0;
6433
6423
  for (let i = 0; i < output.indent; i++) {
6434
- output.text.push(" ");
6424
+ yield " ";
6435
6425
  }
6436
6426
  output.currentLineWidth += output.indent;
6437
6427
  }
6438
6428
  }
6439
6429
  if (opts.excludeTagContent == null || opts.excludeTagContent.includes(tagName) === false) {
6430
+ const tag = tagName === shadowRootTag ? "template" : tagName;
6440
6431
  const childNodes = tagName === "template" ? node.content.childNodes : node.childNodes;
6441
6432
  const childNodeLength = childNodes.length;
6442
6433
  if (childNodeLength > 0) {
@@ -6447,17 +6438,17 @@ style="${cssText}">`);
6447
6438
  output.indent = output.indent + ((_h = opts.indentSpaces) != null ? _h : 0);
6448
6439
  }
6449
6440
  for (let i = 0; i < childNodeLength; i++) {
6450
- serializeToHtml(childNodes[i], opts, output, false);
6441
+ yield* streamToHtml(childNodes[i], opts, output);
6451
6442
  }
6452
6443
  if (ignoreTag === false) {
6453
6444
  if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
6454
- output.text.push("\n");
6445
+ yield "\n";
6455
6446
  output.currentLineWidth = 0;
6456
6447
  }
6457
6448
  if (((_i = opts.indentSpaces) != null ? _i : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
6458
6449
  output.indent = output.indent - ((_j = opts.indentSpaces) != null ? _j : 0);
6459
6450
  for (let i = 0; i < output.indent; i++) {
6460
- output.text.push(" ");
6451
+ yield " ";
6461
6452
  }
6462
6453
  output.currentLineWidth += output.indent;
6463
6454
  }
@@ -6465,13 +6456,13 @@ style="${cssText}">`);
6465
6456
  }
6466
6457
  }
6467
6458
  if (ignoreTag === false) {
6468
- output.text.push("</" + tagName + ">");
6469
- output.currentLineWidth += tagName.length + 3;
6459
+ yield "</" + tag + ">";
6460
+ output.currentLineWidth += tag.length + 3;
6470
6461
  }
6471
6462
  }
6472
6463
  }
6473
6464
  if (((_k = opts.approximateLineWidth) != null ? _k : 0) > 0 && STRUCTURE_ELEMENTS.has(tagName)) {
6474
- output.text.push("\n");
6465
+ yield "\n";
6475
6466
  output.currentLineWidth = 0;
6476
6467
  }
6477
6468
  if (tagName === "body") {
@@ -6483,27 +6474,27 @@ style="${cssText}">`);
6483
6474
  const trimmedTextContent = textContent.trim();
6484
6475
  if (trimmedTextContent === "") {
6485
6476
  if (isWithinWhitespaceSensitive(node)) {
6486
- output.text.push(textContent);
6477
+ yield textContent;
6487
6478
  output.currentLineWidth += textContent.length;
6488
6479
  } else if (((_l = opts.approximateLineWidth) != null ? _l : 0) > 0 && !output.isWithinBody) {
6489
6480
  } else if (!opts.prettyHtml) {
6490
6481
  output.currentLineWidth += 1;
6491
6482
  if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth > opts.approximateLineWidth) {
6492
- output.text.push("\n");
6483
+ yield "\n";
6493
6484
  output.currentLineWidth = 0;
6494
6485
  } else {
6495
- output.text.push(" ");
6486
+ yield " ";
6496
6487
  }
6497
6488
  }
6498
6489
  } else {
6499
6490
  const isWithinWhitespaceSensitiveNode = opts.newLines || ((_m = opts.indentSpaces) != null ? _m : 0) > 0 || opts.prettyHtml ? isWithinWhitespaceSensitive(node) : false;
6500
6491
  if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
6501
- output.text.push("\n");
6492
+ yield "\n";
6502
6493
  output.currentLineWidth = 0;
6503
6494
  }
6504
6495
  if (((_n = opts.indentSpaces) != null ? _n : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
6505
6496
  for (let i = 0; i < output.indent; i++) {
6506
- output.text.push(" ");
6497
+ yield " ";
6507
6498
  }
6508
6499
  output.currentLineWidth += output.indent;
6509
6500
  }
@@ -6512,15 +6503,15 @@ style="${cssText}">`);
6512
6503
  const parentTagName = node.parentNode != null && node.parentNode.nodeType === 1 /* ELEMENT_NODE */ ? node.parentNode.nodeName : null;
6513
6504
  if (typeof parentTagName === "string" && NON_ESCAPABLE_CONTENT.has(parentTagName)) {
6514
6505
  if (isWithinWhitespaceSensitive(node)) {
6515
- output.text.push(textContent);
6506
+ yield textContent;
6516
6507
  } else {
6517
- output.text.push(trimmedTextContent);
6508
+ yield trimmedTextContent;
6518
6509
  textContentLength = trimmedTextContent.length;
6519
6510
  }
6520
6511
  output.currentLineWidth += textContentLength;
6521
6512
  } else {
6522
6513
  if (opts.prettyHtml && !isWithinWhitespaceSensitiveNode) {
6523
- output.text.push(escapeString(textContent.replace(/\s\s+/g, " ").trim(), false));
6514
+ yield escapeString(textContent.replace(/\s\s+/g, " ").trim(), false);
6524
6515
  output.currentLineWidth += textContentLength;
6525
6516
  } else {
6526
6517
  if (isWithinWhitespaceSensitive(node)) {
@@ -6542,7 +6533,7 @@ style="${cssText}">`);
6542
6533
  }
6543
6534
  output.currentLineWidth += textContentLength;
6544
6535
  }
6545
- output.text.push(escapeString(textContent, false));
6536
+ yield escapeString(textContent, false);
6546
6537
  }
6547
6538
  }
6548
6539
  }
@@ -6550,27 +6541,27 @@ style="${cssText}">`);
6550
6541
  }
6551
6542
  } else if (node.nodeType === 8 /* COMMENT_NODE */) {
6552
6543
  const nodeValue = node.nodeValue;
6553
- if (opts.removeHtmlComments) {
6554
- const isHydrateAnnotation = (nodeValue == null ? void 0 : nodeValue.startsWith(CONTENT_REF_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(ORG_LOCATION_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(SLOT_NODE_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(TEXT_NODE_ID + "."));
6555
- if (!isHydrateAnnotation) {
6556
- return;
6557
- }
6544
+ const isHydrateAnnotation = (nodeValue == null ? void 0 : nodeValue.startsWith(CONTENT_REF_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(ORG_LOCATION_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(SLOT_NODE_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(TEXT_NODE_ID + "."));
6545
+ if (opts.removeHtmlComments && !isHydrateAnnotation) {
6546
+ return;
6558
6547
  }
6559
6548
  const isWithinWhitespaceSensitiveNode = opts.newLines || ((_o = opts.indentSpaces) != null ? _o : 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
6560
6549
  if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
6561
- output.text.push("\n");
6550
+ yield "\n";
6562
6551
  output.currentLineWidth = 0;
6563
6552
  }
6564
6553
  if (((_p = opts.indentSpaces) != null ? _p : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
6565
6554
  for (let i = 0; i < output.indent; i++) {
6566
- output.text.push(" ");
6555
+ yield " ";
6567
6556
  }
6568
6557
  output.currentLineWidth += output.indent;
6569
6558
  }
6570
- output.text.push("<!--" + nodeValue + "-->");
6571
- output.currentLineWidth += nodeValue.length + 7;
6559
+ yield "<!--" + nodeValue + "-->";
6560
+ if (nodeValue) {
6561
+ output.currentLineWidth += nodeValue.length + 7;
6562
+ }
6572
6563
  } else if (node.nodeType === 10 /* DOCUMENT_TYPE_NODE */) {
6573
- output.text.push("<!doctype html>");
6564
+ yield "<!doctype html>";
6574
6565
  }
6575
6566
  }
6576
6567
  var AMP_REGEX = /&/g;
@@ -6595,7 +6586,7 @@ function escapeString(str, attrMode) {
6595
6586
  }
6596
6587
  function isWithinWhitespaceSensitive(node) {
6597
6588
  let _node = node;
6598
- while (_node != null) {
6589
+ while (_node == null ? void 0 : _node.nodeName) {
6599
6590
  if (WHITESPACE_SENSITIVE.has(_node.nodeName)) {
6600
6591
  return true;
6601
6592
  }
@@ -6911,6 +6902,10 @@ Testing components with ElementInternals is fully supported in e2e tests.`
6911
6902
  get shadowRoot() {
6912
6903
  return this.__shadowRoot || null;
6913
6904
  }
6905
+ /**
6906
+ * Set shadow root for element
6907
+ * @param shadowRoot - ShadowRoot to set
6908
+ */
6914
6909
  set shadowRoot(shadowRoot) {
6915
6910
  if (shadowRoot != null) {
6916
6911
  shadowRoot.host = this;
@@ -8740,14 +8735,16 @@ var WINDOW_PROPS = [
8740
8735
  ];
8741
8736
  var GLOBAL_CONSTRUCTORS = [
8742
8737
  ["CustomEvent", MockCustomEvent],
8738
+ ["DocumentFragment", MockDocumentFragment],
8739
+ ["DOMParser", MockDOMParser],
8743
8740
  ["Event", MockEvent],
8744
- ["Headers", MockHeaders],
8745
8741
  ["FocusEvent", MockFocusEvent],
8742
+ ["Headers", MockHeaders],
8746
8743
  ["KeyboardEvent", MockKeyboardEvent],
8747
8744
  ["MouseEvent", MockMouseEvent],
8748
8745
  ["Request", MockRequest],
8749
8746
  ["Response", MockResponse],
8750
- ["DOMParser", MockDOMParser],
8747
+ ["ShadowRoot", MockDocumentFragment],
8751
8748
  ["HTMLAnchorElement", MockAnchorElement],
8752
8749
  ["HTMLBaseElement", MockBaseElement],
8753
8750
  ["HTMLButtonElement", MockButtonElement],
@@ -8958,6 +8955,7 @@ var nativeClearTimeout = clearTimeout;
8958
8955
  var nativeSetInterval = setInterval;
8959
8956
  var nativeSetTimeout = setTimeout;
8960
8957
  var nativeURL = URL;
8958
+ var nativeWindow = globalThis.window;
8961
8959
  var MockWindow = class {
8962
8960
  constructor(html = null) {
8963
8961
  if (html !== false) {
@@ -8984,10 +8982,10 @@ var MockWindow = class {
8984
8982
  blur() {
8985
8983
  }
8986
8984
  cancelAnimationFrame(id) {
8987
- this.__clearTimeout(id);
8985
+ this.__clearTimeout.call(nativeWindow || this, id);
8988
8986
  }
8989
8987
  cancelIdleCallback(id) {
8990
- this.__clearTimeout(id);
8988
+ this.__clearTimeout.call(nativeWindow || this, id);
8991
8989
  }
8992
8990
  get CharacterData() {
8993
8991
  if (this.__charDataCstr == null) {
@@ -9005,10 +9003,10 @@ var MockWindow = class {
9005
9003
  this.__charDataCstr = charDataCstr;
9006
9004
  }
9007
9005
  clearInterval(id) {
9008
- this.__clearInterval(id);
9006
+ this.__clearInterval.call(nativeWindow || this, id);
9009
9007
  }
9010
9008
  clearTimeout(id) {
9011
- this.__clearTimeout(id);
9009
+ this.__clearTimeout.call(nativeWindow || this, id);
9012
9010
  }
9013
9011
  close() {
9014
9012
  resetWindow(this);
@@ -9308,20 +9306,24 @@ var MockWindow = class {
9308
9306
  }
9309
9307
  return intervalId;
9310
9308
  }
9311
- const timeoutId = this.__setTimeout(() => {
9312
- if (this.__timeouts) {
9313
- this.__timeouts.delete(timeoutId);
9314
- try {
9315
- callback(...args);
9316
- } catch (e2) {
9317
- if (this.console) {
9318
- this.console.error(e2);
9319
- } else {
9320
- console.error(e2);
9309
+ const timeoutId = this.__setTimeout.call(
9310
+ nativeWindow || this,
9311
+ () => {
9312
+ if (this.__timeouts) {
9313
+ this.__timeouts.delete(timeoutId);
9314
+ try {
9315
+ callback(...args);
9316
+ } catch (e2) {
9317
+ if (this.console) {
9318
+ this.console.error(e2);
9319
+ } else {
9320
+ console.error(e2);
9321
+ }
9321
9322
  }
9322
9323
  }
9323
- }
9324
- }, ms);
9324
+ },
9325
+ ms
9326
+ );
9325
9327
  if (this.__timeouts) {
9326
9328
  this.__timeouts.add(timeoutId);
9327
9329
  }
@@ -9332,20 +9334,24 @@ var MockWindow = class {
9332
9334
  this.__timeouts = /* @__PURE__ */ new Set();
9333
9335
  }
9334
9336
  ms = Math.min(ms, this.__maxTimeout);
9335
- const timeoutId = this.__setTimeout(() => {
9336
- if (this.__timeouts) {
9337
- this.__timeouts.delete(timeoutId);
9338
- try {
9339
- callback(...args);
9340
- } catch (e2) {
9341
- if (this.console) {
9342
- this.console.error(e2);
9343
- } else {
9344
- console.error(e2);
9337
+ const timeoutId = this.__setTimeout.call(
9338
+ nativeWindow || this,
9339
+ () => {
9340
+ if (this.__timeouts) {
9341
+ this.__timeouts.delete(timeoutId);
9342
+ try {
9343
+ callback(...args);
9344
+ } catch (e2) {
9345
+ if (this.console) {
9346
+ this.console.error(e2);
9347
+ } else {
9348
+ console.error(e2);
9349
+ }
9345
9350
  }
9346
9351
  }
9347
- }
9348
- }, ms);
9352
+ },
9353
+ ms
9354
+ );
9349
9355
  if (this.__timeouts) {
9350
9356
  this.__timeouts.add(timeoutId);
9351
9357
  }
@@ -9562,11 +9568,11 @@ function cloneWindow(srcWin, opts = {}) {
9562
9568
  return clonedWin;
9563
9569
  }
9564
9570
  function cloneDocument(srcDoc) {
9565
- if (srcDoc == null) {
9571
+ if (srcDoc == null || !srcDoc.defaultView) {
9566
9572
  return null;
9567
9573
  }
9568
9574
  const dstWin = cloneWindow(srcDoc.defaultView);
9569
- return dstWin.document;
9575
+ return (dstWin == null ? void 0 : dstWin.document) || null;
9570
9576
  }
9571
9577
  function constrainTimeouts(win) {
9572
9578
  win.__allowInterval = false;
@@ -124,7 +124,7 @@ declare class MockDocument extends MockHTMLElement {
124
124
  defaultView: any;
125
125
  cookie: string;
126
126
  referrer: string;
127
- constructor(html?: string | boolean, win?: any);
127
+ constructor(html?: string | boolean | null, win?: any);
128
128
  get dir(): string;
129
129
  set dir(value: string);
130
130
  get localName(): never;
@@ -538,6 +538,10 @@ declare class MockElement extends MockNode {
538
538
  get localName(): string;
539
539
  get namespaceURI(): string;
540
540
  get shadowRoot(): any;
541
+ /**
542
+ * Set shadow root for element
543
+ * @param shadowRoot - ShadowRoot to set
544
+ */
541
545
  set shadowRoot(shadowRoot: any);
542
546
  get attributes(): MockAttributeMap;
543
547
  set attributes(attrs: MockAttributeMap);
@@ -852,19 +856,28 @@ declare function selectAll(selector: string, elm: MockElement): any;
852
856
  */
853
857
  declare const PROBLEMATIC_SELECTORS: readonly [":scope", ":where", ":is"];
854
858
  /**
855
- * Serialize a node (either a DOM node or a mock-doc node) to an HTML string
859
+ * Serialize a node (either a DOM node or a mock-doc node) to an HTML string.
860
+ * This operation is similar to `outerHTML` but allows for more control over the
861
+ * serialization process. It is fully synchronous meaning that it will not
862
+ * wait for a component to be fully rendered before serializing it. Use `streamToHtml`
863
+ * for a streaming version of this function.
856
864
  *
857
865
  * @param elm the node to serialize
858
- * @param opts options to control serialization behavior
866
+ * @param serializationOptions options to control serialization behavior
859
867
  * @returns an html string
860
868
  */
861
- declare function serializeNodeToHtml(elm: Node | MockNode, opts?: SerializeNodeToHtmlOptions): string;
869
+ declare function serializeNodeToHtml(elm: Node | MockNode, serializationOptions?: SerializeNodeToHtmlOptions): string;
862
870
  declare const NON_ESCAPABLE_CONTENT: Set<string>;
863
871
  /**
864
872
  * A list of whitespace sensitive tag names, such as `code`, `pre`, etc.
865
873
  */
866
874
  declare const WHITESPACE_SENSITIVE: Set<string>;
867
875
  declare const EMPTY_ELEMENTS: Set<string>;
876
+ /**
877
+ * Partially duplicate of https://github.com/ionic-team/stencil/blob/6017dad2cb6fe366242e2e0594f82c8e3a3b5d15/src/declarations/stencil-public-compiler.ts#L895
878
+ * Types can't be imported in this documented as Eslint will not embed the types
879
+ * in the d.ts file.
880
+ */
868
881
  interface SerializeNodeToHtmlOptions {
869
882
  approximateLineWidth?: number;
870
883
  excludeTagContent?: string[];
@@ -878,6 +891,7 @@ interface SerializeNodeToHtmlOptions {
878
891
  removeEmptyAttributes?: boolean;
879
892
  removeHtmlComments?: boolean;
880
893
  serializeShadowRoot?: boolean;
894
+ fullDocument?: boolean;
881
895
  }
882
896
  declare class MockStorage {
883
897
  key(_value: number): void;