happy-dom 16.7.3 → 16.8.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.
@@ -1,15 +1,91 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ const QuerySelector_js_1 = __importDefault(require("../../query-selector/QuerySelector.cjs"));
30
+ const PropertySymbol = __importStar(require("../../PropertySymbol.cjs"));
6
31
  const HTMLElement_js_1 = __importDefault(require("../html-element/HTMLElement.cjs"));
32
+ const DOMExceptionNameEnum_js_1 = __importDefault(require("../../exception/DOMExceptionNameEnum.cjs"));
7
33
  /**
8
34
  * HTMLTableSectionElement
9
35
  *
10
36
  * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableSectionElement
11
37
  */
12
38
  class HTMLTableSectionElement extends HTMLElement_js_1.default {
39
+ /**
40
+ * Returns an HTMLTableRowElement representing a new row of the table. It inserts it in the rows collection immediately before the <tr> element at the given index position. If the index is -1, the new row is appended to the collection. If the index is smaller than -1 or greater than the number of rows in the collection, a DOMException with the value IndexSizeError is raised.
41
+ *
42
+ * @param [index] Index.
43
+ * @returns Row.
44
+ */
45
+ insertRow(index = -1) {
46
+ if (typeof index !== 'number') {
47
+ index = -1;
48
+ }
49
+ const rows = QuerySelector_js_1.default.querySelectorAll(this, 'tr')[PropertySymbol.items];
50
+ if (index < -1) {
51
+ throw new this[PropertySymbol.window].DOMException(`Failed to execute 'insertRow' on 'HTMLTableSectionElement': The index provided (${index}) is less than -1.`, DOMExceptionNameEnum_js_1.default.indexSizeError);
52
+ }
53
+ if (index > rows.length) {
54
+ throw new this[PropertySymbol.window].DOMException(`Failed to execute 'insertRow' on 'HTMLTableSectionElement': The index provided (${index}) is greater than the number of rows (${rows.length}).`, DOMExceptionNameEnum_js_1.default.indexSizeError);
55
+ }
56
+ const row = this[PropertySymbol.ownerDocument].createElement('tr');
57
+ if (index === -1 || index === rows.length) {
58
+ this.appendChild(row);
59
+ }
60
+ else {
61
+ this.insertBefore(row, rows[index]);
62
+ }
63
+ return row;
64
+ }
65
+ /**
66
+ * Removes the row corresponding to the index given in parameter. If the index value is -1 the last row is removed; if it is smaller than -1 or greater than the amount of rows in the collection, a DOMException with the value IndexSizeError is raised.
67
+ *
68
+ * @param index Index.
69
+ */
70
+ deleteRow(index) {
71
+ if (arguments.length === 0) {
72
+ throw new this[PropertySymbol.window].TypeError("Failed to execute 'deleteRow' on 'HTMLTableSectionElement': 1 argument required, but only 0 present.");
73
+ }
74
+ if (typeof index !== 'number') {
75
+ index = -1;
76
+ }
77
+ if (index < -1) {
78
+ throw new this[PropertySymbol.window].DOMException(`Failed to execute 'deleteRow' on 'HTMLTableSectionElement': The index provided (${index}) is less than -1.`, DOMExceptionNameEnum_js_1.default.indexSizeError);
79
+ }
80
+ const rows = QuerySelector_js_1.default.querySelectorAll(this, 'tr')[PropertySymbol.items];
81
+ if (index >= rows.length) {
82
+ throw new this[PropertySymbol.window].DOMException(`Failed to execute 'deleteRow' on 'HTMLTableSectionElement': The index provided (${index}) is greater than the number of rows in the table (${rows.length}).`, DOMExceptionNameEnum_js_1.default.indexSizeError);
83
+ }
84
+ if (index === -1) {
85
+ index = rows.length - 1;
86
+ }
87
+ rows[index].remove();
88
+ }
13
89
  }
14
90
  exports.default = HTMLTableSectionElement;
15
91
  //# sourceMappingURL=HTMLTableSectionElement.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"HTMLTableSectionElement.cjs","sourceRoot":"","sources":["../../../src/nodes/html-table-section-element/HTMLTableSectionElement.ts"],"names":[],"mappings":";;;;;AAAA,oFAAyD;AACzD;;;;GAIG;AACH,MAAqB,uBAAwB,SAAQ,wBAAW;CAAG;AAAnE,0CAAmE"}
