@stencil/mock-doc 5.0.0-alpha.4 → 5.0.0-alpha.6

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.
package/dist/index.d.mts CHANGED
@@ -219,7 +219,7 @@ declare class MockWindow {
219
219
  __allowInterval: boolean;
220
220
  URL: typeof URL;
221
221
  console: Console;
222
- customElements: CustomElementRegistry;
222
+ customElements: CustomElementRegistry | null;
223
223
  document: Document;
224
224
  performance: Performance;
225
225
  devicePixelRatio: number;
@@ -433,7 +433,7 @@ declare class MockWindow {
433
433
  onwebkitfullscreenerror(): void;
434
434
  onwheel(): void;
435
435
  }
436
- declare function cloneWindow(srcWin: Window, opts?: {
436
+ declare function cloneWindow(srcWin: Window | MockWindow, opts?: {
437
437
  customElementProxy?: boolean;
438
438
  }): MockWindow | null;
439
439
  declare function cloneDocument(srcDoc: Document): Document;
@@ -442,7 +442,7 @@ declare function cloneDocument(srcDoc: Document): Document;
442
442
  * only allow setInterval() to fire once, also constrained to 1ms.
443
443
  * @param win the mock window instance to update
444
444
  */
445
- declare function constrainTimeouts(win: any): void;
445
+ declare function constrainTimeouts(win: MockWindow): void;
446
446
  //#endregion
447
447
  //#region src/event.d.ts
448
448
  declare class MockEvent {
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
9
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
10
  var __copyProps = (to, from, except, desc) => {
11
11
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
12
  key = keys[i];
@@ -48,13 +48,6 @@ let NODE_TYPES = /* @__PURE__ */ function(NODE_TYPES) {
48
48
  NODE_TYPES[NODE_TYPES["DOCUMENT_FRAGMENT_NODE"] = 11] = "DOCUMENT_FRAGMENT_NODE";
49
49
  return NODE_TYPES;
50
50
  }({});
51
- let NODE_NAMES = /* @__PURE__ */ function(NODE_NAMES) {
52
- NODE_NAMES["COMMENT_NODE"] = "#comment";
53
- NODE_NAMES["DOCUMENT_NODE"] = "#document";
54
- NODE_NAMES["DOCUMENT_FRAGMENT_NODE"] = "#document-fragment";
55
- NODE_NAMES["TEXT_NODE"] = "#text";
56
- return NODE_NAMES;
57
- }({});
58
51
  //#endregion
59
52
  //#region src/attribute.ts
60
53
  const attrHandler = { get(obj, prop) {
@@ -63,6 +56,7 @@ const attrHandler = { get(obj, prop) {
63
56
  } };
64
57
  const createAttributeProxy = (caseInsensitive) => new Proxy(new MockAttributeMap(caseInsensitive), attrHandler);
65
58
  var MockAttributeMap = class {
59
+ caseInsensitive;
66
60
  __items = [];
67
61
  constructor(caseInsensitive = false) {
68
62
  this.caseInsensitive = caseInsensitive;
@@ -285,6 +279,7 @@ function jsCaseToCssCase(str) {
285
279
  //#endregion
286
280
  //#region src/custom-element-registry.ts
287
281
  var MockCustomElementRegistry = class {
282
+ win;
288
283
  __registry;
289
284
  __whenDefined;
290
285
  constructor(win) {
@@ -389,7 +384,7 @@ const proxyElements = /* @__PURE__ */ new WeakMap();
389
384
  const upgradedElements = /* @__PURE__ */ new WeakSet();
390
385
  function connectNode(ownerDocument, node) {
391
386
  node.ownerDocument = ownerDocument;
392
- if (node.nodeType === NODE_TYPES.ELEMENT_NODE) {
387
+ if (node.nodeType === 1) {
393
388
  if (ownerDocument != null && node.nodeName.includes("-")) {
394
389
  if (ownerDocument.defaultView != null && typeof node.connectedCallback === "function" && node.isConnected) fireConnectedCallback(node);
395
390
  const shadowRoot = node.shadowRoot;
@@ -414,7 +409,7 @@ function fireConnectedCallback(node) {
414
409
  }
415
410
  }
416
411
  function disconnectNode(node) {
417
- if (node.nodeType === NODE_TYPES.ELEMENT_NODE) {
412
+ if (node.nodeType === 1) {
418
413
  if (node.nodeName.includes("-") === true && typeof node.disconnectedCallback === "function") {
419
414
  if (tempDisableCallbacks.has(node.ownerDocument) === false) try {
420
415
  node.disconnectedCallback();
@@ -508,7 +503,7 @@ var MockEvent = class {
508
503
  let currentElement = this.target;
509
504
  while (currentElement) {
510
505
  composedPath.push(currentElement);
511
- if (!currentElement.parentElement && currentElement.nodeName === NODE_NAMES.DOCUMENT_NODE) {
506
+ if (!currentElement.parentElement && currentElement.nodeName === "#document") {
512
507
  composedPath.push(currentElement.defaultView);
513
508
  break;
514
509
  }
@@ -639,7 +634,7 @@ function triggerEventListener(elm, ev) {
639
634
  }
640
635
  });
641
636
  if (ev.bubbles === false) return;
642
- if (elm.nodeName === NODE_NAMES.DOCUMENT_NODE) triggerEventListener(elm.defaultView, ev);
637
+ if (elm.nodeName === "#document") triggerEventListener(elm.defaultView, ev);
643
638
  else if (elm.parentElement == null && elm.tagName === "HTML") triggerEventListener(elm.ownerDocument, ev);
644
639
  else triggerEventListener(getNextEventTarget(elm, ev), ev);
645
640
  }
@@ -688,7 +683,7 @@ function getParser(ownerDocument) {
688
683
  if (parseOptions != null) return parseOptions;
689
684
  parseOptions = { treeAdapter: {
690
685
  createDocument() {
691
- const doc = ownerDocument.createElement(NODE_NAMES.DOCUMENT_NODE);
686
+ const doc = ownerDocument.createElement("#document");
692
687
  doc["x-mode"] = "no-quirks";
693
688
  return doc;
694
689
  },
@@ -727,7 +722,7 @@ function getParser(ownerDocument) {
727
722
  return templateElement.content;
728
723
  },
729
724
  setDocumentType(doc, name, publicId, systemId) {
730
- let doctypeNode = doc.childNodes.find((n) => n.nodeType === NODE_TYPES.DOCUMENT_TYPE_NODE);
725
+ let doctypeNode = doc.childNodes.find((n) => n.nodeType === 10);
731
726
  if (doctypeNode == null) {
732
727
  doctypeNode = ownerDocument.createDocumentTypeNode();
733
728
  doc.insertBefore(doctypeNode, doc.firstChild);
@@ -748,12 +743,12 @@ function getParser(ownerDocument) {
748
743
  },
749
744
  insertText(parentNode, text) {
750
745
  const lastChild = parentNode.lastChild;
751
- if (lastChild != null && lastChild.nodeType === NODE_TYPES.TEXT_NODE) lastChild.nodeValue += text;
746
+ if (lastChild != null && lastChild.nodeType === 3) lastChild.nodeValue += text;
752
747
  else parentNode.appendChild(ownerDocument.createTextNode(text));
753
748
  },
754
749
  insertTextBefore(parentNode, text, referenceNode) {
755
750
  const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
756
- if (prevNode != null && prevNode.nodeType === NODE_TYPES.TEXT_NODE) prevNode.nodeValue += text;
751
+ if (prevNode != null && prevNode.nodeType === 3) prevNode.nodeValue += text;
757
752
  else parentNode.insertBefore(ownerDocument.createTextNode(text), referenceNode);
758
753
  },
759
754
  adoptAttributes(recipient, attrs) {
@@ -805,16 +800,16 @@ function getParser(ownerDocument) {
805
800
  return doctypeNode["x-systemId"];
806
801
  },
807
802
  isTextNode(node) {
808
- return node.nodeType === NODE_TYPES.TEXT_NODE;
803
+ return node.nodeType === 3;
809
804
  },
810
805
  isCommentNode(node) {
811
- return node.nodeType === NODE_TYPES.COMMENT_NODE;
806
+ return node.nodeType === 8;
812
807
  },
813
808
  isDocumentTypeNode(node) {
814
- return node.nodeType === NODE_TYPES.DOCUMENT_TYPE_NODE;
809
+ return node.nodeType === 10;
815
810
  },
816
811
  isElementNode(node) {
817
- return node.nodeType === NODE_TYPES.ELEMENT_NODE;
812
+ return node.nodeType === 1;
818
813
  }
819
814
  } };
820
815
  docParser.set(ownerDocument, parseOptions);
@@ -888,8 +883,8 @@ const shadowRootTag = "mock:shadow-root";
888
883
  * @yields the serialized HTML in chunks
889
884
  */
890
885
  function* streamToHtml(node, opts, output) {
891
- const isShadowRoot = node.nodeType === NODE_TYPES.DOCUMENT_FRAGMENT_NODE;
892
- if (node.nodeType === NODE_TYPES.ELEMENT_NODE || isShadowRoot) {
886
+ const isShadowRoot = node.nodeType === 11;
887
+ if (node.nodeType === 1 || isShadowRoot) {
893
888
  const tagName = isShadowRoot ? shadowRootTag : getTagName(node);
894
889
  if (tagName === "body") output.isWithinBody = true;
895
890
  const ignoreTag = opts.excludeTags != null && opts.excludeTags.includes(tagName);
@@ -925,7 +920,7 @@ function* streamToHtml(node, opts, output) {
925
920
  const attr = attributes.item(i);
926
921
  const attrName = attr.name;
927
922
  if (attrName === "style") continue;
928
- if (tag === "template" && isShadowRoot && (attrName === "shadowrootmode" || attrName === "shadowrootdelegatesfocus")) continue;
923
+ if (tag === "template" && isShadowRoot && (attrName === "shadowrootmode" || attrName === "shadowrootdelegatesfocus" || attrName === "shadowrootcustomelementregistry")) continue;
929
924
  let attrValue = attr.value;
930
925
  if (opts.removeEmptyAttributes && attrValue === "" && REMOVE_EMPTY_ATTR.has(attrName)) continue;
931
926
  const attrNamespaceURI = attr.namespaceURI;
@@ -988,7 +983,7 @@ function* streamToHtml(node, opts, output) {
988
983
  yield* streamToHtml(shadowRoot, opts, output);
989
984
  output.indent = output.indent - (opts.indentSpaces ?? 0);
990
985
  const childNodes = getChildNodes(node);
991
- if (opts.newLines && (childNodes.length === 0 || childNodes.length === 1 && childNodes[0].nodeType === NODE_TYPES.TEXT_NODE && childNodes[0].nodeValue?.trim() === "")) {
986
+ if (opts.newLines && (childNodes.length === 0 || childNodes.length === 1 && childNodes[0].nodeType === 3 && childNodes[0].nodeValue?.trim() === "")) {
992
987
  yield "\n";
993
988
  output.currentLineWidth = 0;
994
989
  for (let i = 0; i < output.indent; i++) yield " ";
@@ -999,7 +994,7 @@ function* streamToHtml(node, opts, output) {
999
994
  const tag = tagName === shadowRootTag ? "template" : tagName;
1000
995
  const childNodes = tagName === "template" ? node.content.childNodes : getChildNodes(node);
1001
996
  const childNodeLength = childNodes.length;
1002
- if (childNodeLength > 0) if (childNodeLength === 1 && childNodes[0].nodeType === NODE_TYPES.TEXT_NODE && (typeof childNodes[0].nodeValue !== "string" || childNodes[0].nodeValue.trim() === "")) {} else {
997
+ if (childNodeLength > 0) if (childNodeLength === 1 && childNodes[0].nodeType === 3 && (typeof childNodes[0].nodeValue !== "string" || childNodes[0].nodeValue.trim() === "")) {} else {
1003
998
  const isWithinWhitespaceSensitiveNode = opts.newLines || (opts.indentSpaces ?? 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
1004
999
  if (!isWithinWhitespaceSensitiveNode && (opts.indentSpaces ?? 0) > 0 && ignoreTag === false) output.indent = output.indent + (opts.indentSpaces ?? 0);
1005
1000
  for (let i = 0; i < childNodeLength; i++) {
@@ -1041,7 +1036,7 @@ function* streamToHtml(node, opts, output) {
1041
1036
  output.currentLineWidth = 0;
1042
1037
  }
1043
1038
  if (tagName === "body") output.isWithinBody = false;
1044
- } else if (node.nodeType === NODE_TYPES.TEXT_NODE) {
1039
+ } else if (node.nodeType === 3) {
1045
1040
  let textContent = node.nodeValue;
1046
1041
  if (typeof textContent === "string") {
1047
1042
  const trimmedTextContent = textContent.trim();
@@ -1068,7 +1063,7 @@ function* streamToHtml(node, opts, output) {
1068
1063
  }
1069
1064
  let textContentLength = textContent.length;
1070
1065
  if (textContentLength > 0) {
1071
- const parentTagName = node.parentNode != null && node.parentNode.nodeType === NODE_TYPES.ELEMENT_NODE ? node.parentNode.nodeName : null;
1066
+ const parentTagName = node.parentNode != null && node.parentNode.nodeType === 1 ? node.parentNode.nodeName : null;
1072
1067
  if (typeof parentTagName === "string" && NON_ESCAPABLE_CONTENT.has(parentTagName)) {
1073
1068
  if (isWithinWhitespaceSensitive(node)) yield textContent;
1074
1069
  else {
@@ -1082,13 +1077,13 @@ function* streamToHtml(node, opts, output) {
1082
1077
  } else {
1083
1078
  if (isWithinWhitespaceSensitive(node)) output.currentLineWidth += textContentLength;
1084
1079
  else {
1085
- if (/\s/.test(textContent.charAt(0))) textContent = " " + textContent.trimLeft();
1080
+ if (/\s/.test(textContent.charAt(0))) textContent = " " + textContent.trimStart();
1086
1081
  textContentLength = textContent.length;
1087
1082
  if (textContentLength > 1) {
1088
1083
  if (/\s/.test(textContent.charAt(textContentLength - 1))) if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth + textContentLength > opts.approximateLineWidth) {
1089
- textContent = textContent.trimRight() + "\n";
1084
+ textContent = textContent.trimEnd() + "\n";
1090
1085
  output.currentLineWidth = 0;
1091
- } else textContent = textContent.trimRight() + " ";
1086
+ } else textContent = textContent.trimEnd() + " ";
1092
1087
  }
1093
1088
  output.currentLineWidth += textContentLength;
1094
1089
  }
@@ -1097,7 +1092,7 @@ function* streamToHtml(node, opts, output) {
1097
1092
  }
1098
1093
  }
1099
1094
  }
1100
- } else if (node.nodeType === NODE_TYPES.COMMENT_NODE) {
1095
+ } else if (node.nodeType === 8) {
1101
1096
  const nodeValue = node.nodeValue;
1102
1097
  const isHydrateAnnotation = nodeValue?.startsWith("r.") || nodeValue?.startsWith("o.") || nodeValue?.startsWith("s.") || nodeValue?.startsWith("t.");
1103
1098
  /**
@@ -1116,7 +1111,7 @@ function* streamToHtml(node, opts, output) {
1116
1111
  }
1117
1112
  yield "<!--" + nodeValue + "-->";
1118
1113
  if (nodeValue) output.currentLineWidth += nodeValue.length + 7;
1119
- } else if (node.nodeType === NODE_TYPES.DOCUMENT_TYPE_NODE) yield "<!doctype html>";
1114
+ } else if (node.nodeType === 10) yield "<!doctype html>";
1120
1115
  }
1121
1116
  const AMP_REGEX = /&/g;
1122
1117
  const NBSP_REGEX = /\u00a0/g;
@@ -1163,11 +1158,7 @@ const NON_ESCAPABLE_CONTENT = new Set([
1163
1158
  "STYLE",
1164
1159
  "SCRIPT",
1165
1160
  "IFRAME",
1166
- "NOSCRIPT",
1167
- "XMP",
1168
- "NOEMBED",
1169
- "NOFRAMES",
1170
- "PLAINTEXT"
1161
+ "NOSCRIPT"
1171
1162
  ]);
1172
1163
  /**
1173
1164
  * A list of whitespace sensitive tag names, such as `code`, `pre`, etc.
@@ -1175,7 +1166,6 @@ const NON_ESCAPABLE_CONTENT = new Set([
1175
1166
  const WHITESPACE_SENSITIVE = new Set([
1176
1167
  "CODE",
1177
1168
  "OUTPUT",
1178
- "PLAINTEXT",
1179
1169
  "PRE",
1180
1170
  "SCRIPT",
1181
1171
  "TEMPLATE",
@@ -1184,21 +1174,16 @@ const WHITESPACE_SENSITIVE = new Set([
1184
1174
  const EMPTY_ELEMENTS = new Set([
1185
1175
  "area",
1186
1176
  "base",
1187
- "basefont",
1188
- "bgsound",
1189
1177
  "br",
1190
1178
  "col",
1191
1179
  "embed",
1192
- "frame",
1193
1180
  "hr",
1194
1181
  "img",
1195
1182
  "input",
1196
- "keygen",
1197
1183
  "link",
1198
1184
  "meta",
1199
1185
  "param",
1200
1186
  "source",
1201
- "trace",
1202
1187
  "track",
1203
1188
  "wbr"
1204
1189
  ]);
@@ -1216,44 +1201,29 @@ const BOOLEAN_ATTR = new Set([
1216
1201
  "autofocus",
1217
1202
  "autoplay",
1218
1203
  "checked",
1219
- "compact",
1220
1204
  "controls",
1221
- "declare",
1222
1205
  "default",
1223
- "defaultchecked",
1224
- "defaultmuted",
1225
- "defaultselected",
1226
1206
  "defer",
1227
1207
  "disabled",
1228
- "enabled",
1229
1208
  "formnovalidate",
1230
1209
  "hidden",
1231
- "indeterminate",
1232
1210
  "inert",
1233
1211
  "ismap",
1234
1212
  "itemscope",
1235
1213
  "loop",
1236
1214
  "multiple",
1237
1215
  "muted",
1238
- "nohref",
1239
1216
  "nomodule",
1240
- "noresize",
1241
- "noshade",
1242
1217
  "novalidate",
1243
- "nowrap",
1244
1218
  "open",
1245
- "pauseonexit",
1246
1219
  "readonly",
1247
1220
  "required",
1248
1221
  "reversed",
1249
- "scoped",
1250
- "seamless",
1251
1222
  "selected",
1223
+ "shadowrootclonable",
1224
+ "shadowrootcustomelementregistry",
1252
1225
  "shadowrootdelegatesfocus",
1253
- "sortable",
1254
- "truespeed",
1255
- "typemustmatch",
1256
- "visible"
1226
+ "shadowrootserializable"
1257
1227
  ]);
1258
1228
  const STRUCTURE_ELEMENTS = new Set([
1259
1229
  "html",
@@ -1270,6 +1240,8 @@ const STRUCTURE_ELEMENTS = new Set([
1270
1240
  //#endregion
1271
1241
  //#region src/token-list.ts
1272
1242
  var MockTokenList = class {
1243
+ elm;
1244
+ attr;
1273
1245
  constructor(elm, attr) {
1274
1246
  this.elm = elm;
1275
1247
  this.attr = attr;
@@ -1352,7 +1324,7 @@ var MockNode = class {
1352
1324
  this._childNodes = value;
1353
1325
  }
1354
1326
  appendChild(newNode) {
1355
- if (newNode.nodeType === NODE_TYPES.DOCUMENT_FRAGMENT_NODE) {
1327
+ if (newNode.nodeType === 11) {
1356
1328
  const nodes = newNode.childNodes.slice();
1357
1329
  for (const child of nodes) this.appendChild(child);
1358
1330
  } else {
@@ -1383,22 +1355,20 @@ var MockNode = class {
1383
1355
  const DOCUMENT_POSITION_DISCONNECTED = 1;
1384
1356
  const DOCUMENT_POSITION_PRECEDING = 2;
1385
1357
  const DOCUMENT_POSITION_FOLLOWING = 4;
1386
- const DOCUMENT_POSITION_CONTAINS = 8;
1387
- const DOCUMENT_POSITION_CONTAINED_BY = 16;
1388
1358
  if (this === other) return 0;
1389
1359
  let thisRoot = this;
1390
1360
  while (thisRoot.parentNode) thisRoot = thisRoot.parentNode;
1391
1361
  let otherRoot = other;
1392
1362
  while (otherRoot.parentNode) otherRoot = otherRoot.parentNode;
1393
- if (thisRoot !== otherRoot) return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_PRECEDING;
1363
+ if (thisRoot !== otherRoot) return 3;
1394
1364
  let node = other;
1395
1365
  while (node) {
1396
- if (node === this) return DOCUMENT_POSITION_CONTAINS | DOCUMENT_POSITION_PRECEDING;
1366
+ if (node === this) return 10;
1397
1367
  node = node.parentNode;
1398
1368
  }
1399
1369
  node = this;
1400
1370
  while (node) {
1401
- if (node === other) return DOCUMENT_POSITION_CONTAINED_BY | DOCUMENT_POSITION_FOLLOWING;
1371
+ if (node === other) return 20;
1402
1372
  node = node.parentNode;
1403
1373
  }
1404
1374
  const getAncestors = (n) => {
@@ -1426,16 +1396,16 @@ var MockNode = class {
1426
1396
  return this.childNodes[0] || null;
1427
1397
  }
1428
1398
  insertBefore(newNode, referenceNode) {
1429
- if (newNode.nodeType === NODE_TYPES.DOCUMENT_FRAGMENT_NODE) for (let i = 0, ii = newNode.childNodes.length; i < ii; i++) insertBefore(this, newNode.childNodes[i], referenceNode);
1399
+ if (newNode.nodeType === 11) for (let i = 0, ii = newNode.childNodes.length; i < ii; i++) insertBefore(this, newNode.childNodes[i], referenceNode);
1430
1400
  else insertBefore(this, newNode, referenceNode);
1431
1401
  return newNode;
1432
1402
  }
1433
1403
  get isConnected() {
1434
1404
  let node = this;
1435
1405
  while (node != null) {
1436
- if (node.nodeType === NODE_TYPES.DOCUMENT_NODE) return true;
1406
+ if (node.nodeType === 9) return true;
1437
1407
  node = node.parentNode;
1438
- if (node != null && node.nodeType === NODE_TYPES.DOCUMENT_FRAGMENT_NODE) node = node.host;
1408
+ if (node != null && node.nodeType === 11) node = node.host;
1439
1409
  }
1440
1410
  return false;
1441
1411
  }
@@ -1481,7 +1451,7 @@ var MockNode = class {
1481
1451
  const index = this.childNodes.indexOf(childNode);
1482
1452
  if (index > -1) {
1483
1453
  this.childNodes.splice(index, 1);
1484
- if (this.nodeType === NODE_TYPES.ELEMENT_NODE) {
1454
+ if (this.nodeType === 1) {
1485
1455
  const wasConnected = this.isConnected;
1486
1456
  childNode.parentNode = null;
1487
1457
  if (wasConnected === true) disconnectNode(childNode);
@@ -1550,7 +1520,7 @@ var MockElement = class extends MockNode {
1550
1520
  } });
1551
1521
  }
1552
1522
  constructor(ownerDocument, nodeName, namespaceURI = null) {
1553
- super(ownerDocument, NODE_TYPES.ELEMENT_NODE, typeof nodeName === "string" ? nodeName : null, null);
1523
+ super(ownerDocument, 1, typeof nodeName === "string" ? nodeName : null, null);
1554
1524
  this.__namespaceURI = namespaceURI;
1555
1525
  this.__localName = typeof nodeName === "string" ? nodeName : null;
1556
1526
  this.__shadowRoot = null;
@@ -1625,10 +1595,10 @@ var MockElement = class extends MockNode {
1625
1595
  this.__attributeMap = attrs;
1626
1596
  }
1627
1597
  get children() {
1628
- return this.childNodes.filter((n) => n.nodeType === NODE_TYPES.ELEMENT_NODE);
1598
+ return this.childNodes.filter((n) => n.nodeType === 1);
1629
1599
  }
1630
1600
  get childElementCount() {
1631
- return this.childNodes.filter((n) => n.nodeType === NODE_TYPES.ELEMENT_NODE).length;
1601
+ return this.childNodes.filter((n) => n.nodeType === 1).length;
1632
1602
  }
1633
1603
  get className() {
1634
1604
  return this.getAttributeNS(null, "class") || "";
@@ -1821,7 +1791,7 @@ var MockElement = class extends MockNode {
1821
1791
  }
1822
1792
  get nextElementSibling() {
1823
1793
  const parentElement = this.parentElement;
1824
- if (parentElement != null && (parentElement.nodeType === NODE_TYPES.ELEMENT_NODE || parentElement.nodeType === NODE_TYPES.DOCUMENT_FRAGMENT_NODE || parentElement.nodeType === NODE_TYPES.DOCUMENT_NODE)) {
1794
+ if (parentElement != null && (parentElement.nodeType === 1 || parentElement.nodeType === 11 || parentElement.nodeType === 9)) {
1825
1795
  const index = parentElement.children.indexOf(this) + 1;
1826
1796
  return parentElement.children[index] || null;
1827
1797
  }
@@ -1836,7 +1806,7 @@ var MockElement = class extends MockNode {
1836
1806
  }
1837
1807
  get previousElementSibling() {
1838
1808
  const parentElement = this.parentElement;
1839
- if (parentElement != null && (parentElement.nodeType === NODE_TYPES.ELEMENT_NODE || parentElement.nodeType === NODE_TYPES.DOCUMENT_FRAGMENT_NODE || parentElement.nodeType === NODE_TYPES.DOCUMENT_NODE)) {
1809
+ if (parentElement != null && (parentElement.nodeType === 1 || parentElement.nodeType === 11 || parentElement.nodeType === 9)) {
1840
1810
  const index = parentElement.children.indexOf(this) - 1;
1841
1811
  return parentElement.children[index] || null;
1842
1812
  }
@@ -2095,7 +2065,7 @@ function insertBefore(parentNode, newNode, referenceNode) {
2095
2065
  var MockHTMLElement = class extends MockElement {
2096
2066
  __namespaceURI = "http://www.w3.org/1999/xhtml";
2097
2067
  constructor(ownerDocument, nodeName) {
2098
- super(ownerDocument, typeof nodeName === "string" ? nodeName.toUpperCase() : null);
2068
+ super(ownerDocument, nodeName ? nodeName.toUpperCase() : null);
2099
2069
  }
2100
2070
  get tagName() {
2101
2071
  return this.nodeName ?? "";
@@ -2127,7 +2097,7 @@ var MockHTMLElement = class extends MockElement {
2127
2097
  };
2128
2098
  var MockTextNode = class MockTextNode extends MockNode {
2129
2099
  constructor(ownerDocument, text) {
2130
- super(ownerDocument, NODE_TYPES.TEXT_NODE, NODE_NAMES.TEXT_NODE, text);
2100
+ super(ownerDocument, 3, "#text", text);
2131
2101
  }
2132
2102
  cloneNode(_deep) {
2133
2103
  return new MockTextNode(null, this.nodeValue);
@@ -2149,7 +2119,7 @@ var MockTextNode = class MockTextNode extends MockNode {
2149
2119
  const text = [];
2150
2120
  for (let i = 0, ii = this.parentNode.childNodes.length; i < ii; i++) {
2151
2121
  const childNode = this.parentNode.childNodes[i];
2152
- if (childNode.nodeType === NODE_TYPES.TEXT_NODE) text.push(childNode.nodeValue);
2122
+ if (childNode.nodeType === 3) text.push(childNode.nodeValue);
2153
2123
  }
2154
2124
  return text.join("");
2155
2125
  }
@@ -2159,8 +2129,8 @@ var MockTextNode = class MockTextNode extends MockNode {
2159
2129
  function getTextContent(childNodes, text) {
2160
2130
  for (let i = 0, ii = childNodes.length; i < ii; i++) {
2161
2131
  const childNode = childNodes[i];
2162
- if (childNode.nodeType === NODE_TYPES.TEXT_NODE) text.push(childNode.nodeValue);
2163
- else if (childNode.nodeType === NODE_TYPES.ELEMENT_NODE) getTextContent(childNode.childNodes, text);
2132
+ if (childNode.nodeType === 3) text.push(childNode.nodeValue);
2133
+ else if (childNode.nodeType === 1) getTextContent(childNode.childNodes, text);
2164
2134
  }
2165
2135
  }
2166
2136
  function setTextContent(elm, text) {
@@ -2205,7 +2175,7 @@ function unmarkAsDispatching(target, eventType) {
2205
2175
  //#region src/comment-node.ts
2206
2176
  var MockComment = class MockComment extends MockNode {
2207
2177
  constructor(ownerDocument, data) {
2208
- super(ownerDocument, NODE_TYPES.COMMENT_NODE, NODE_NAMES.COMMENT_NODE, data);
2178
+ super(ownerDocument, 8, "#comment", data);
2209
2179
  }
2210
2180
  cloneNode(_deep) {
2211
2181
  return new MockComment(null, this.nodeValue);
@@ -3360,8 +3330,8 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
3360
3330
  var MockDocumentFragment = class MockDocumentFragment extends MockHTMLElement {
3361
3331
  constructor(ownerDocument) {
3362
3332
  super(ownerDocument, null);
3363
- this.nodeName = NODE_NAMES.DOCUMENT_FRAGMENT_NODE;
3364
- this.nodeType = NODE_TYPES.DOCUMENT_FRAGMENT_NODE;
3333
+ this.nodeName = "#document-fragment";
3334
+ this.nodeType = 11;
3365
3335
  }
3366
3336
  getElementById(id) {
3367
3337
  return getElementById(this, id);
@@ -3376,7 +3346,7 @@ var MockDocumentFragment = class MockDocumentFragment extends MockHTMLElement {
3376
3346
  const cloned = new MockDocumentFragment(null);
3377
3347
  if (deep) for (let i = 0, ii = this.childNodes.length; i < ii; i++) {
3378
3348
  const childNode = this.childNodes[i];
3379
- if (childNode.nodeType === NODE_TYPES.ELEMENT_NODE || childNode.nodeType === NODE_TYPES.TEXT_NODE || childNode.nodeType === NODE_TYPES.COMMENT_NODE) {
3349
+ if (childNode.nodeType === 1 || childNode.nodeType === 3 || childNode.nodeType === 8) {
3380
3350
  const clonedChildNode = this.childNodes[i].cloneNode(true);
3381
3351
  cloned.appendChild(clonedChildNode);
3382
3352
  }
@@ -3389,13 +3359,14 @@ var MockDocumentFragment = class MockDocumentFragment extends MockHTMLElement {
3389
3359
  var MockDocumentTypeNode = class extends MockHTMLElement {
3390
3360
  constructor(ownerDocument) {
3391
3361
  super(ownerDocument, "!DOCTYPE");
3392
- this.nodeType = NODE_TYPES.DOCUMENT_TYPE_NODE;
3362
+ this.nodeType = 10;
3393
3363
  this.setAttribute("html", "");
3394
3364
  }
3395
3365
  };
3396
3366
  //#endregion
3397
3367
  //#region src/css-style-sheet.ts
3398
3368
  var MockCSSRule = class {
3369
+ parentStyleSheet;
3399
3370
  cssText = "";
3400
3371
  type = 0;
3401
3372
  constructor(parentStyleSheet) {
@@ -3883,8 +3854,8 @@ var MockSlotElement = class MockSlotElement extends MockHTMLElement {
3883
3854
  const ownerHost = this.getRootNode().host;
3884
3855
  if (!ownerHost) return nodesToReturn;
3885
3856
  if (ownerHost.childNodes.length) {
3886
- if (this.name) nodesToReturn = ownerHost.childNodes.filter((n) => n.nodeType === NODE_TYPES.ELEMENT_NODE && n.getAttribute("slot") === this.name);
3887
- else nodesToReturn = ownerHost.childNodes.filter((n) => n.nodeType === NODE_TYPES.ELEMENT_NODE && !n.getAttribute("slot") || n.nodeType !== NODE_TYPES.ELEMENT_NODE);
3857
+ if (this.name) nodesToReturn = ownerHost.childNodes.filter((n) => n.nodeType === 1 && n.getAttribute("slot") === this.name);
3858
+ else nodesToReturn = ownerHost.childNodes.filter((n) => n.nodeType === 1 && !n.getAttribute("slot") || n.nodeType !== 1);
3888
3859
  if (nodesToReturn.length) return nodesToReturn;
3889
3860
  }
3890
3861
  if (!opts?.flatten) return this.childNodes.filter((n) => !(n instanceof MockSlotElement));
@@ -5317,8 +5288,8 @@ var MockDocument = class MockDocument extends MockHTMLElement {
5317
5288
  #nwsapi = null;
5318
5289
  constructor(html = null, win = null) {
5319
5290
  super(null, null);
5320
- this.nodeName = NODE_NAMES.DOCUMENT_NODE;
5321
- this.nodeType = NODE_TYPES.DOCUMENT_NODE;
5291
+ this.nodeName = "#document";
5292
+ this.nodeType = 9;
5322
5293
  this.defaultView = win;
5323
5294
  this.cookie = "";
5324
5295
  this.referrer = "";
@@ -5409,7 +5380,7 @@ var MockDocument = class MockDocument extends MockHTMLElement {
5409
5380
  return documentElement;
5410
5381
  }
5411
5382
  set documentElement(documentElement) {
5412
- for (let i = this.childNodes.length - 1; i >= 0; i--) if (this.childNodes[i].nodeType !== NODE_TYPES.DOCUMENT_TYPE_NODE) this.childNodes[i].remove();
5383
+ for (let i = this.childNodes.length - 1; i >= 0; i--) if (this.childNodes[i].nodeType !== 10) this.childNodes[i].remove();
5413
5384
  if (documentElement != null) {
5414
5385
  this.appendChild(documentElement);
5415
5386
  setOwnerDocument(documentElement, this);
@@ -5461,7 +5432,7 @@ var MockDocument = class MockDocument extends MockHTMLElement {
5461
5432
  return new MockAttr(attrName, "", namespaceURI);
5462
5433
  }
5463
5434
  createElement(tagName) {
5464
- if (tagName === NODE_NAMES.DOCUMENT_NODE) {
5435
+ if (tagName === "#document") {
5465
5436
  const doc = new MockDocument(false);
5466
5437
  doc.nodeName = tagName;
5467
5438
  doc.parentNode = null;
@@ -5533,10 +5504,10 @@ function resetDocument(doc) {
5533
5504
  }
5534
5505
  for (const key in doc) if (doc.hasOwnProperty(key) && !DOC_KEY_KEEPERS.has(key)) delete doc[key];
5535
5506
  try {
5536
- doc.nodeName = NODE_NAMES.DOCUMENT_NODE;
5507
+ doc.nodeName = "#document";
5537
5508
  } catch {}
5538
5509
  try {
5539
- doc.nodeType = NODE_TYPES.DOCUMENT_NODE;
5510
+ doc.nodeType = 9;
5540
5511
  } catch {}
5541
5512
  try {
5542
5513
  doc.cookie = "";
@@ -5580,7 +5551,7 @@ function getElementsByName(elm, elmName, foundElms = []) {
5580
5551
  function setOwnerDocument(elm, ownerDocument) {
5581
5552
  for (let i = 0, ii = elm.childNodes.length; i < ii; i++) {
5582
5553
  elm.childNodes[i].ownerDocument = ownerDocument;
5583
- if (elm.childNodes[i].nodeType === NODE_TYPES.ELEMENT_NODE) setOwnerDocument(elm.childNodes[i], ownerDocument);
5554
+ if (elm.childNodes[i].nodeType === 1) setOwnerDocument(elm.childNodes[i], ownerDocument);
5584
5555
  }
5585
5556
  }
5586
5557
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/mock-doc",
3
- "version": "5.0.0-alpha.4",
3
+ "version": "5.0.0-alpha.6",
4
4
  "description": "A minimal mock DOM implementation for SSR and testing",
5
5
  "keywords": [
6
6
  "dom",
@@ -32,14 +32,14 @@
32
32
  }
33
33
  },
34
34
  "dependencies": {
35
- "nwsapi": "^2.2.23",
36
- "parse5": "7.2.1"
35
+ "nwsapi": "^2.0.0",
36
+ "parse5": "^8.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@stencil/vitest": "^1.10.0",
40
- "tsdown": "^0.21.6",
41
- "typescript": "~6.0.2",
42
- "vitest": "^4.1.1"
39
+ "@stencil/vitest": "^1.12.1",
40
+ "tsdown": ">=0.21.0 <1.0.0",
41
+ "typescript": ">4.0.0 <7.0.0",
42
+ "vitest": "^4.1.7"
43
43
  },
44
44
  "volta": {
45
45
  "extends": "../../package.json"