happy-dom 2.28.0 → 2.31.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.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/lib/config/ElementTag.d.ts +2 -0
- package/lib/config/ElementTag.js +2 -0
- package/lib/config/ElementTag.js.map +1 -1
- package/lib/event/NonImplementedEventTypes.js +0 -1
- package/lib/event/NonImplementedEventTypes.js.map +1 -1
- package/lib/event/events/CustomEvent.d.ts +10 -0
- package/lib/event/events/CustomEvent.js +18 -0
- package/lib/event/events/CustomEvent.js.map +1 -1
- package/lib/event/events/IStorageEventInit.d.ts +8 -0
- package/lib/event/events/IStorageEventInit.js +3 -0
- package/lib/event/events/IStorageEventInit.js.map +1 -0
- package/lib/event/events/StorageEvent.d.ts +19 -0
- package/lib/event/events/StorageEvent.js +51 -0
- package/lib/event/events/StorageEvent.js.map +1 -0
- package/lib/nodes/document/Document.d.ts +6 -2
- package/lib/nodes/document/Document.js +15 -2
- package/lib/nodes/document/Document.js.map +1 -1
- package/lib/nodes/element/Element.d.ts +12 -0
- package/lib/nodes/element/Element.js +20 -0
- package/lib/nodes/element/Element.js.map +1 -1
- package/lib/nodes/element/HTMLCollection.d.ts +13 -0
- package/lib/nodes/element/HTMLCollection.js +37 -0
- package/lib/nodes/element/HTMLCollection.js.map +1 -0
- package/lib/nodes/element/IElement.d.ts +1 -0
- package/lib/nodes/html-slot-element/HTMLSlotElement.d.ts +59 -0
- package/lib/nodes/html-slot-element/HTMLSlotElement.js +126 -0
- package/lib/nodes/html-slot-element/HTMLSlotElement.js.map +1 -0
- package/lib/nodes/html-slot-element/IHTMLSlotElement.d.ts +46 -0
- package/lib/nodes/html-slot-element/IHTMLSlotElement.js +3 -0
- package/lib/nodes/html-slot-element/IHTMLSlotElement.js.map +1 -0
- package/lib/nodes/node/INode.d.ts +2 -1
- package/lib/nodes/node/NodeList.d.ts +13 -0
- package/lib/nodes/node/NodeList.js +37 -0
- package/lib/nodes/node/NodeList.js.map +1 -0
- package/lib/window/IWindow.d.ts +12 -0
- package/lib/window/Window.d.ts +6 -0
- package/lib/window/Window.js +6 -0
- package/lib/window/Window.js.map +1 -1
- package/package.json +2 -2
- package/src/config/ElementTag.ts +2 -0
- package/src/event/NonImplementedEventTypes.ts +0 -1
- package/src/event/events/CustomEvent.ts +21 -0
- package/src/event/events/IStorageEventInit.ts +9 -0
- package/src/event/events/StorageEvent.ts +30 -0
- package/src/nodes/document/Document.ts +18 -2
- package/src/nodes/element/Element.ts +18 -0
- package/src/nodes/element/HTMLCollection.ts +16 -0
- package/src/nodes/element/IElement.ts +1 -0
- package/src/nodes/html-slot-element/HTMLSlotElement.ts +110 -0
- package/src/nodes/html-slot-element/IHTMLSlotElement.ts +47 -0
- package/src/nodes/node/INode.ts +2 -1
- package/src/nodes/node/NodeList.ts +16 -0
- package/src/window/IWindow.ts +12 -0
- package/src/window/Window.ts +6 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
import HTMLElement from '../html-element/HTMLElement';
|
2
|
+
import IShadowRoot from '../shadow-root/IShadowRoot';
|
3
|
+
import IHTMLSlotElement from './IHTMLSlotElement';
|
4
|
+
import IText from '../text/IText';
|
5
|
+
import IElement from '../element/IElement';
|
6
|
+
import INode from '../node/INode';
|
7
|
+
|
8
|
+
/**
|
9
|
+
* HTML Slot Element.
|
10
|
+
*
|
11
|
+
* Reference:
|
12
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement.
|
13
|
+
*/
|
14
|
+
export default class HTMLSlotElement extends HTMLElement implements IHTMLSlotElement {
|
15
|
+
/**
|
16
|
+
* Returns name.
|
17
|
+
*
|
18
|
+
* @returns Name.
|
19
|
+
*/
|
20
|
+
public get name(): string {
|
21
|
+
return this.getAttributeNS(null, 'name') || '';
|
22
|
+
}
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Sets name.
|
26
|
+
*
|
27
|
+
* @param name Name.
|
28
|
+
*/
|
29
|
+
public set name(name: string) {
|
30
|
+
this.setAttributeNS(null, 'name', name);
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Sets the slot's manually assigned nodes to an ordered set of slottables.
|
35
|
+
*
|
36
|
+
* @param _nodes Nodes.
|
37
|
+
*/
|
38
|
+
public assign(..._nodes: Array<IText | IElement>): void {
|
39
|
+
// TODO: Do nothing for now. We need to find an example of how it is expected to work before it can be implemented.
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Returns assigned nodes.
|
44
|
+
*
|
45
|
+
* @param [options] Options.
|
46
|
+
* @param [options.flatten] A boolean value indicating whether to return the assigned nodes of any available child <slot> elements (true) or not (false). Defaults to false.
|
47
|
+
* @returns Nodes.
|
48
|
+
*/
|
49
|
+
public assignedNodes(options?: { flatten?: boolean }): INode[] {
|
50
|
+
const host = (<IShadowRoot>this.getRootNode())?.host;
|
51
|
+
|
52
|
+
// TODO: Add support for options.flatten. We need to find an example of how it is expected to work before it can be implemented.
|
53
|
+
|
54
|
+
if (host) {
|
55
|
+
const name = this.name;
|
56
|
+
|
57
|
+
if (name) {
|
58
|
+
return this.assignedElements(options);
|
59
|
+
}
|
60
|
+
|
61
|
+
return host.childNodes.slice();
|
62
|
+
}
|
63
|
+
|
64
|
+
return [];
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Returns assigned elements.
|
69
|
+
*
|
70
|
+
* @param [_options] Options.
|
71
|
+
* @param [_options.flatten] A boolean value indicating whether to return the assigned elements of any available child <slot> elements (true) or not (false). Defaults to false.
|
72
|
+
* @returns Nodes.
|
73
|
+
*/
|
74
|
+
public assignedElements(_options?: { flatten?: boolean }): IElement[] {
|
75
|
+
const host = (<IShadowRoot>this.getRootNode())?.host;
|
76
|
+
|
77
|
+
// TODO: Add support for options.flatten. We need to find an example of how it expected to work before it can be implemented.
|
78
|
+
|
79
|
+
if (host) {
|
80
|
+
const name = this.name;
|
81
|
+
|
82
|
+
if (name) {
|
83
|
+
const assignedElements = [];
|
84
|
+
|
85
|
+
for (const child of host.children) {
|
86
|
+
if (child.slot === name) {
|
87
|
+
assignedElements.push(child);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
return assignedElements;
|
92
|
+
}
|
93
|
+
|
94
|
+
return host.children.slice();
|
95
|
+
}
|
96
|
+
|
97
|
+
return [];
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Clones a node.
|
102
|
+
*
|
103
|
+
* @override
|
104
|
+
* @param [deep=false] "true" to clone deep.
|
105
|
+
* @returns Cloned node.
|
106
|
+
*/
|
107
|
+
public cloneNode(deep = false): IHTMLSlotElement {
|
108
|
+
return <HTMLSlotElement>super.cloneNode(deep);
|
109
|
+
}
|
110
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import IHTMLElement from '../html-element/IHTMLElement';
|
2
|
+
import IText from '../text/IText';
|
3
|
+
import IElement from '../element/IElement';
|
4
|
+
import INode from '../node/INode';
|
5
|
+
|
6
|
+
/**
|
7
|
+
* HTML Slot Element.
|
8
|
+
*
|
9
|
+
* Reference:
|
10
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement.
|
11
|
+
*/
|
12
|
+
export default interface IHTMLSlotElement extends IHTMLElement {
|
13
|
+
name: string;
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Sets the slot's manually assigned nodes to an ordered set of slottables.
|
17
|
+
*
|
18
|
+
* @param nodes Nodes.
|
19
|
+
*/
|
20
|
+
assign(...nodes: Array<IText | IElement>): void;
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Returns assigned nodes.
|
24
|
+
*
|
25
|
+
* @param [options] Options.
|
26
|
+
* @param [options.flatten] A boolean value indicating whether to return the assigned nodes of any available child <slot> elements (true) or not (false). Defaults to false.
|
27
|
+
* @returns Nodes.
|
28
|
+
*/
|
29
|
+
assignedNodes(options?: { flatten?: boolean }): INode[];
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Returns assigned nodes.
|
33
|
+
*
|
34
|
+
* @param [options.flatten] A boolean value indicating whether to return the assigned elements of any available child <slot> elements (true) or not (false). Defaults to false.
|
35
|
+
* @returns Nodes.
|
36
|
+
*/
|
37
|
+
assignedElements(options?: { flatten?: boolean }): IElement[];
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Clones a node.
|
41
|
+
*
|
42
|
+
* @override
|
43
|
+
* @param [deep=false] "true" to clone deep.
|
44
|
+
* @returns Cloned node.
|
45
|
+
*/
|
46
|
+
cloneNode(deep: boolean): IHTMLSlotElement;
|
47
|
+
}
|
package/src/nodes/node/INode.ts
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
import IEventTarget from '../../event/IEventTarget';
|
2
2
|
import IDocument from '../document/IDocument';
|
3
3
|
import IElement from '../element/IElement';
|
4
|
+
import INodeList from './INodeList';
|
4
5
|
|
5
6
|
export default interface INode extends IEventTarget {
|
6
7
|
readonly ownerDocument: IDocument;
|
7
8
|
readonly parentNode: INode;
|
8
9
|
readonly parentElement: IElement;
|
9
10
|
readonly nodeType: number;
|
10
|
-
readonly childNodes: INode
|
11
|
+
readonly childNodes: INodeList<INode>;
|
11
12
|
readonly isConnected: boolean;
|
12
13
|
readonly nodeName: string;
|
13
14
|
readonly previousSibling: INode;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import INodeList from './INodeList';
|
2
|
+
import INode from './INode';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Class list.
|
6
|
+
*/
|
7
|
+
export default class NodeList extends Array implements INodeList<INode> {
|
8
|
+
/**
|
9
|
+
* Returns item by index.
|
10
|
+
*
|
11
|
+
* @param index Index.
|
12
|
+
*/
|
13
|
+
public item(index: number): INode {
|
14
|
+
return index >= 0 && this[index] ? this[index] : null;
|
15
|
+
}
|
16
|
+
}
|
package/src/window/IWindow.ts
CHANGED
@@ -18,6 +18,7 @@ import SVGElement from '../nodes/svg-element/SVGElement';
|
|
18
18
|
import HTMLScriptElement from '../nodes/html-script-element/HTMLScriptElement';
|
19
19
|
import HTMLImageElement from '../nodes/html-image-element/HTMLImageElement';
|
20
20
|
import DocumentFragment from '../nodes/document-fragment/DocumentFragment';
|
21
|
+
import CharacterData from '../nodes/character-data/CharacterData';
|
21
22
|
import TreeWalker from '../tree-walker/TreeWalker';
|
22
23
|
import Event from '../event/Event';
|
23
24
|
import CustomEvent from '../event/events/CustomEvent';
|
@@ -38,6 +39,7 @@ import DOMException from '../exception/DOMException';
|
|
38
39
|
import FileReader from '../file/FileReader';
|
39
40
|
import History from '../history/History';
|
40
41
|
import CSSStyleDeclaration from '../css/CSSStyleDeclaration';
|
42
|
+
import PointerEvent from '../event/events/PointerEvent';
|
41
43
|
import MouseEvent from '../event/events/MouseEvent';
|
42
44
|
import FocusEvent from '../event/events/FocusEvent';
|
43
45
|
import WheelEvent from '../event/events/WheelEvent';
|
@@ -47,6 +49,7 @@ import DataTransferItemList from '../event/DataTransferItemList';
|
|
47
49
|
import InputEvent from '../event/events/InputEvent';
|
48
50
|
import UIEvent from '../event/UIEvent';
|
49
51
|
import ErrorEvent from '../event/events/ErrorEvent';
|
52
|
+
import StorageEvent from '../event/events/StorageEvent';
|
50
53
|
import Screen from '../screen/Screen';
|
51
54
|
import AsyncTaskManager from './AsyncTaskManager';
|
52
55
|
import IResponse from './IResponse';
|
@@ -56,6 +59,9 @@ import HTMLStyleElement from '../nodes/html-style-element/HTMLStyleElement';
|
|
56
59
|
import IFetchOptions from './IFetchOptions';
|
57
60
|
import NodeFilter from '../tree-walker/NodeFilter';
|
58
61
|
import Window from './Window';
|
62
|
+
import URLSearchParams from '../url-search-params/URLSearchParams';
|
63
|
+
import HTMLCollection from '../nodes/element/HTMLCollection';
|
64
|
+
import NodeList from '../nodes/node/NodeList';
|
59
65
|
|
60
66
|
/**
|
61
67
|
* Window.
|
@@ -86,6 +92,7 @@ export default interface IWindow {
|
|
86
92
|
readonly ShadowRoot: typeof ShadowRoot;
|
87
93
|
readonly Element: typeof Element;
|
88
94
|
readonly DocumentFragment: typeof DocumentFragment;
|
95
|
+
readonly CharacterData: typeof CharacterData;
|
89
96
|
readonly NodeFilter: typeof NodeFilter;
|
90
97
|
readonly TreeWalker: typeof TreeWalker;
|
91
98
|
readonly DOMParser: typeof DOMParser;
|
@@ -99,11 +106,13 @@ export default interface IWindow {
|
|
99
106
|
readonly CustomEvent: typeof CustomEvent;
|
100
107
|
readonly AnimationEvent: typeof AnimationEvent;
|
101
108
|
readonly KeyboardEvent: typeof KeyboardEvent;
|
109
|
+
readonly PointerEvent: typeof PointerEvent;
|
102
110
|
readonly MouseEvent: typeof MouseEvent;
|
103
111
|
readonly FocusEvent: typeof FocusEvent;
|
104
112
|
readonly WheelEvent: typeof WheelEvent;
|
105
113
|
readonly InputEvent: typeof InputEvent;
|
106
114
|
readonly ErrorEvent: typeof ErrorEvent;
|
115
|
+
readonly StorageEvent: typeof StorageEvent;
|
107
116
|
readonly ProgressEvent: typeof ProgressEvent;
|
108
117
|
readonly EventTarget: typeof EventTarget;
|
109
118
|
readonly DataTransfer: typeof DataTransfer;
|
@@ -124,6 +133,9 @@ export default interface IWindow {
|
|
124
133
|
readonly History: typeof History;
|
125
134
|
readonly Screen: typeof Screen;
|
126
135
|
readonly Storage: typeof Storage;
|
136
|
+
readonly URLSearchParams: typeof URLSearchParams;
|
137
|
+
readonly HTMLCollection: typeof HTMLCollection;
|
138
|
+
readonly NodeList: typeof NodeList;
|
127
139
|
|
128
140
|
// Events
|
129
141
|
onload: (event: Event) => void;
|
package/src/window/Window.ts
CHANGED
@@ -52,6 +52,7 @@ import DataTransferItemList from '../event/DataTransferItemList';
|
|
52
52
|
import InputEvent from '../event/events/InputEvent';
|
53
53
|
import UIEvent from '../event/UIEvent';
|
54
54
|
import ErrorEvent from '../event/events/ErrorEvent';
|
55
|
+
import StorageEvent from '../event/events/StorageEvent';
|
55
56
|
import Screen from '../screen/Screen';
|
56
57
|
import AsyncTaskManager from './AsyncTaskManager';
|
57
58
|
import IResponse from './IResponse';
|
@@ -63,6 +64,8 @@ import HTMLStyleElement from '../nodes/html-style-element/HTMLStyleElement';
|
|
63
64
|
import IFetchOptions from './IFetchOptions';
|
64
65
|
import IWindow from './IWindow';
|
65
66
|
import URLSearchParams from '../url-search-params/URLSearchParams';
|
67
|
+
import HTMLCollection from '../nodes/element/HTMLCollection';
|
68
|
+
import NodeList from '../nodes/node/NodeList';
|
66
69
|
|
67
70
|
const FETCH_RESPONSE_TYPE_METHODS = ['blob', 'json', 'text'];
|
68
71
|
|
@@ -119,6 +122,7 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
119
122
|
public readonly WheelEvent = WheelEvent;
|
120
123
|
public readonly InputEvent = InputEvent;
|
121
124
|
public readonly ErrorEvent = ErrorEvent;
|
125
|
+
public readonly StorageEvent = StorageEvent;
|
122
126
|
public readonly ProgressEvent = ProgressEvent;
|
123
127
|
public readonly EventTarget = EventTarget;
|
124
128
|
public readonly DataTransfer = DataTransfer;
|
@@ -140,6 +144,8 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
140
144
|
public readonly Screen = Screen;
|
141
145
|
public readonly Storage = Storage;
|
142
146
|
public readonly URLSearchParams = URLSearchParams;
|
147
|
+
public readonly HTMLCollection = HTMLCollection;
|
148
|
+
public readonly NodeList = NodeList;
|
143
149
|
|
144
150
|
// Events
|
145
151
|
public onload: (event: Event) => void = null;
|