@stencil/core 2.17.2 → 2.18.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 (65) hide show
  1. package/cli/index.cjs +32 -16
  2. package/cli/index.js +32 -16
  3. package/cli/package.json +1 -1
  4. package/compiler/lib.dom.d.ts +620 -89
  5. package/compiler/lib.dom.iterable.d.ts +27 -3
  6. package/compiler/lib.es2015.core.d.ts +3 -3
  7. package/compiler/lib.es2015.iterable.d.ts +2 -1
  8. package/compiler/lib.es2015.reflect.d.ts +1 -1
  9. package/compiler/lib.es2020.bigint.d.ts +7 -5
  10. package/compiler/lib.es2020.d.ts +2 -0
  11. package/compiler/lib.es2020.date.d.ts +44 -0
  12. package/compiler/lib.es2020.intl.d.ts +51 -11
  13. package/compiler/lib.es2020.number.d.ts +30 -0
  14. package/compiler/lib.es2021.intl.d.ts +106 -4
  15. package/compiler/lib.es2022.array.d.ts +123 -0
  16. package/compiler/lib.es2022.d.ts +26 -0
  17. package/compiler/lib.es2022.error.d.ts +75 -0
  18. package/compiler/lib.es2022.full.d.ts +25 -0
  19. package/compiler/lib.es2022.intl.d.ts +111 -0
  20. package/compiler/lib.es2022.object.d.ts +28 -0
  21. package/compiler/lib.es2022.string.d.ts +27 -0
  22. package/compiler/lib.es5.d.ts +25 -19
  23. package/compiler/lib.esnext.d.ts +1 -1
  24. package/compiler/lib.esnext.intl.d.ts +4 -1
  25. package/compiler/lib.webworker.d.ts +236 -40
  26. package/compiler/lib.webworker.iterable.d.ts +10 -3
  27. package/compiler/package.json +1 -1
  28. package/compiler/stencil.js +689 -232
  29. package/compiler/stencil.min.js +2 -2
  30. package/compiler/sys/in-memory-fs.d.ts +218 -0
  31. package/dependencies.json +10 -1
  32. package/dev-server/client/index.js +1 -1
  33. package/dev-server/client/package.json +1 -1
  34. package/dev-server/connector.html +2 -2
  35. package/dev-server/index.js +1 -1
  36. package/dev-server/package.json +1 -1
  37. package/dev-server/server-process.js +13 -13
  38. package/internal/app-data/package.json +1 -1
  39. package/internal/client/css-shim.js +1 -1
  40. package/internal/client/dom.js +1 -1
  41. package/internal/client/index.js +337 -157
  42. package/internal/client/package.json +1 -1
  43. package/internal/client/patch-browser.js +1 -1
  44. package/internal/client/patch-esm.js +1 -1
  45. package/internal/client/shadow-css.js +1 -1
  46. package/internal/hydrate/package.json +1 -1
  47. package/internal/hydrate/runner.d.ts +1 -1
  48. package/internal/package.json +1 -1
  49. package/internal/stencil-private.d.ts +2 -106
  50. package/internal/stencil-public-compiler.d.ts +42 -8
  51. package/internal/testing/package.json +1 -1
  52. package/mock-doc/index.cjs +77 -61
  53. package/mock-doc/index.d.ts +13 -12
  54. package/mock-doc/index.js +77 -61
  55. package/mock-doc/package.json +1 -1
  56. package/package.json +5 -7
  57. package/screenshot/index.js +10 -10
  58. package/screenshot/package.json +1 -1
  59. package/sys/node/index.js +1 -1
  60. package/sys/node/package.json +1 -1
  61. package/sys/node/worker.js +1 -1
  62. package/testing/index.js +96 -106
  63. package/testing/jest/jest-config.d.ts +1 -1
  64. package/testing/package.json +1 -1
  65. package/testing/testing-utils.d.ts +5 -4
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Mock Doc (CommonJS) v2.17.2 | MIT Licensed | https://stenciljs.com
2
+ Stencil Mock Doc (CommonJS) v2.18.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var mockDoc = (function(exports) {
5
5
  'use strict';
@@ -282,7 +282,7 @@ const proxyElements = new WeakMap();
282
282
  const upgradedElements = new WeakSet();
283
283
  function connectNode(ownerDocument, node) {
284
284
  node.ownerDocument = ownerDocument;
285
- if (node.nodeType === 1 /* ELEMENT_NODE */) {
285
+ if (node.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */) {
286
286
  if (ownerDocument != null && node.nodeName.includes('-')) {
287
287
  const win = ownerDocument.defaultView;
288
288
  if (win != null && typeof node.connectedCallback === 'function' && node.isConnected) {
@@ -318,7 +318,7 @@ function fireConnectedCallback(node) {
318
318
  }
319
319
  }
320
320
  function disconnectNode(node) {
321
- if (node.nodeType === 1 /* ELEMENT_NODE */) {
321
+ if (node.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */) {
322
322
  if (node.nodeName.includes('-') === true && typeof node.disconnectedCallback === 'function') {
323
323
  if (tempDisableCallbacks.has(node.ownerDocument) === false) {
324
324
  try {
@@ -634,7 +634,7 @@ class MockEvent {
634
634
  let currentElement = this.target;
635
635
  while (currentElement) {
636
636
  composedPath.push(currentElement);
637
- if (!currentElement.parentElement && currentElement.nodeName === "#document" /* DOCUMENT_NODE */) {
637
+ if (!currentElement.parentElement && currentElement.nodeName === "#document" /* NODE_NAMES.DOCUMENT_NODE */) {
638
638
  // the current element doesn't have a parent, but we've detected it's our root document node. push the window
639
639
  // object associated with the document onto the path
640
640
  composedPath.push(currentElement.defaultView);
@@ -756,7 +756,7 @@ function triggerEventListener(elm, ev) {
756
756
  if (ev.bubbles === false) {
757
757
  return;
758
758
  }
759
- if (elm.nodeName === "#document" /* DOCUMENT_NODE */) {
759
+ if (elm.nodeName === "#document" /* NODE_NAMES.DOCUMENT_NODE */) {
760
760
  triggerEventListener(elm.defaultView, ev);
761
761
  }
762
762
  else {
@@ -829,7 +829,7 @@ function serializeNodeToHtml(elm, opts = {}) {
829
829
  return output.text.join('');
830
830
  }
831
831
  function serializeToHtml(node, opts, output, isShadowRoot) {
832
- if (node.nodeType === 1 /* ELEMENT_NODE */ || isShadowRoot) {
832
+ if (node.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */ || isShadowRoot) {
833
833
  const tagName = isShadowRoot ? 'mock:shadow-root' : getTagName(node);
834
834
  if (tagName === 'body') {
835
835
  output.isWithinBody = true;
@@ -946,7 +946,7 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
946
946
  if (opts.newLines &&
947
947
  (node.childNodes.length === 0 ||
948
948
  (node.childNodes.length === 1 &&
949
- node.childNodes[0].nodeType === 3 /* TEXT_NODE */ &&
949
+ node.childNodes[0].nodeType === 3 /* NODE_TYPES.TEXT_NODE */ &&
950
950
  node.childNodes[0].nodeValue.trim() === ''))) {
951
951
  output.text.push('\n');
952
952
  output.currentLineWidth = 0;
@@ -961,7 +961,7 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
961
961
  const childNodeLength = childNodes.length;
962
962
  if (childNodeLength > 0) {
963
963
  if (childNodeLength === 1 &&
964
- childNodes[0].nodeType === 3 /* TEXT_NODE */ &&
964
+ childNodes[0].nodeType === 3 /* NODE_TYPES.TEXT_NODE */ &&
965
965
  (typeof childNodes[0].nodeValue !== 'string' || childNodes[0].nodeValue.trim() === '')) ;
966
966
  else {
967
967
  const isWithinWhitespaceSensitiveNode = opts.newLines || opts.indentSpaces > 0 ? isWithinWhitespaceSensitive(node) : false;
@@ -1000,7 +1000,7 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
1000
1000
  output.isWithinBody = false;
1001
1001
  }
1002
1002
  }
1003
- else if (node.nodeType === 3 /* TEXT_NODE */) {
1003
+ else if (node.nodeType === 3 /* NODE_TYPES.TEXT_NODE */) {
1004
1004
  let textContent = node.nodeValue;
1005
1005
  if (typeof textContent === 'string') {
1006
1006
  const trimmedTextContent = textContent.trim();
@@ -1047,7 +1047,7 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
1047
1047
  let textContentLength = textContent.length;
1048
1048
  if (textContentLength > 0) {
1049
1049
  // this text node has text content
1050
- const parentTagName = node.parentNode != null && node.parentNode.nodeType === 1 /* ELEMENT_NODE */
1050
+ const parentTagName = node.parentNode != null && node.parentNode.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */
1051
1051
  ? node.parentNode.nodeName
1052
1052
  : null;
1053
1053
  if (NON_ESCAPABLE_CONTENT.has(parentTagName)) {
@@ -1102,7 +1102,7 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
1102
1102
  }
1103
1103
  }
1104
1104
  }
1105
- else if (node.nodeType === 8 /* COMMENT_NODE */) {
1105
+ else if (node.nodeType === 8 /* NODE_TYPES.COMMENT_NODE */) {
1106
1106
  const nodeValue = node.nodeValue;
1107
1107
  if (opts.removeHtmlComments) {
1108
1108
  const isHydrateAnnotation = nodeValue.startsWith(CONTENT_REF_ID + '.') ||
@@ -1127,7 +1127,7 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
1127
1127
  output.text.push('<!--' + nodeValue + '-->');
1128
1128
  output.currentLineWidth += nodeValue.length + 7;
1129
1129
  }
1130
- else if (node.nodeType === 10 /* DOCUMENT_TYPE_NODE */) {
1130
+ else if (node.nodeType === 10 /* NODE_TYPES.DOCUMENT_TYPE_NODE */) {
1131
1131
  output.text.push('<!doctype html>');
1132
1132
  }
1133
1133
  }
@@ -1286,7 +1286,7 @@ function getParser(ownerDocument) {
1286
1286
  }
1287
1287
  const treeAdapter = {
1288
1288
  createDocument() {
1289
- const doc = ownerDocument.createElement("#document" /* DOCUMENT_NODE */);
1289
+ const doc = ownerDocument.createElement("#document" /* NODE_NAMES.DOCUMENT_NODE */);
1290
1290
  doc['x-mode'] = 'no-quirks';
1291
1291
  return doc;
1292
1292
  },
@@ -1328,7 +1328,7 @@ function getParser(ownerDocument) {
1328
1328
  return templateElement.content;
1329
1329
  },
1330
1330
  setDocumentType(doc, name, publicId, systemId) {
1331
- let doctypeNode = doc.childNodes.find((n) => n.nodeType === 10 /* DOCUMENT_TYPE_NODE */);
1331
+ let doctypeNode = doc.childNodes.find((n) => n.nodeType === 10 /* NODE_TYPES.DOCUMENT_TYPE_NODE */);
1332
1332
  if (doctypeNode == null) {
1333
1333
  doctypeNode = ownerDocument.createDocumentTypeNode();
1334
1334
  doc.insertBefore(doctypeNode, doc.firstChild);
@@ -1349,7 +1349,7 @@ function getParser(ownerDocument) {
1349
1349
  },
1350
1350
  insertText(parentNode, text) {
1351
1351
  const lastChild = parentNode.lastChild;
1352
- if (lastChild != null && lastChild.nodeType === 3 /* TEXT_NODE */) {
1352
+ if (lastChild != null && lastChild.nodeType === 3 /* NODE_TYPES.TEXT_NODE */) {
1353
1353
  lastChild.nodeValue += text;
1354
1354
  }
1355
1355
  else {
@@ -1358,7 +1358,7 @@ function getParser(ownerDocument) {
1358
1358
  },
1359
1359
  insertTextBefore(parentNode, text, referenceNode) {
1360
1360
  const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
1361
- if (prevNode != null && prevNode.nodeType === 3 /* TEXT_NODE */) {
1361
+ if (prevNode != null && prevNode.nodeType === 3 /* NODE_TYPES.TEXT_NODE */) {
1362
1362
  prevNode.nodeValue += text;
1363
1363
  }
1364
1364
  else {
@@ -1420,16 +1420,16 @@ function getParser(ownerDocument) {
1420
1420
  return doctypeNode['x-systemId'];
1421
1421
  },
1422
1422
  isTextNode(node) {
1423
- return node.nodeType === 3 /* TEXT_NODE */;
1423
+ return node.nodeType === 3 /* NODE_TYPES.TEXT_NODE */;
1424
1424
  },
1425
1425
  isCommentNode(node) {
1426
- return node.nodeType === 8 /* COMMENT_NODE */;
1426
+ return node.nodeType === 8 /* NODE_TYPES.COMMENT_NODE */;
1427
1427
  },
1428
1428
  isDocumentTypeNode(node) {
1429
- return node.nodeType === 10 /* DOCUMENT_TYPE_NODE */;
1429
+ return node.nodeType === 10 /* NODE_TYPES.DOCUMENT_TYPE_NODE */;
1430
1430
  },
1431
1431
  isElementNode(node) {
1432
- return node.nodeType === 1 /* ELEMENT_NODE */;
1432
+ return node.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */;
1433
1433
  },
1434
1434
  };
1435
1435
  parseOptions = {
@@ -1449,7 +1449,7 @@ class MockNode {
1449
1449
  this.childNodes = [];
1450
1450
  }
1451
1451
  appendChild(newNode) {
1452
- if (newNode.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */) {
1452
+ if (newNode.nodeType === 11 /* NODE_TYPES.DOCUMENT_FRAGMENT_NODE */) {
1453
1453
  const nodes = newNode.childNodes.slice();
1454
1454
  for (const child of nodes) {
1455
1455
  this.appendChild(child);
@@ -1473,7 +1473,9 @@ class MockNode {
1473
1473
  const firstChild = this.firstChild;
1474
1474
  items.forEach((item) => {
1475
1475
  const isNode = typeof item === 'object' && item !== null && 'nodeType' in item;
1476
- this.insertBefore(isNode ? item : this.ownerDocument.createTextNode(String(item)), firstChild);
1476
+ if (firstChild) {
1477
+ this.insertBefore(isNode ? item : this.ownerDocument.createTextNode(String(item)), firstChild);
1478
+ }
1477
1479
  });
1478
1480
  }
1479
1481
  cloneNode(deep) {
@@ -1488,7 +1490,7 @@ class MockNode {
1488
1490
  return this.childNodes[0] || null;
1489
1491
  }
1490
1492
  insertBefore(newNode, referenceNode) {
1491
- if (newNode.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */) {
1493
+ if (newNode.nodeType === 11 /* NODE_TYPES.DOCUMENT_FRAGMENT_NODE */) {
1492
1494
  for (let i = 0, ii = newNode.childNodes.length; i < ii; i++) {
1493
1495
  insertBefore(this, newNode.childNodes[i], referenceNode);
1494
1496
  }
@@ -1501,11 +1503,11 @@ class MockNode {
1501
1503
  get isConnected() {
1502
1504
  let node = this;
1503
1505
  while (node != null) {
1504
- if (node.nodeType === 9 /* DOCUMENT_NODE */) {
1506
+ if (node.nodeType === 9 /* NODE_TYPES.DOCUMENT_NODE */) {
1505
1507
  return true;
1506
1508
  }
1507
1509
  node = node.parentNode;
1508
- if (node != null && node.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */) {
1510
+ if (node != null && node.nodeType === 11 /* NODE_TYPES.DOCUMENT_FRAGMENT_NODE */) {
1509
1511
  node = node.host;
1510
1512
  }
1511
1513
  }
@@ -1525,7 +1527,8 @@ class MockNode {
1525
1527
  return null;
1526
1528
  }
1527
1529
  get nodeValue() {
1528
- return this._nodeValue;
1530
+ var _a;
1531
+ return (_a = this._nodeValue) !== null && _a !== void 0 ? _a : '';
1529
1532
  }
1530
1533
  set nodeValue(value) {
1531
1534
  this._nodeValue = value;
@@ -1557,7 +1560,7 @@ class MockNode {
1557
1560
  const index = this.childNodes.indexOf(childNode);
1558
1561
  if (index > -1) {
1559
1562
  this.childNodes.splice(index, 1);
1560
- if (this.nodeType === 1 /* ELEMENT_NODE */) {
1563
+ if (this.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */) {
1561
1564
  const wasConnected = this.isConnected;
1562
1565
  childNode.parentNode = null;
1563
1566
  if (wasConnected === true) {
@@ -1587,7 +1590,8 @@ class MockNode {
1587
1590
  return null;
1588
1591
  }
1589
1592
  get textContent() {
1590
- return this._nodeValue;
1593
+ var _a;
1594
+ return (_a = this._nodeValue) !== null && _a !== void 0 ? _a : '';
1591
1595
  }
1592
1596
  set textContent(value) {
1593
1597
  this._nodeValue = String(value);
@@ -1609,8 +1613,10 @@ class MockNodeList {
1609
1613
  }
1610
1614
  class MockElement extends MockNode {
1611
1615
  constructor(ownerDocument, nodeName) {
1612
- super(ownerDocument, 1 /* ELEMENT_NODE */, typeof nodeName === 'string' ? nodeName : null, null);
1616
+ super(ownerDocument, 1 /* NODE_TYPES.ELEMENT_NODE */, typeof nodeName === 'string' ? nodeName : null, null);
1613
1617
  this.namespaceURI = null;
1618
+ this.__shadowRoot = null;
1619
+ this.__attributeMap = null;
1614
1620
  }
1615
1621
  addEventListener(type, handler) {
1616
1622
  addEventListener(this, type, handler);
@@ -1637,7 +1643,9 @@ class MockElement extends MockNode {
1637
1643
  }
1638
1644
  get attributes() {
1639
1645
  if (this.__attributeMap == null) {
1640
- this.__attributeMap = createAttributeProxy(false);
1646
+ const attrMap = createAttributeProxy(false);
1647
+ this.__attributeMap = attrMap;
1648
+ return attrMap;
1641
1649
  }
1642
1650
  return this.__attributeMap;
1643
1651
  }
@@ -1645,10 +1653,10 @@ class MockElement extends MockNode {
1645
1653
  this.__attributeMap = attrs;
1646
1654
  }
1647
1655
  get children() {
1648
- return this.childNodes.filter((n) => n.nodeType === 1 /* ELEMENT_NODE */);
1656
+ return this.childNodes.filter((n) => n.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */);
1649
1657
  }
1650
1658
  get childElementCount() {
1651
- return this.childNodes.filter((n) => n.nodeType === 1 /* ELEMENT_NODE */).length;
1659
+ return this.childNodes.filter((n) => n.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */).length;
1652
1660
  }
1653
1661
  get className() {
1654
1662
  return this.getAttributeNS(null, 'class') || '';
@@ -1664,6 +1672,7 @@ class MockElement extends MockNode {
1664
1672
  }
1665
1673
  cloneNode(_deep) {
1666
1674
  // implemented on MockElement.prototype from within element.ts
1675
+ // @ts-ignore - implemented on MockElement.prototype from within element.ts
1667
1676
  return null;
1668
1677
  }
1669
1678
  closest(selector) {
@@ -1753,7 +1762,8 @@ class MockElement extends MockNode {
1753
1762
  });
1754
1763
  }
1755
1764
  set innerHTML(html) {
1756
- if (NON_ESCAPABLE_CONTENT.has(this.nodeName) === true) {
1765
+ var _a;
1766
+ if (NON_ESCAPABLE_CONTENT.has((_a = this.nodeName) !== null && _a !== void 0 ? _a : '') === true) {
1757
1767
  setTextContent(this, html);
1758
1768
  }
1759
1769
  else {
@@ -1865,9 +1875,9 @@ class MockElement extends MockNode {
1865
1875
  get nextElementSibling() {
1866
1876
  const parentElement = this.parentElement;
1867
1877
  if (parentElement != null &&
1868
- (parentElement.nodeType === 1 /* ELEMENT_NODE */ ||
1869
- parentElement.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */ ||
1870
- parentElement.nodeType === 9 /* DOCUMENT_NODE */)) {
1878
+ (parentElement.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */ ||
1879
+ parentElement.nodeType === 11 /* NODE_TYPES.DOCUMENT_FRAGMENT_NODE */ ||
1880
+ parentElement.nodeType === 9 /* NODE_TYPES.DOCUMENT_NODE */)) {
1871
1881
  const children = parentElement.children;
1872
1882
  const index = children.indexOf(this) + 1;
1873
1883
  return parentElement.children[index] || null;
@@ -1884,9 +1894,9 @@ class MockElement extends MockNode {
1884
1894
  get previousElementSibling() {
1885
1895
  const parentElement = this.parentElement;
1886
1896
  if (parentElement != null &&
1887
- (parentElement.nodeType === 1 /* ELEMENT_NODE */ ||
1888
- parentElement.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */ ||
1889
- parentElement.nodeType === 9 /* DOCUMENT_NODE */)) {
1897
+ (parentElement.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */ ||
1898
+ parentElement.nodeType === 11 /* NODE_TYPES.DOCUMENT_FRAGMENT_NODE */ ||
1899
+ parentElement.nodeType === 9 /* NODE_TYPES.DOCUMENT_NODE */)) {
1890
1900
  const children = parentElement.children;
1891
1901
  const index = children.indexOf(this) - 1;
1892
1902
  return parentElement.children[index] || null;
@@ -2019,7 +2029,8 @@ class MockElement extends MockNode {
2019
2029
  this.setAttributeNS(null, 'tabindex', value);
2020
2030
  }
2021
2031
  get tagName() {
2022
- return this.nodeName;
2032
+ var _a;
2033
+ return (_a = this.nodeName) !== null && _a !== void 0 ? _a : '';
2023
2034
  }
2024
2035
  set tagName(value) {
2025
2036
  this.nodeName = value;
@@ -2334,10 +2345,11 @@ function getElementsByClassName(elm, classNames, foundElms) {
2334
2345
  }
2335
2346
  }
2336
2347
  function getElementsByTagName(elm, tagName, foundElms) {
2348
+ var _a;
2337
2349
  const children = elm.children;
2338
2350
  for (let i = 0, ii = children.length; i < ii; i++) {
2339
2351
  const childElm = children[i];
2340
- if (tagName === '*' || childElm.nodeName.toLowerCase() === tagName) {
2352
+ if (tagName === '*' || ((_a = childElm.nodeName) !== null && _a !== void 0 ? _a : '').toLowerCase() === tagName) {
2341
2353
  foundElms.push(childElm);
2342
2354
  }
2343
2355
  getElementsByTagName(childElm, tagName, foundElms);
@@ -2376,14 +2388,17 @@ class MockHTMLElement extends MockElement {
2376
2388
  this.namespaceURI = 'http://www.w3.org/1999/xhtml';
2377
2389
  }
2378
2390
  get tagName() {
2379
- return this.nodeName;
2391
+ var _a;
2392
+ return (_a = this.nodeName) !== null && _a !== void 0 ? _a : '';
2380
2393
  }
2381
2394
  set tagName(value) {
2382
2395
  this.nodeName = value;
2383
2396
  }
2384
2397
  get attributes() {
2385
2398
  if (this.__attributeMap == null) {
2386
- this.__attributeMap = createAttributeProxy(true);
2399
+ const attrMap = createAttributeProxy(true);
2400
+ this.__attributeMap = attrMap;
2401
+ return attrMap;
2387
2402
  }
2388
2403
  return this.__attributeMap;
2389
2404
  }
@@ -2393,7 +2408,7 @@ class MockHTMLElement extends MockElement {
2393
2408
  }
2394
2409
  class MockTextNode extends MockNode {
2395
2410
  constructor(ownerDocument, text) {
2396
- super(ownerDocument, 3 /* TEXT_NODE */, "#text" /* TEXT_NODE */, text);
2411
+ super(ownerDocument, 3 /* NODE_TYPES.TEXT_NODE */, "#text" /* NODE_NAMES.TEXT_NODE */, text);
2397
2412
  }
2398
2413
  cloneNode(_deep) {
2399
2414
  return new MockTextNode(null, this.nodeValue);
@@ -2415,7 +2430,7 @@ class MockTextNode extends MockNode {
2415
2430
  const text = [];
2416
2431
  for (let i = 0, ii = this.parentNode.childNodes.length; i < ii; i++) {
2417
2432
  const childNode = this.parentNode.childNodes[i];
2418
- if (childNode.nodeType === 3 /* TEXT_NODE */) {
2433
+ if (childNode.nodeType === 3 /* NODE_TYPES.TEXT_NODE */) {
2419
2434
  text.push(childNode.nodeValue);
2420
2435
  }
2421
2436
  }
@@ -2427,10 +2442,10 @@ class MockTextNode extends MockNode {
2427
2442
  function getTextContent(childNodes, text) {
2428
2443
  for (let i = 0, ii = childNodes.length; i < ii; i++) {
2429
2444
  const childNode = childNodes[i];
2430
- if (childNode.nodeType === 3 /* TEXT_NODE */) {
2445
+ if (childNode.nodeType === 3 /* NODE_TYPES.TEXT_NODE */) {
2431
2446
  text.push(childNode.nodeValue);
2432
2447
  }
2433
- else if (childNode.nodeType === 1 /* ELEMENT_NODE */) {
2448
+ else if (childNode.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */) {
2434
2449
  getTextContent(childNode.childNodes, text);
2435
2450
  }
2436
2451
  }
@@ -2445,7 +2460,7 @@ function setTextContent(elm, text) {
2445
2460
 
2446
2461
  class MockComment extends MockNode {
2447
2462
  constructor(ownerDocument, data) {
2448
- super(ownerDocument, 8 /* COMMENT_NODE */, "#comment" /* COMMENT_NODE */, data);
2463
+ super(ownerDocument, 8 /* NODE_TYPES.COMMENT_NODE */, "#comment" /* NODE_NAMES.COMMENT_NODE */, data);
2449
2464
  }
2450
2465
  cloneNode(_deep) {
2451
2466
  return new MockComment(null, this.nodeValue);
@@ -2461,8 +2476,8 @@ class MockComment extends MockNode {
2461
2476
  class MockDocumentFragment extends MockHTMLElement {
2462
2477
  constructor(ownerDocument) {
2463
2478
  super(ownerDocument, null);
2464
- this.nodeName = "#document-fragment" /* DOCUMENT_FRAGMENT_NODE */;
2465
- this.nodeType = 11 /* DOCUMENT_FRAGMENT_NODE */;
2479
+ this.nodeName = "#document-fragment" /* NODE_NAMES.DOCUMENT_FRAGMENT_NODE */;
2480
+ this.nodeType = 11 /* NODE_TYPES.DOCUMENT_FRAGMENT_NODE */;
2466
2481
  }
2467
2482
  getElementById(id) {
2468
2483
  return getElementById(this, id);
@@ -2472,9 +2487,9 @@ class MockDocumentFragment extends MockHTMLElement {
2472
2487
  if (deep) {
2473
2488
  for (let i = 0, ii = this.childNodes.length; i < ii; i++) {
2474
2489
  const childNode = this.childNodes[i];
2475
- if (childNode.nodeType === 1 /* ELEMENT_NODE */ ||
2476
- childNode.nodeType === 3 /* TEXT_NODE */ ||
2477
- childNode.nodeType === 8 /* COMMENT_NODE */) {
2490
+ if (childNode.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */ ||
2491
+ childNode.nodeType === 3 /* NODE_TYPES.TEXT_NODE */ ||
2492
+ childNode.nodeType === 8 /* NODE_TYPES.COMMENT_NODE */) {
2478
2493
  const clonedChildNode = this.childNodes[i].cloneNode(true);
2479
2494
  cloned.appendChild(clonedChildNode);
2480
2495
  }
@@ -2487,7 +2502,7 @@ class MockDocumentFragment extends MockHTMLElement {
2487
2502
  class MockDocumentTypeNode extends MockHTMLElement {
2488
2503
  constructor(ownerDocument) {
2489
2504
  super(ownerDocument, '!DOCTYPE');
2490
- this.nodeType = 10 /* DOCUMENT_TYPE_NODE */;
2505
+ this.nodeType = 10 /* NODE_TYPES.DOCUMENT_TYPE_NODE */;
2491
2506
  this.setAttribute('html', '');
2492
2507
  }
2493
2508
  }
@@ -3632,6 +3647,7 @@ class MockNavigator {
3632
3647
  class MockPerformance {
3633
3648
  constructor() {
3634
3649
  this.timeOrigin = Date.now();
3650
+ this.eventCounts = new Map();
3635
3651
  }
3636
3652
  addEventListener() {
3637
3653
  //
@@ -4521,8 +4537,8 @@ function resetWindowDimensions(win) {
4521
4537
  class MockDocument extends MockHTMLElement {
4522
4538
  constructor(html = null, win = null) {
4523
4539
  super(null, null);
4524
- this.nodeName = "#document" /* DOCUMENT_NODE */;
4525
- this.nodeType = 9 /* DOCUMENT_NODE */;
4540
+ this.nodeName = "#document" /* NODE_NAMES.DOCUMENT_NODE */;
4541
+ this.nodeType = 9 /* NODE_TYPES.DOCUMENT_NODE */;
4526
4542
  this.defaultView = win;
4527
4543
  this.cookie = '';
4528
4544
  this.referrer = '';
@@ -4596,7 +4612,7 @@ class MockDocument extends MockHTMLElement {
4596
4612
  }
4597
4613
  set documentElement(documentElement) {
4598
4614
  for (let i = this.childNodes.length - 1; i >= 0; i--) {
4599
- if (this.childNodes[i].nodeType !== 10 /* DOCUMENT_TYPE_NODE */) {
4615
+ if (this.childNodes[i].nodeType !== 10 /* NODE_TYPES.DOCUMENT_TYPE_NODE */) {
4600
4616
  this.childNodes[i].remove();
4601
4617
  }
4602
4618
  }
@@ -4667,7 +4683,7 @@ class MockDocument extends MockHTMLElement {
4667
4683
  return new MockAttr(attrName, '', namespaceURI);
4668
4684
  }
4669
4685
  createElement(tagName) {
4670
- if (tagName === "#document" /* DOCUMENT_NODE */) {
4686
+ if (tagName === "#document" /* NODE_NAMES.DOCUMENT_NODE */) {
4671
4687
  const doc = new MockDocument(false);
4672
4688
  doc.nodeName = tagName;
4673
4689
  doc.parentNode = null;
@@ -4736,11 +4752,11 @@ function resetDocument(doc) {
4736
4752
  }
4737
4753
  }
4738
4754
  try {
4739
- doc.nodeName = "#document" /* DOCUMENT_NODE */;
4755
+ doc.nodeName = "#document" /* NODE_NAMES.DOCUMENT_NODE */;
4740
4756
  }
4741
4757
  catch (e) { }
4742
4758
  try {
4743
- doc.nodeType = 9 /* DOCUMENT_NODE */;
4759
+ doc.nodeType = 9 /* NODE_TYPES.DOCUMENT_NODE */;
4744
4760
  }
4745
4761
  catch (e) { }
4746
4762
  try {
@@ -4790,7 +4806,7 @@ function getElementsByName(elm, elmName, foundElms = []) {
4790
4806
  function setOwnerDocument(elm, ownerDocument) {
4791
4807
  for (let i = 0, ii = elm.childNodes.length; i < ii; i++) {
4792
4808
  elm.childNodes[i].ownerDocument = ownerDocument;
4793
- if (elm.childNodes[i].nodeType === 1 /* ELEMENT_NODE */) {
4809
+ if (elm.childNodes[i].nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */) {
4794
4810
  setOwnerDocument(elm.childNodes[i], ownerDocument);
4795
4811
  }
4796
4812
  }
@@ -7,7 +7,7 @@ declare class MockAttributeMap {
7
7
  setNamedItem(attr: MockAttr): void;
8
8
  setNamedItemNS(attr: MockAttr): void;
9
9
  getNamedItem(attrName: string): MockAttr;
10
- getNamedItemNS(namespaceURI: string, attrName: string): MockAttr;
10
+ getNamedItemNS(namespaceURI: string | null, attrName: string): MockAttr;
11
11
  removeNamedItem(attr: MockAttr): void;
12
12
  removeNamedItemNS(attr: MockAttr): void;
13
13
  [Symbol.iterator](): {
@@ -20,7 +20,7 @@ declare class MockAttributeMap {
20
20
  }
21
21
  declare function cloneAttributes(srcAttrs: MockAttributeMap, sortByName?: boolean): MockAttributeMap;
22
22
  declare class MockAttr {
23
- constructor(attrName: string, attrValue: string, namespaceURI?: string);
23
+ constructor(attrName: string, attrValue: string, namespaceURI?: string | null);
24
24
  get name(): string;
25
25
  set name(value: string);
26
26
  get value(): string;
@@ -108,7 +108,7 @@ declare class MockCustomElementRegistry implements CustomElementRegistry {
108
108
  declare function createCustomElement(customElements: MockCustomElementRegistry, ownerDocument: any, tagName: string): any;
109
109
  declare function connectNode(ownerDocument: any, node: MockNode): void;
110
110
  declare function disconnectNode(node: MockNode): void;
111
- declare function attributeChanged(node: MockNode, attrName: string, oldValue: string, newValue: string): void;
111
+ declare function attributeChanged(node: MockNode, attrName: string, oldValue: string | null, newValue: string | null): void;
112
112
  declare function checkAttributeChanged(node: MockNode): boolean;
113
113
  declare function dataset(elm: MockElement): any;
114
114
  declare class MockDocumentFragment extends MockHTMLElement {
@@ -471,12 +471,12 @@ declare class MockNavigator {
471
471
  userAgent: string;
472
472
  }
473
473
  declare class MockNode {
474
- nodeName: string;
474
+ nodeName: string | null;
475
475
  nodeType: number;
476
476
  ownerDocument: any;
477
- parentNode: MockNode;
477
+ parentNode: MockNode | null;
478
478
  childNodes: MockNode[];
479
- constructor(ownerDocument: any, nodeType: number, nodeName: string, nodeValue: string);
479
+ constructor(ownerDocument: any, nodeType: number, nodeName: string | null, nodeValue: string | null);
480
480
  appendChild(newNode: MockNode): MockNode;
481
481
  append(...items: (MockNode | string)[]): void;
482
482
  prepend(...items: (MockNode | string)[]): void;
@@ -514,8 +514,8 @@ declare class MockNodeList {
514
514
  constructor(ownerDocument: any, childNodes: MockNode[], length: number);
515
515
  }
516
516
  declare class MockElement extends MockNode {
517
- namespaceURI: string;
518
- constructor(ownerDocument: any, nodeName: string);
517
+ namespaceURI: string | null;
518
+ constructor(ownerDocument: any, nodeName: string | null);
519
519
  addEventListener(type: string, handler: (ev?: any) => void): void;
520
520
  attachShadow(_opts: ShadowRootInit): any;
521
521
  blur(): void;
@@ -540,7 +540,7 @@ declare class MockElement extends MockNode {
540
540
  preventScroll?: boolean;
541
541
  }): void;
542
542
  getAttribute(attrName: string): any;
543
- getAttributeNS(namespaceURI: string, attrName: string): string;
543
+ getAttributeNS(namespaceURI: string | null, attrName: string): string;
544
544
  getBoundingClientRect(): {
545
545
  bottom: number;
546
546
  height: number;
@@ -568,7 +568,7 @@ declare class MockElement extends MockNode {
568
568
  insertAdjacentHTML(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', html: string): void;
569
569
  insertAdjacentText(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', text: string): void;
570
570
  hasAttribute(attrName: string): boolean;
571
- hasAttributeNS(namespaceURI: string, name: string): boolean;
571
+ hasAttributeNS(namespaceURI: string | null, name: string): boolean;
572
572
  get hidden(): boolean;
573
573
  set hidden(isHidden: boolean);
574
574
  get lang(): string;
@@ -583,10 +583,10 @@ declare class MockElement extends MockNode {
583
583
  querySelector(selector: string): Element;
584
584
  querySelectorAll(selector: string): Element[];
585
585
  removeAttribute(attrName: string): void;
586
- removeAttributeNS(namespaceURI: string, attrName: string): void;
586
+ removeAttributeNS(namespaceURI: string | null, attrName: string): void;
587
587
  removeEventListener(type: string, handler: any): void;
588
588
  setAttribute(attrName: string, value: any): void;
589
- setAttributeNS(namespaceURI: string, attrName: string, value: any): void;
589
+ setAttributeNS(namespaceURI: string | null, attrName: string, value: any): void;
590
590
  get style(): any;
591
591
  set style(val: any);
592
592
  get tabIndex(): number;
@@ -723,6 +723,7 @@ declare class MockDOMParser {
723
723
  */
724
724
  declare class MockPerformance implements Performance {
725
725
  timeOrigin: number;
726
+ eventCounts: EventCounts;
726
727
  constructor();
727
728
  addEventListener(): void;
728
729
  clearMarks(): void;