happy-dom 2.41.0 → 2.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of happy-dom might be problematic. Click here for more details.

Files changed (48) hide show
  1. package/lib/css/CSSStyleDeclaration.js +1 -1
  2. package/lib/css/CSSStyleDeclaration.js.map +1 -1
  3. package/lib/dom-token-list/DOMTokenList.d.ts +104 -0
  4. package/lib/dom-token-list/DOMTokenList.js +209 -0
  5. package/lib/dom-token-list/DOMTokenList.js.map +1 -0
  6. package/lib/dom-token-list/IDOMTokenList.d.ts +18 -0
  7. package/lib/dom-token-list/IDOMTokenList.js +3 -0
  8. package/lib/dom-token-list/IDOMTokenList.js.map +1 -0
  9. package/lib/nodes/document/Document.d.ts +7 -0
  10. package/lib/nodes/document/Document.js +12 -0
  11. package/lib/nodes/document/Document.js.map +1 -1
  12. package/lib/nodes/document/IDocument.d.ts +13 -2
  13. package/lib/nodes/element/Element.d.ts +15 -5
  14. package/lib/nodes/element/Element.js +28 -3
  15. package/lib/nodes/element/Element.js.map +1 -1
  16. package/lib/nodes/element/IElement.d.ts +2 -2
  17. package/lib/nodes/html-label-element/HTMLLabelElement.d.ts +0 -1
  18. package/lib/nodes/html-label-element/HTMLLabelElement.js +2 -6
  19. package/lib/nodes/html-label-element/HTMLLabelElement.js.map +1 -1
  20. package/lib/nodes/html-link-element/HTMLLinkElement.d.ts +12 -0
  21. package/lib/nodes/html-link-element/HTMLLinkElement.js +26 -0
  22. package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
  23. package/lib/nodes/html-link-element/IHTMLLinkElement.d.ts +2 -0
  24. package/lib/query-selector/SelectorItem.d.ts +18 -2
  25. package/lib/query-selector/SelectorItem.js +54 -25
  26. package/lib/query-selector/SelectorItem.js.map +1 -1
  27. package/lib/window/IWindow.d.ts +3 -1
  28. package/lib/window/Window.d.ts +1 -0
  29. package/lib/window/Window.js +1 -0
  30. package/lib/window/Window.js.map +1 -1
  31. package/package.json +2 -2
  32. package/src/css/CSSStyleDeclaration.ts +1 -1
  33. package/src/dom-token-list/DOMTokenList.ts +219 -0
  34. package/src/dom-token-list/IDOMTokenList.ts +19 -0
  35. package/src/nodes/document/Document.ts +10 -0
  36. package/src/nodes/document/IDocument.ts +13 -2
  37. package/src/nodes/element/Element.ts +30 -3
  38. package/src/nodes/element/IElement.ts +2 -2
  39. package/src/nodes/html-label-element/HTMLLabelElement.ts +1 -5
  40. package/src/nodes/html-link-element/HTMLLinkElement.ts +26 -0
  41. package/src/nodes/html-link-element/IHTMLLinkElement.ts +2 -0
  42. package/src/query-selector/SelectorItem.ts +62 -26
  43. package/src/window/IWindow.ts +3 -1
  44. package/src/window/Window.ts +1 -0
  45. package/lib/nodes/element/ClassList.d.ts +0 -40
  46. package/lib/nodes/element/ClassList.js +0 -99
  47. package/lib/nodes/element/ClassList.js.map +0 -1
  48. package/src/nodes/element/ClassList.ts +0 -92