1
+ {"version":3,"file":"HTMLTableSectionElement.cjs","sourceRoot":"","sources":["../../../src/nodes/html-table-section-element/HTMLTableSectionElement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6FAAkE;AAClE,wEAA0D;AAC1D,oFAAyD;AAEzD,sGAA2E;AAC3E;;;;GAIG;AACH,MAAqB,uBAAwB,SAAQ,wBAAW;IAC/D;;;;;OAKG;IACI,SAAS,CAAC,QAAgB,CAAC,CAAC;QAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/B,KAAK,GAAG,CAAC,CAAC,CAAC;QACZ,CAAC;QAED,MAAM,IAAI,GAAG,0BAAa,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAE9E,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;YAChB,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,YAAY,CACjD,mFAAmF,KAAK,oBAAoB,EAC5G,iCAAoB,C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;QAE9E,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,YAAY,CACjD,mFAAmF,KAAK,sDAAsD,IAAI,CAAC,MAAM,IAAI,EAC7J,iCAAoB,CAAC,cAAc,CACnC,CAAC;QACH,CAAC;QAED,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YAClB,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACzB,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IACtB,CAAC;CACD;AA7ED,0CA6EC"}
@@ -1,9 +1,23 @@
1
1
  import HTMLElement from '../html-element/HTMLElement.cjs';
2
+ import HTMLTableRowElement from '../html-table-row-element/HTMLTableRowElement.cjs';
2
3
  /**
3
4
  * HTMLTableSectionElement
4
5
  *
5
6
  * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableSectionElement
6
7
  */
7
8
  export default class HTMLTableSectionElement extends HTMLElement {
9
+ /**
10
+ * Returns an HTMLTableRowElement representing a new row of the table. It inserts it in the rows collection immediately before the <tr> element at the given index position. If the index is -1, the new row is appended to the collection. If the index is smaller than -1 or greater than the number of rows in the collection, a DOMException with the value IndexSizeError is raised.
11
+ *
12
+ * @param [index] Index.
13
+ * @returns Row.
14
+ */
15
+ insertRow(index?: number): HTMLTableRowElement;
16
+ /**
17
+ * Removes the row corresponding to the index given in parameter. If the index value is -1 the last row is removed; if it is smaller than -1 or greater than the amount of rows in the collection, a DOMException with the value IndexSizeError is raised.
18
+ *
19
+ * @param index Index.
20
+ */
21
+ deleteRow(index: number): void;
8
22
  }
9
23
  //# sourceMappingURL=HTMLTableSectionElement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HTMLTableSectionElement.d.ts","sourceRoot":"","sources":["../../../src/nodes/html-table-section-element/HTMLTableSectionElement.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,WAAW;CAAG"}
1
+ {"version":3,"file":"HTMLTableSectionElement.d.ts","sourceRoot":"","sources":["../../../src/nodes/html-table-section-element/HTMLTableSectionElement.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD,OAAO,mBAAmB,MAAM,kDAAkD,CAAC;AAEnF;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,WAAW;IAC/D;;;;;OAKG;IACI,SAAS,CAAC,KAAK,GAAE,MAAW,GAAG,mBAAmB;IAgCzD;;;;OAIG;IACI,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAiCrC"}
@@ -1,9 +1,23 @@
1
1
  import HTMLElement from '../html-element/HTMLElement.js';
2
+ import HTMLTableRowElement from '../html-table-row-element/HTMLTableRowElement.js';
2
3
  /**
3
4
  * HTMLTableSectionElement
4
5
  *
5
6
  * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableSectionElement
6
7
  */
7
8
  export default class HTMLTableSectionElement extends HTMLElement {
9
+ /**
10
+ * Returns an HTMLTableRowElement representing a new row of the table. It inserts it in the rows collection immediately before the <tr> element at the given index position. If the index is -1, the new row is appended to the collection. If the index is smaller than -1 or greater than the number of rows in the collection, a DOMException with the value IndexSizeError is raised.
11
+ *
12
+ * @param [index] Index.
13
+ * @returns Row.
14
+ */
15
+ insertRow(index?: number): HTMLTableRowElement;
16
+ /**
17
+ * Removes the row corresponding to the index given in parameter. If the index value is -1 the last row is removed; if it is smaller than -1 or greater than the amount of rows in the collection, a DOMException with the value IndexSizeError is raised.
18
+ *
19
+ * @param index Index.
20
+ */
21
+ deleteRow(index: number): void;
8
22
  }
9
23
  //# sourceMappingURL=HTMLTableSectionElement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HTMLTableSectionElement.d.ts","sourceRoot":"","sources":["../../../src/nodes/html-table-section-element/HTMLTableSectionElement.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,WAAW;CAAG"}
1
+ {"version":3,"file":"HTMLTableSectionElement.d.ts","sourceRoot":"","sources":["../../../src/nodes/html-table-section-element/HTMLTableSectionElement.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD,OAAO,mBAAmB,MAAM,kDAAkD,CAAC;AAEnF;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,WAAW;IAC/D;;;;;OAKG;IACI,SAAS,CAAC,KAAK,GAAE,MAAW,GAAG,mBAAmB;IAgCzD;;;;OAIG;IACI,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAiCrC"}
@@ -1,9 +1,62 @@
1
+ import QuerySelector from '../../query-selector/QuerySelector.js';
2
+ import * as PropertySymbol from '../../PropertySymbol.js';
1
3
  import HTMLElement from '../html-element/HTMLElement.js';
4
+ import DOMExceptionNameEnum from '../../exception/DOMExceptionNameEnum.js';
2
5
  /**
3
6
  * HTMLTableSectionElement
4
7
  *
5
8
  * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableSectionElement
6
9
  */
7
10
  export default class HTMLTableSectionElement extends HTMLElement {
11
+ /**
12
+ * Returns an HTMLTableRowElement representing a new row of the table. It inserts it in the rows collection immediately before the <tr> element at the given index position. If the index is -1, the new row is appended to the collection. If the index is smaller than -1 or greater than the number of rows in the collection, a DOMException with the value IndexSizeError is raised.
13
+ *
14
+ * @param [index] Index.
15
+ * @returns Row.
16
+ */
17
+ insertRow(index = -1) {
18
+ if (typeof index !== 'number') {
19
+ index = -1;
20
+ }
21
+ const rows = QuerySelector.querySelectorAll(this, 'tr')[PropertySymbol.items];
22
+ if (index < -1) {
23
+ throw new this[PropertySymbol.window].DOMException(`Failed to execute 'insertRow' on 'HTMLTableSectionElement': The index provided (${index}) is less than -1.`, DOMExceptionNameEnum.indexSizeError);
24
+ }
25
+ if (index > rows.length) {
26
+ throw new this[PropertySymbol.window].DOMException(`Failed to execute 'insertRow' on 'HTMLTableSectionElement': The index provided (${index}) is greater than the number of rows (${rows.length}).`, DOMExceptionNameEnum.indexSizeError);
27
+ }
28
+ const row = this[PropertySymbol.ownerDocument].createElement('tr');
29
+ if (index === -1 || index === rows.length) {
30
+ this.appendChild(row);
31
+ }
32
+ else {
33
+ this.insertBefore(row, rows[index]);
34
+ }
35
+ return row;
36
+ }
37
+ /**
38
+ * Removes the row corresponding to the index given in parameter. If the index value is -1 the last row is removed; if it is smaller than -1 or greater than the amount of rows in the collection, a DOMException with the value IndexSizeError is raised.
39
+ *
40
+ * @param index Index.
41
+ */
42
+ deleteRow(index) {
43
+ if (arguments.length === 0) {
44
+ throw new this[PropertySymbol.window].TypeError("Failed to execute 'deleteRow' on 'HTMLTableSectionElement': 1 argument required, but only 0 present.");
45
+ }
46
+ if (typeof index !== 'number') {
47
+ index = -1;
48
+ }
49
+ if (index < -1) {
50
+ throw new this[PropertySymbol.window].DOMException(`Failed to execute 'deleteRow' on 'HTMLTableSectionElement': The index provided (${index}) is less than -1.`, DOMExceptionNameEnum.indexSizeError);
51
+ }
52
+ const rows = QuerySelector.querySelectorAll(this, 'tr')[PropertySymbol.items];
53
+ if (index >= rows.length) {
54
+ throw new this[PropertySymbol.window].DOMException(`Failed to execute 'deleteRow' on 'HTMLTableSectionElement': The index provided (${index}) is greater than the number of rows in the table (${rows.length}).`, DOMExceptionNameEnum.indexSizeError);
55
+ }
56
+ if (index === -1) {
57
+ index = rows.length - 1;
58
+ }
59
+ rows[index].remove();
60
+ }
8
61
  }
9
62
  //# sourceMappingURL=HTMLTableSectionElement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HTMLTableSectionElement.js","sourceRoot":"","sources":["../../../src/nodes/html-table-section-element/HTMLTableSectionElement.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,WAAW;CAAG"}
1
+ {"version":3,"file":"HTMLTableSectionElement.js","sourceRoot":"","sources":["../../../src/nodes/html-table-section-element/HTMLTableSectionElement.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,uCAAuC,CAAC;AAClE,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAC1D,OAAO,WAAW,MAAM,gCAAgC,CAAC;AAEzD,OAAO,oBAAoB,MAAM,yCAAyC,CAAC;AAC3E;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,WAAW;IAC/D;;;;;OAKG;IACI,SAAS,CAAC,QAAgB,CAAC,CAAC;QAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/B,KAAK,GAAG,CAAC,CAAC,CAAC;QACZ,CAAC;QAED,MAAM,IAAI,GAAG,aAAa,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAE9E,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;YAChB,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,YAAY,CACjD,mFAAmF,KAAK,oBAAoB,EAC5G,oBAAoB,CAAC,cAAc,CACnC,CAAC;QACH,CAAC;QAED,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YACzB,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,YAAY,CACjD,mFAAmF,KAAK,yCAAyC,IAAI,CAAC,MAAM,IAAI,EAChJ,oBAAoB,CAAC,cAAc,CACnC,CAAC;QACH,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,aAAa,CAAC,IAAI,C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AED,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IACtB,CAAC;CACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "happy-dom",
3
- "version": "16.7.3",
3
+ "version": "16.8.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/capricorn86/happy-dom",
6
6
  "repository": "https://github.com/capricorn86/happy-dom",
@@ -1,7 +1,88 @@
1
+ import QuerySelector from '../../query-selector/QuerySelector.js';
2
+ import * as PropertySymbol from '../../PropertySymbol.js';
1
3
  import HTMLElement from '../html-element/HTMLElement.js';
4
+ import HTMLTableRowElement from '../html-table-row-element/HTMLTableRowElement.js';
5
+ import DOMExceptionNameEnum from '../../exception/DOMExceptionNameEnum.js';
2
6
  /**
3
7
  * HTMLTableSectionElement
4
8
  *
5
9
  * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableSectionElement
6
10
  */
7
- export default class HTMLTableSectionElement extends HTMLElement {}
11
+ export default class HTMLTableSectionElement extends HTMLElement {
12
+ /**
13
+ * Returns an HTMLTableRowElement representing a new row of the table. It inserts it in the rows collection immediately before the <tr> element at the given index position. If the index is -1, the new row is appended to the collection. If the index is smaller than -1 or greater than the number of rows in the collection, a DOMException with the value IndexSizeError is raised.
14
+ *
15
+ * @param [index] Index.
16
+ * @returns Row.
17
+ */
18
+ public insertRow(index: number = -1): HTMLTableRowElement {
19
+ if (typeof index !== 'number') {
20
+ index = -1;
21
+ }
22
+
23
+ const rows = QuerySelector.querySelectorAll(this, 'tr')[PropertySymbol.items];
24
+
25
+ if (index < -1) {
26
+ throw new this[PropertySymbol.window].DOMException(
27
+ `Failed to execute 'insertRow' on 'HTMLTableSectionElement': The index provided (${index}) is less than -1.`,
28
+ DOMExceptionNameEnum.indexSizeError
29
+ );
30
+ }
31
+
32
+ if (index > rows.length) {
33
+ throw new this[PropertySymbol.window].DOMException(
34
+ `Failed to execute 'insertRow' on 'HTMLTableSectionElement': The index provided (${index}) is greater than the number of rows (${rows.length}).`,
35
+ DOMExceptionNameEnum.indexSizeError
36
+ );
37
+ }
38
+
39
+ const row = this[PropertySymbol.ownerDocument].createElement('tr');
40
+
41
+ if (index === -1 || index === rows.length) {
42
+ this.appendChild(row);
43
+ } else {
44
+ this.insertBefore(row, rows[index]);
45
+ }
46
+
47
+ return row;
48
+ }
49
+
50
+ /**
51
+ * Removes the row corresponding to the index given in parameter. If the index value is -1 the last row is removed; if it is smaller than -1 or greater than the amount of rows in the collection, a DOMException with the value IndexSizeError is raised.
52
+ *
53
+ * @param index Index.
54
+ */
55
+ public deleteRow(index: number): void {
56
+ if (arguments.length === 0) {
57
+ throw new this[PropertySymbol.window].TypeError(
58
+ "Failed to execute 'deleteRow' on 'HTMLTableSectionElement': 1 argument required, but only 0 present."
59
+ );
60
+ }
61
+
62
+ if (typeof index !== 'number') {
63
+ index = -1;
64
+ }
65
+
66
+ if (index < -1) {
67
+ throw new this[PropertySymbol.window].DOMException(
68
+ `Failed to execute 'deleteRow' on 'HTMLTableSectionElement': The index provided (${index}) is less than -1.`,
69
+ DOMExceptionNameEnum.indexSizeError
70
+ );
71
+ }
72
+
73
+ const rows = QuerySelector.querySelectorAll(this, 'tr')[PropertySymbol.items];
74
+
75
+ if (index >= rows.length) {
76
+ throw new this[PropertySymbol.window].DOMException(
77
+ `Failed to execute 'deleteRow' on 'HTMLTableSectionElement': The index provided (${index}) is greater than the number of rows in the table (${rows.length}).`,
78
+ DOMExceptionNameEnum.indexSizeError
79
+ );
80
+ }
81
+
82
+ if (index === -1) {
83
+ index = rows.length - 1;
84
+ }
85
+
86
+ rows[index].remove();
87
+ }
88
+ }