@@ -1,99 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var DOMException_1 = __importDefault(require("../../exception/DOMException"));
7
- /**
8
- * Class list.
9
- */
10
- var ClassList = /** @class */ (function () {
11
- /**
12
- * Adds class names.
13
- *
14
- * @param ownerElement Owner element.
15
- */
16
- function ClassList(ownerElement) {
17
- this._ownerElement = ownerElement;
18
- }
19
- /**
20
- * Adds class names.
21
- *
22
- * @param classNames Class names.
23
- */
24
- ClassList.prototype.add = function () {
25
- var classNames = [];
26
- for (var _i = 0; _i < arguments.length; _i++) {
27
- classNames[_i] = arguments[_i];
28
- }
29
- var attr = this._ownerElement.getAttribute('class');
30
- var list = attr ? attr.split(' ') : [];
31
- for (var _a = 0, classNames_1 = classNames; _a < classNames_1.length; _a++) {
32
- var className = classNames_1[_a];
33
- if (!list.includes(className)) {
34
- if (className.includes(' ')) {
35
- throw new DOMException_1.default("Failed to execute 'add' on 'DOMTokenList': The token provided ('".concat(className, "') contains HTML space characters, which are not valid in tokens."));
36
- }
37
- list.push(className);
38
- }
39
- }
40
- this._ownerElement.setAttribute('class', list.join(' '));
41
- };
42
- /**
43
- * Adds class names.
44
- *
45
- * @param classNames Class names.
46
- */
47
- ClassList.prototype.remove = function () {
48
- var classNames = [];
49
- for (var _i = 0; _i < arguments.length; _i++) {
50
- classNames[_i] = arguments[_i];
51
- }
52
- var attr = this._ownerElement.getAttribute('class');
53
- var list = attr ? attr.split(' ') : [];
54
- for (var _a = 0, classNames_2 = classNames; _a < classNames_2.length; _a++) {
55
- var className = classNames_2[_a];
56
- var index = list.indexOf(className);
57
- if (index !== -1) {
58
- list.splice(index, 1);
59
- }
60
- }
61
- this._ownerElement.setAttribute('class', list.join(' '));
62
- };
63
- /**
64
- * Check if the list contains a class.
65
- *
66
- * @param className Class name.
67
- * @returns TRUE if it contains.
68
- */
69
- ClassList.prototype.contains = function (className) {
70
- var attr = this._ownerElement.getAttribute('class');
71
- var list = attr ? attr.split(' ') : [];
72
- return list.includes(className);
73
- };
74
- /**
75
- * Toggle a class name.
76
- *
77
- * @param className A string representing the class name you want to toggle.
78
- * @param force If included, turns the toggle into a one way-only operation. If set to `false`, then class name will only be removed, but not added. If set to `true`, then class name will only be added, but not removed.
79
- * @returns A boolean value, `true` or `false`, indicating whether class name is in the list after the call or not.
80
- */
81
- ClassList.prototype.toggle = function (className, force) {
82
- var shouldAdd;
83
- if (force !== undefined) {
84
- shouldAdd = force;
85
- }
86
- else {
87
- shouldAdd = !this.contains(className);
88
- }
89
- if (shouldAdd) {
90
- this.add(className);
91
- return true;
92
- }
93
- this.remove(className);
94
- return false;
95
- };
96
- return ClassList;
97
- }());
98
- exports.default = ClassList;
99
- //# sourceMappingURL=ClassList.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClassList.js","sourceRoot":"","sources":["../../../src/nodes/element/ClassList.ts"],"names":[],"mappings":";;;;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AV,IAAU,EAAE;YAA/B,IAAM,SAAS,mBAAA;YACnB,IAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACtC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;gBACjB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;aACtB;SACD;QACD,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;OAKG;IACI,4BAAQ,GAAf,UAAgB,SAAiB;QAChC,IAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACtD,IAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;OAMG;IACI,0BAAM,GAAb,UAAc,SAAiB,EAAE,KAAe;QAC/C,IAAI,SAAkB,CAAC;QACvB,IAAI,KAAK,KAAK,SAAS,EAAE;YACxB,SAAS,GAAG,KAAK,CAAC;SAClB;aAAM;YACN,SAAS,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;SACtC;QAED,IAAI,SAAS,EAAE;YACd,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACpB,OAAO,IAAI,CAAC;SACZ;QAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;IACd,CAAC;IACF,gBAAC;AAAD,CAAC,AArFD,IAqFC"}
@@ -1,92 +0,0 @@
1
- import DOMException from '../../exception/DOMException';
2
- import Element from './Element';
3
-
4
- /**
5
- * Class list.
6
- */
7
- export default class ClassList {
8
- private _ownerElement: Element;
9
-
10
- /**
11
- * Adds class names.
12
- *
13
- * @param ownerElement Owner element.
14
- */
15
- constructor(ownerElement: Element) {
16
- this._ownerElement = ownerElement;
17
- }
18
-
19
- /**
20
- * Adds class names.
21
- *
22
- * @param classNames Class names.
23
- */
24
- public add(...classNames: string[]): void {
25
- const attr = this._ownerElement.getAttribute('class');
26
- const list = attr ? attr.split(' ') : [];
27
- for (const className of classNames) {
28
- if (!list.includes(className)) {
29
- if (className.includes(' ')) {
30
- throw new DOMException(
31
- `Failed to execute 'add' on 'DOMTokenList': The token provided ('${className}') contains HTML space characters, which are not valid in tokens.`
32
- );
33
- }
34
- list.push(className);
35
- }
36
- }
37
- this._ownerElement.setAttribute('class', list.join(' '));
38
- }
39
-
40
- /**
41
- * Adds class names.
42
- *
43
- * @param classNames Class names.
44
- */
45
- public remove(...classNames: string[]): void {
46
- const attr = this._ownerElement.getAttribute('class');
47
- const list = attr ? attr.split(' ') : [];
48
- for (const className of classNames) {
49
- const index = list.indexOf(className);
50
- if (index !== -1) {
51
- list.splice(index, 1);
52
- }
53
- }
54
- this._ownerElement.setAttribute('class', list.join(' '));
55
- }
56
-
57
- /**
58
- * Check if the list contains a class.
59
- *
60
- * @param className Class name.
61
- * @returns TRUE if it contains.
62
- */
63
- public contains(className: string): boolean {
64
- const attr = this._ownerElement.getAttribute('class');
65
- const list = attr ? attr.split(' ') : [];
66
- return list.includes(className);
67
- }
68
-
69
- /**
70
- * Toggle a class name.
71
- *
72
- * @param className A string representing the class name you want to toggle.
73
- * @param force If included, turns the toggle into a one way-only operation. If set to `false`, then class name will only be removed, but not added. If set to `true`, then class name will only be added, but not removed.
74
- * @returns A boolean value, `true` or `false`, indicating whether class name is in the list after the call or not.
75
- */
76
- public toggle(className: string, force?: boolean): boolean {
77
- let shouldAdd: boolean;
78
- if (force !== undefined) {
79
- shouldAdd = force;
80
- } else {
81
- shouldAdd = !this.contains(className);
82
- }
83
-
84
- if (shouldAdd) {
85
- this.add(className);
86
- return true;
87
- }
88
-
89
- this.remove(className);
90
- return false;
91
- }
92
- }