happy-dom 12.6.0 → 12.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.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/cjs/clipboard/Clipboard.cjs +103 -0
- package/cjs/clipboard/Clipboard.cjs.map +1 -0
- package/cjs/clipboard/Clipboard.d.ts +42 -0
- package/cjs/clipboard/Clipboard.d.ts.map +1 -0
- package/cjs/clipboard/ClipboardItem.cjs +69 -0
- package/cjs/clipboard/ClipboardItem.cjs.map +1 -0
- package/cjs/clipboard/ClipboardItem.d.ts +37 -0
- package/cjs/clipboard/ClipboardItem.d.ts.map +1 -0
- package/cjs/event/DataTransfer.cjs +71 -2
- package/cjs/event/DataTransfer.cjs.map +1 -1
- package/cjs/event/DataTransfer.d.ts +41 -4
- package/cjs/event/DataTransfer.d.ts.map +1 -1
- package/cjs/event/DataTransferItem.cjs +27 -9
- package/cjs/event/DataTransferItem.cjs.map +1 -1
- package/cjs/event/DataTransferItem.d.ts +10 -4
- package/cjs/event/DataTransferItem.d.ts.map +1 -1
- package/cjs/event/DataTransferItemList.cjs +16 -8
- package/cjs/event/DataTransferItemList.cjs.map +1 -1
- package/cjs/event/DataTransferItemList.d.ts +3 -3
- package/cjs/event/DataTransferItemList.d.ts.map +1 -1
- package/cjs/event/events/ClipboardEvent.cjs +23 -0
- package/cjs/event/events/ClipboardEvent.cjs.map +1 -0
- package/cjs/event/events/ClipboardEvent.d.ts +17 -0
- package/cjs/event/events/ClipboardEvent.d.ts.map +1 -0
- package/cjs/event/events/IClipboardEventInit.cjs +3 -0
- package/cjs/event/events/IClipboardEventInit.cjs.map +1 -0
- package/cjs/event/events/IClipboardEventInit.d.ts +6 -0
- package/cjs/event/events/IClipboardEventInit.d.ts.map +1 -0
- package/cjs/index.cjs +15 -2
- package/cjs/index.cjs.map +1 -1
- package/cjs/index.d.ts +8 -1
- package/cjs/index.d.ts.map +1 -1
- package/cjs/navigator/Navigator.cjs +38 -5
- package/cjs/navigator/Navigator.cjs.map +1 -1
- package/cjs/navigator/Navigator.d.ts +17 -4
- package/cjs/navigator/Navigator.d.ts.map +1 -1
- package/cjs/nodes/element/Element.cjs +2 -0
- package/cjs/nodes/element/Element.cjs.map +1 -1
- package/cjs/nodes/element/Element.d.ts +1 -0
- package/cjs/nodes/element/Element.d.ts.map +1 -1
- package/cjs/nodes/element/IElement.d.ts +1 -0
- package/cjs/nodes/element/IElement.d.ts.map +1 -1
- package/cjs/nodes/html-input-element/HTMLInputElement.cjs +48 -25
- package/cjs/nodes/html-input-element/HTMLInputElement.cjs.map +1 -1
- package/cjs/nodes/html-input-element/HTMLInputElement.d.ts.map +1 -1
- package/cjs/permissions/PermissionNameEnum.cjs +35 -0
- package/cjs/permissions/PermissionNameEnum.cjs.map +1 -0
- package/cjs/permissions/PermissionNameEnum.d.ts +32 -0
- package/cjs/permissions/PermissionNameEnum.d.ts.map +1 -0
- package/cjs/permissions/PermissionStatus.cjs +26 -0
- package/cjs/permissions/PermissionStatus.cjs.map +1 -0
- package/cjs/permissions/PermissionStatus.d.ts +19 -0
- package/cjs/permissions/PermissionStatus.d.ts.map +1 -0
- package/cjs/permissions/Permissions.cjs +46 -0
- package/cjs/permissions/Permissions.cjs.map +1 -0
- package/cjs/permissions/Permissions.d.ts +25 -0
- package/cjs/permissions/Permissions.d.ts.map +1 -0
- package/cjs/version.cjs +1 -1
- package/cjs/window/IWindow.d.ts +128 -21
- package/cjs/window/IWindow.d.ts.map +1 -1
- package/cjs/window/Window.cjs +127 -35
- package/cjs/window/Window.cjs.map +1 -1
- package/cjs/window/Window.d.ts +131 -30
- package/cjs/window/Window.d.ts.map +1 -1
- package/lib/clipboard/Clipboard.d.ts +42 -0
- package/lib/clipboard/Clipboard.d.ts.map +1 -0
- package/lib/clipboard/Clipboard.js +98 -0
- package/lib/clipboard/Clipboard.js.map +1 -0
- package/lib/clipboard/ClipboardItem.d.ts +37 -0
- package/lib/clipboard/ClipboardItem.d.ts.map +1 -0
- package/lib/clipboard/ClipboardItem.js +64 -0
- package/lib/clipboard/ClipboardItem.js.map +1 -0
- package/lib/event/DataTransfer.d.ts +41 -4
- package/lib/event/DataTransfer.d.ts.map +1 -1
- package/lib/event/DataTransfer.js +71 -2
- package/lib/event/DataTransfer.js.map +1 -1
- package/lib/event/DataTransferItem.d.ts +10 -4
- package/lib/event/DataTransferItem.d.ts.map +1 -1
- package/lib/event/DataTransferItem.js +29 -10
- package/lib/event/DataTransferItem.js.map +1 -1
- package/lib/event/DataTransferItemList.d.ts +3 -3
- package/lib/event/DataTransferItemList.d.ts.map +1 -1
- package/lib/event/DataTransferItemList.js +16 -8
- package/lib/event/DataTransferItemList.js.map +1 -1
- package/lib/event/events/ClipboardEvent.d.ts +17 -0
- package/lib/event/events/ClipboardEvent.d.ts.map +1 -0
- package/lib/event/events/ClipboardEvent.js +17 -0
- package/lib/event/events/ClipboardEvent.js.map +1 -0
- package/lib/event/events/IClipboardEventInit.d.ts +6 -0
- package/lib/event/events/IClipboardEventInit.d.ts.map +1 -0
- package/lib/event/events/IClipboardEventInit.js +2 -0
- package/lib/event/events/IClipboardEventInit.js.map +1 -0
- package/lib/index.d.ts +8 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -1
- package/lib/index.js.map +1 -1
- package/lib/navigator/Navigator.d.ts +17 -4
- package/lib/navigator/Navigator.d.ts.map +1 -1
- package/lib/navigator/Navigator.js +40 -6
- package/lib/navigator/Navigator.js.map +1 -1
- package/lib/nodes/element/Element.d.ts +1 -0
- package/lib/nodes/element/Element.d.ts.map +1 -1
- package/lib/nodes/element/Element.js +2 -0
- package/lib/nodes/element/Element.js.map +1 -1
- package/lib/nodes/element/IElement.d.ts +1 -0
- package/lib/nodes/element/IElement.d.ts.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElement.d.ts.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElement.js +48 -25
- package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
- package/lib/permissions/PermissionNameEnum.d.ts +32 -0
- package/lib/permissions/PermissionNameEnum.d.ts.map +1 -0
- package/lib/permissions/PermissionNameEnum.js +33 -0
- package/lib/permissions/PermissionNameEnum.js.map +1 -0
- package/lib/permissions/PermissionStatus.d.ts +19 -0
- package/lib/permissions/PermissionStatus.d.ts.map +1 -0
- package/lib/permissions/PermissionStatus.js +20 -0
- package/lib/permissions/PermissionStatus.js.map +1 -0
- package/lib/permissions/Permissions.d.ts +25 -0
- package/lib/permissions/Permissions.d.ts.map +1 -0
- package/lib/permissions/Permissions.js +41 -0
- package/lib/permissions/Permissions.js.map +1 -0
- package/lib/version.js +1 -1
- package/lib/window/IWindow.d.ts +128 -21
- package/lib/window/IWindow.d.ts.map +1 -1
- package/lib/window/Window.d.ts +131 -30
- package/lib/window/Window.d.ts.map +1 -1
- package/lib/window/Window.js +127 -35
- package/lib/window/Window.js.map +1 -1
- package/package.json +1 -1
- package/src/clipboard/Clipboard.ts +96 -0
- package/src/clipboard/ClipboardItem.ts +59 -0
- package/src/event/DataTransfer.ts +88 -4
- package/src/event/DataTransferItem.ts +16 -9
- package/src/event/DataTransferItemList.ts +17 -7
- package/src/event/events/ClipboardEvent.ts +22 -0
- package/src/event/events/IClipboardEventInit.ts +6 -0
- package/src/index.ts +15 -1
- package/src/navigator/Navigator.ts +27 -7
- package/src/nodes/element/Element.ts +2 -0
- package/src/nodes/element/IElement.ts +1 -0
- package/src/nodes/html-input-element/HTMLInputElement.ts +49 -22
- package/src/permissions/PermissionNameEnum.ts +32 -0
- package/src/permissions/PermissionStatus.ts +23 -0
- package/src/permissions/Permissions.ts +45 -0
- package/src/window/IWindow.ts +139 -23
- package/src/window/Window.ts +133 -38
- package/cjs/config/NonImplemenetedElementClasses.cjs +0 -55
- package/cjs/config/NonImplemenetedElementClasses.cjs.map +0 -1
- package/cjs/config/NonImplemenetedElementClasses.d.ts +0 -3
- package/cjs/config/NonImplemenetedElementClasses.d.ts.map +0 -1
- package/cjs/event/NonImplementedEventTypes.cjs +0 -48
- package/cjs/event/NonImplementedEventTypes.cjs.map +0 -1
- package/cjs/event/NonImplementedEventTypes.d.ts +0 -3
- package/cjs/event/NonImplementedEventTypes.d.ts.map +0 -1
- package/lib/config/NonImplemenetedElementClasses.d.ts +0 -3
- package/lib/config/NonImplemenetedElementClasses.d.ts.map +0 -1
- package/lib/config/NonImplemenetedElementClasses.js +0 -53
- package/lib/config/NonImplemenetedElementClasses.js.map +0 -1
- package/lib/event/NonImplementedEventTypes.d.ts +0 -3
- package/lib/event/NonImplementedEventTypes.d.ts.map +0 -1
- package/lib/event/NonImplementedEventTypes.js +0 -46
- package/lib/event/NonImplementedEventTypes.js.map +0 -1
- package/src/config/NonImplemenetedElementClasses.ts +0 -52
- package/src/event/NonImplementedEventTypes.ts +0 -45
@@ -4,16 +4,24 @@ import DataTransferItem from './DataTransferItem.js';
|
|
4
4
|
/**
|
5
5
|
*
|
6
6
|
*/
|
7
|
-
export default class DataTransferItemList {
|
8
|
-
public readonly DataTransferItem: DataTransferItem[] = [];
|
9
|
-
|
7
|
+
export default class DataTransferItemList extends Array<DataTransferItem> {
|
10
8
|
/**
|
11
9
|
* Adds an item.
|
12
10
|
*
|
13
11
|
* @param item Item.
|
12
|
+
* @param type Type.
|
14
13
|
*/
|
15
|
-
public add(item: File | string): void {
|
16
|
-
|
14
|
+
public add(item: File | string, type?: string): void {
|
15
|
+
if (item instanceof File) {
|
16
|
+
this.push(new DataTransferItem(item));
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
if (!type) {
|
20
|
+
throw new TypeError(
|
21
|
+
`Failed to execute 'add' on 'DataTransferItemList': parameter 1 is not of type 'File'.`
|
22
|
+
);
|
23
|
+
}
|
24
|
+
this.push(new DataTransferItem(item, type));
|
17
25
|
}
|
18
26
|
|
19
27
|
/**
|
@@ -22,13 +30,15 @@ export default class DataTransferItemList {
|
|
22
30
|
* @param index Index.
|
23
31
|
*/
|
24
32
|
public remove(index: number): void {
|
25
|
-
this.
|
33
|
+
this.splice(index, 1);
|
26
34
|
}
|
27
35
|
|
28
36
|
/**
|
29
37
|
* Clears list.
|
30
38
|
*/
|
31
39
|
public clear(): void {
|
32
|
-
(
|
40
|
+
while (this.length) {
|
41
|
+
this.pop();
|
42
|
+
}
|
33
43
|
}
|
34
44
|
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import DataTransfer from '../DataTransfer.js';
|
2
|
+
import Event from '../Event.js';
|
3
|
+
import IClipboardEventInit from './IClipboardEventInit.js';
|
4
|
+
|
5
|
+
/**
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
export default class ClipboardEvent extends Event {
|
9
|
+
public clipboardData: DataTransfer | null;
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Constructor.
|
13
|
+
*
|
14
|
+
* @param type Event type.
|
15
|
+
* @param [eventInit] Event init.
|
16
|
+
*/
|
17
|
+
constructor(type: string, eventInit: IClipboardEventInit | null = null) {
|
18
|
+
super(type, eventInit);
|
19
|
+
|
20
|
+
this.clipboardData = eventInit?.clipboardData ?? null;
|
21
|
+
}
|
22
|
+
}
|
package/src/index.ts
CHANGED
@@ -8,6 +8,7 @@ import { URLSearchParams } from 'url';
|
|
8
8
|
import URL from './url/URL.js';
|
9
9
|
import Location from './location/Location.js';
|
10
10
|
import MutationObserver from './mutation-observer/MutationObserver.js';
|
11
|
+
import MutationRecord from './mutation-observer/MutationRecord.js';
|
11
12
|
import ResizeObserver from './resize-observer/ResizeObserver.js';
|
12
13
|
import Blob from './file/Blob.js';
|
13
14
|
import File from './file/File.js';
|
@@ -152,6 +153,12 @@ import IVirtualConsoleLogGroup from './console/types/IVirtualConsoleLogGroup.js'
|
|
152
153
|
import IVirtualConsolePrinter from './console/types/IVirtualConsolePrinter.js';
|
153
154
|
import VirtualConsole from './console/VirtualConsole.js';
|
154
155
|
import VirtualConsolePrinter from './console/VirtualConsolePrinter.js';
|
156
|
+
import Permissions from './permissions/Permissions.js';
|
157
|
+
import PermissionStatus from './permissions/PermissionStatus.js';
|
158
|
+
import Clipboard from './clipboard/Clipboard.js';
|
159
|
+
import ClipboardItem from './clipboard/ClipboardItem.js';
|
160
|
+
import ClipboardEvent from './event/events/ClipboardEvent.js';
|
161
|
+
import IClipboardEventInit from './event/events/IClipboardEventInit.js';
|
155
162
|
|
156
163
|
export {
|
157
164
|
GlobalWindow,
|
@@ -163,6 +170,7 @@ export {
|
|
163
170
|
URL,
|
164
171
|
Location,
|
165
172
|
MutationObserver,
|
173
|
+
MutationRecord,
|
166
174
|
ResizeObserver,
|
167
175
|
Blob,
|
168
176
|
File,
|
@@ -199,6 +207,8 @@ export {
|
|
199
207
|
ProgressEvent,
|
200
208
|
SubmitEvent,
|
201
209
|
WheelEvent,
|
210
|
+
ClipboardEvent,
|
211
|
+
IClipboardEventInit,
|
202
212
|
DOMParser,
|
203
213
|
Document,
|
204
214
|
IDocument,
|
@@ -307,5 +317,9 @@ export {
|
|
307
317
|
IVirtualConsoleLogGroup,
|
308
318
|
IVirtualConsolePrinter,
|
309
319
|
VirtualConsole,
|
310
|
-
VirtualConsolePrinter
|
320
|
+
VirtualConsolePrinter,
|
321
|
+
Permissions,
|
322
|
+
PermissionStatus,
|
323
|
+
Clipboard,
|
324
|
+
ClipboardItem
|
311
325
|
};
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import MimeTypeArray from './MimeTypeArray.js';
|
2
2
|
import PluginArray from './PluginArray.js';
|
3
3
|
import IWindow from '../window/IWindow.js';
|
4
|
+
import Permissions from '../permissions/Permissions.js';
|
5
|
+
import Clipboard from '../clipboard/Clipboard.js';
|
4
6
|
|
5
7
|
/**
|
6
8
|
* Browser Navigator API.
|
@@ -11,14 +13,19 @@ import IWindow from '../window/IWindow.js';
|
|
11
13
|
* https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator.
|
12
14
|
*/
|
13
15
|
export default class Navigator {
|
14
|
-
|
16
|
+
#ownerWindow: IWindow;
|
17
|
+
#clipboard: Clipboard;
|
18
|
+
#permissions: Permissions;
|
15
19
|
|
16
20
|
/**
|
21
|
+
* Constructor.
|
17
22
|
*
|
18
|
-
* @param ownerWindow
|
23
|
+
* @param ownerWindow Owner window.
|
19
24
|
*/
|
20
25
|
constructor(ownerWindow: IWindow) {
|
21
|
-
this
|
26
|
+
this.#ownerWindow = ownerWindow;
|
27
|
+
this.#clipboard = new Clipboard(ownerWindow);
|
28
|
+
this.#permissions = new Permissions();
|
22
29
|
}
|
23
30
|
|
24
31
|
/**
|
@@ -144,7 +151,7 @@ export default class Navigator {
|
|
144
151
|
* "appCodeName/appVersion number (Platform; Security; OS-or-CPU; Localization; rv: revision-version-number) product/productSub Application-Name Application-Name-version".
|
145
152
|
*/
|
146
153
|
public get userAgent(): string {
|
147
|
-
return this.
|
154
|
+
return this.#ownerWindow.happyDOM.settings.navigator.userAgent;
|
148
155
|
}
|
149
156
|
|
150
157
|
/**
|
@@ -155,10 +162,23 @@ export default class Navigator {
|
|
155
162
|
}
|
156
163
|
|
157
164
|
/**
|
158
|
-
*
|
165
|
+
* Returns a Permissions object that can be used to query and update permission status of APIs covered by the Permissions API.
|
166
|
+
*
|
167
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Navigator/permissions
|
168
|
+
* @returns Permissions.
|
159
169
|
*/
|
160
|
-
public get permissions():
|
161
|
-
return
|
170
|
+
public get permissions(): Permissions {
|
171
|
+
return this.#permissions;
|
172
|
+
}
|
173
|
+
|
174
|
+
/**
|
175
|
+
* Returns a Clipboard object providing access to the contents of the system clipboard.
|
176
|
+
*
|
177
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Navigator/clipboard
|
178
|
+
* @returns Clipboard.
|
179
|
+
*/
|
180
|
+
public get clipboard(): Clipboard {
|
181
|
+
return this.#clipboard;
|
162
182
|
}
|
163
183
|
|
164
184
|
/**
|
@@ -47,6 +47,7 @@ export default class Element extends Node implements IElement {
|
|
47
47
|
public prefix: string = null;
|
48
48
|
|
49
49
|
public scrollHeight = 0;
|
50
|
+
public scrollWidth = 0;
|
50
51
|
public scrollTop = 0;
|
51
52
|
public scrollLeft = 0;
|
52
53
|
public readonly namespaceURI: string = null;
|
@@ -380,6 +381,7 @@ export default class Element extends Node implements IElement {
|
|
380
381
|
(<string>clone.tagName) = this.tagName;
|
381
382
|
clone.scrollLeft = this.scrollLeft;
|
382
383
|
clone.scrollTop = this.scrollTop;
|
384
|
+
clone.scrollWidth = this.scrollWidth;
|
383
385
|
clone.scrollHeight = this.scrollHeight;
|
384
386
|
(<string>clone.namespaceURI) = this.namespaceURI;
|
385
387
|
|
@@ -1167,43 +1167,69 @@ export default class HTMLInputElement extends HTMLElement implements IHTMLInputE
|
|
1167
1167
|
* @override
|
1168
1168
|
*/
|
1169
1169
|
public override dispatchEvent(event: Event): boolean {
|
1170
|
+
// Do nothing if the input element is disabled and the event is a click event.
|
1170
1171
|
if (event.type === 'click' && event.eventPhase === EventPhaseEnum.none && this.disabled) {
|
1171
1172
|
return false;
|
1172
1173
|
}
|
1173
1174
|
|
1175
|
+
let previousCheckedValue: boolean | null = null;
|
1176
|
+
|
1177
|
+
// The checkbox or radio button has to be checked before the click event is dispatched, so that event listeners can check the checked value.
|
1178
|
+
// However, the value has to be restored if preventDefault() is called on the click event.
|
1174
1179
|
if (
|
1175
|
-
event.type === 'click' &&
|
1176
1180
|
(event.eventPhase === EventPhaseEnum.atTarget ||
|
1177
1181
|
event.eventPhase === EventPhaseEnum.bubbling) &&
|
1178
|
-
|
1182
|
+
event.type === 'click'
|
1179
1183
|
) {
|
1180
|
-
|
1184
|
+
const inputType = this.type;
|
1185
|
+
if (inputType === 'checkbox' || inputType === 'radio') {
|
1186
|
+
previousCheckedValue = this.checked;
|
1187
|
+
this._setChecked(inputType === 'checkbox' ? !previousCheckedValue : true);
|
1188
|
+
}
|
1181
1189
|
}
|
1182
1190
|
|
1183
1191
|
const returnValue = super.dispatchEvent(event);
|
1184
1192
|
|
1185
1193
|
if (
|
1186
|
-
event.
|
1194
|
+
!event.defaultPrevented &&
|
1187
1195
|
(event.eventPhase === EventPhaseEnum.atTarget ||
|
1188
1196
|
event.eventPhase === EventPhaseEnum.bubbling) &&
|
1189
|
-
|
1197
|
+
event.type === 'click' &&
|
1198
|
+
this.isConnected
|
1190
1199
|
) {
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
if (
|
1197
|
-
form.
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
if (
|
1202
|
-
form.
|
1200
|
+
const inputType = this.type;
|
1201
|
+
if (!this.readOnly || inputType === 'checkbox' || inputType === 'radio') {
|
1202
|
+
if (inputType === 'checkbox' || inputType === 'radio') {
|
1203
|
+
this.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));
|
1204
|
+
this.dispatchEvent(new Event('change', { bubbles: true, cancelable: true }));
|
1205
|
+
} else if (inputType === 'submit') {
|
1206
|
+
const form = <IHTMLFormElement>this._formNode;
|
1207
|
+
if (form) {
|
1208
|
+
form.requestSubmit();
|
1209
|
+
}
|
1210
|
+
} else if (inputType === 'reset' && this.isConnected) {
|
1211
|
+
const form = <IHTMLFormElement>this._formNode;
|
1212
|
+
if (form) {
|
1213
|
+
form.reset();
|
1214
|
+
}
|
1203
1215
|
}
|
1204
1216
|
}
|
1205
1217
|
}
|
1206
1218
|
|
1219
|
+
// Restore checked state if preventDefault() is triggered on the click event.
|
1220
|
+
if (
|
1221
|
+
event.defaultPrevented &&
|
1222
|
+
(event.eventPhase === EventPhaseEnum.atTarget ||
|
1223
|
+
event.eventPhase === EventPhaseEnum.bubbling) &&
|
1224
|
+
event.type === 'click' &&
|
1225
|
+
previousCheckedValue !== null
|
1226
|
+
) {
|
1227
|
+
const inputType = this.type;
|
1228
|
+
if (inputType === 'checkbox' || inputType === 'radio') {
|
1229
|
+
this._setChecked(previousCheckedValue);
|
1230
|
+
}
|
1231
|
+
}
|
1232
|
+
|
1207
1233
|
return returnValue;
|
1208
1234
|
}
|
1209
1235
|
|
@@ -1233,12 +1259,13 @@ export default class HTMLInputElement extends HTMLElement implements IHTMLInputE
|
|
1233
1259
|
* @returns "true" if selection is supported.
|
1234
1260
|
*/
|
1235
1261
|
private _isSelectionSupported(): boolean {
|
1262
|
+
const inputType = this.type;
|
1236
1263
|
return (
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1264
|
+
inputType === 'text' ||
|
1265
|
+
inputType === 'search' ||
|
1266
|
+
inputType === 'url' ||
|
1267
|
+
inputType === 'tel' ||
|
1268
|
+
inputType === 'password'
|
1242
1269
|
);
|
1243
1270
|
}
|
1244
1271
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
enum PermissionNameEnum {
|
2
|
+
geolocation = 'geolocation',
|
3
|
+
notifications = 'notifications',
|
4
|
+
push = 'push',
|
5
|
+
midi = 'midi',
|
6
|
+
camera = 'camera',
|
7
|
+
microphone = 'microphone',
|
8
|
+
backgroundFetch = 'background-fetch',
|
9
|
+
backgroundSync = 'background-sync',
|
10
|
+
persistentStorage = 'persistent-storage',
|
11
|
+
ambientLightSensor = 'ambient-light-sensor',
|
12
|
+
accelerometer = 'accelerometer',
|
13
|
+
gyroscope = 'gyroscope',
|
14
|
+
magnetometer = 'magnetometer',
|
15
|
+
screenWakeLock = 'screen-wake-lock',
|
16
|
+
nfc = 'nfc',
|
17
|
+
displayCapture = 'display-capture',
|
18
|
+
accessibilityEvents = 'accessibility-events',
|
19
|
+
clipboardRead = 'clipboard-read',
|
20
|
+
clipboardWrite = 'clipboard-write',
|
21
|
+
paymentHandler = 'payment-handler',
|
22
|
+
idleDetection = 'idle-detection',
|
23
|
+
periodicBackgroundSync = 'periodic-background-sync',
|
24
|
+
systemWakeLock = 'system-wake-lock',
|
25
|
+
storageAccess = 'storage-access',
|
26
|
+
windowManagement = 'window-management',
|
27
|
+
windowPlacement = 'window-placement',
|
28
|
+
localFonts = 'local-fonts',
|
29
|
+
topLevelStorageAccess = 'top-level-storage-access'
|
30
|
+
}
|
31
|
+
|
32
|
+
export default PermissionNameEnum;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import EventTarget from '../event/EventTarget.js';
|
2
|
+
import Event from '../event/Event.js';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Permission status.
|
6
|
+
*
|
7
|
+
* Reference:
|
8
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus
|
9
|
+
*/
|
10
|
+
export default class PermissionStatus extends EventTarget {
|
11
|
+
public state: 'granted' | 'denied' | 'prompt';
|
12
|
+
public onchange: ((event: Event) => void) | null = null;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Constructor.
|
16
|
+
*
|
17
|
+
* @param [state] State.
|
18
|
+
*/
|
19
|
+
constructor(state: 'granted' | 'denied' | 'prompt' = 'granted') {
|
20
|
+
super();
|
21
|
+
this.state = state;
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import PermissionStatus from './PermissionStatus.js';
|
2
|
+
import PermissionNameEnum from './PermissionNameEnum.js';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Permissions API.
|
6
|
+
*
|
7
|
+
* Reference:
|
8
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Permissions.
|
9
|
+
*/
|
10
|
+
export default class Permissions {
|
11
|
+
#permissionStatus: {
|
12
|
+
[name in PermissionNameEnum]?: PermissionStatus;
|
13
|
+
} = {};
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Returns scroll restoration.
|
17
|
+
*
|
18
|
+
* @param permissionDescriptor Permission descriptor.
|
19
|
+
* @param permissionDescriptor.name Permission name.
|
20
|
+
* @param [permissionDescriptor.userVisibleOnly] User visible only.
|
21
|
+
* @param [permissionDescriptor.sysex] Sysex.
|
22
|
+
* @returns Permission status.
|
23
|
+
*/
|
24
|
+
public async query(permissionDescriptor: {
|
25
|
+
name: string;
|
26
|
+
userVisibleOnly?: boolean;
|
27
|
+
sysex?: boolean;
|
28
|
+
}): Promise<PermissionStatus> {
|
29
|
+
if (this.#permissionStatus[permissionDescriptor.name]) {
|
30
|
+
return this.#permissionStatus[permissionDescriptor.name];
|
31
|
+
}
|
32
|
+
|
33
|
+
if (
|
34
|
+
!Object.values(PermissionNameEnum).includes(<PermissionNameEnum>permissionDescriptor.name)
|
35
|
+
) {
|
36
|
+
throw new Error(
|
37
|
+
`Failed to execute 'query' on 'Permissions': Failed to read the 'name' property from 'PermissionDescriptor': The provided value '${permissionDescriptor.name}' is not a valid enum value of type PermissionName.`
|
38
|
+
);
|
39
|
+
}
|
40
|
+
|
41
|
+
this.#permissionStatus[permissionDescriptor.name] = new PermissionStatus('granted');
|
42
|
+
|
43
|
+
return this.#permissionStatus[permissionDescriptor.name];
|
44
|
+
}
|
45
|
+
}
|
package/src/window/IWindow.ts
CHANGED
@@ -46,6 +46,7 @@ import { URLSearchParams } from 'url';
|
|
46
46
|
import URL from '../url/URL.js';
|
47
47
|
import Location from '../location/Location.js';
|
48
48
|
import MutationObserver from '../mutation-observer/MutationObserver.js';
|
49
|
+
import MutationRecord from '../mutation-observer/MutationRecord.js';
|
49
50
|
import DOMParser from '../dom-parser/DOMParser.js';
|
50
51
|
import XMLSerializer from '../xml-serializer/XMLSerializer.js';
|
51
52
|
import ResizeObserver from '../resize-observer/ResizeObserver.js';
|
@@ -126,12 +127,17 @@ import RadioNodeList from '../nodes/html-form-element/RadioNodeList.js';
|
|
126
127
|
import ValidityState from '../validity-state/ValidityState.js';
|
127
128
|
import INodeJSGlobal from './INodeJSGlobal.js';
|
128
129
|
import VirtualConsolePrinter from '../console/VirtualConsolePrinter.js';
|
130
|
+
import Permissions from '../permissions/Permissions.js';
|
131
|
+
import PermissionStatus from '../permissions/PermissionStatus.js';
|
132
|
+
import Clipboard from '../clipboard/Clipboard.js';
|
133
|
+
import ClipboardItem from '../clipboard/ClipboardItem.js';
|
134
|
+
import ClipboardEvent from '../event/events/ClipboardEvent.js';
|
129
135
|
|
130
136
|
/**
|
131
137
|
* Window without dependencies to server side specific packages.
|
132
138
|
*/
|
133
139
|
export default interface IWindow extends IEventTarget, INodeJSGlobal {
|
134
|
-
//
|
140
|
+
// Happy DOM property.
|
135
141
|
readonly happyDOM: {
|
136
142
|
whenAsyncComplete: () => Promise<void>;
|
137
143
|
cancelAsync: () => void;
|
@@ -152,8 +158,24 @@ export default interface IWindow extends IEventTarget, INodeJSGlobal {
|
|
152
158
|
setInnerHeight: (height: number) => void;
|
153
159
|
};
|
154
160
|
|
155
|
-
//
|
161
|
+
// Nodes
|
156
162
|
readonly Node: typeof Node;
|
163
|
+
readonly Attr: typeof Attr;
|
164
|
+
readonly SVGSVGElement: typeof SVGSVGElement;
|
165
|
+
readonly SVGElement: typeof SVGElement;
|
166
|
+
readonly Text: typeof Text;
|
167
|
+
readonly Comment: typeof Comment;
|
168
|
+
readonly ShadowRoot: typeof ShadowRoot;
|
169
|
+
readonly Element: typeof Element;
|
170
|
+
readonly DocumentFragment: typeof DocumentFragment;
|
171
|
+
readonly CharacterData: typeof CharacterData;
|
172
|
+
readonly ProcessingInstruction: typeof ProcessingInstruction;
|
173
|
+
readonly Document: typeof Document;
|
174
|
+
readonly HTMLDocument: typeof HTMLDocument;
|
175
|
+
readonly XMLDocument: typeof XMLDocument;
|
176
|
+
readonly SVGDocument: typeof SVGDocument;
|
177
|
+
|
178
|
+
// Element classes
|
157
179
|
readonly HTMLElement: typeof HTMLElement;
|
158
180
|
readonly HTMLUnknownElement: typeof HTMLUnknownElement;
|
159
181
|
readonly HTMLTemplateElement: typeof HTMLTemplateElement;
|
@@ -174,27 +196,61 @@ export default interface IWindow extends IEventTarget, INodeJSGlobal {
|
|
174
196
|
readonly HTMLBaseElement: typeof HTMLBaseElement;
|
175
197
|
readonly HTMLIFrameElement: typeof HTMLIFrameElement;
|
176
198
|
readonly HTMLDialogElement: typeof HTMLDialogElement;
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
readonly
|
182
|
-
readonly
|
183
|
-
readonly
|
184
|
-
readonly
|
185
|
-
readonly
|
186
|
-
readonly
|
187
|
-
readonly
|
188
|
-
readonly
|
189
|
-
readonly
|
190
|
-
readonly
|
191
|
-
readonly
|
192
|
-
readonly
|
193
|
-
readonly
|
194
|
-
readonly
|
195
|
-
readonly
|
196
|
-
readonly
|
197
|
-
readonly
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Non-implemented element classes
|
202
|
+
*/
|
203
|
+
readonly HTMLHeadElement: typeof HTMLElement;
|
204
|
+
readonly HTMLTitleElement: typeof HTMLElement;
|
205
|
+
readonly HTMLBodyElement: typeof HTMLElement;
|
206
|
+
readonly HTMLHeadingElement: typeof HTMLElement;
|
207
|
+
readonly HTMLParagraphElement: typeof HTMLElement;
|
208
|
+
readonly HTMLHRElement: typeof HTMLElement;
|
209
|
+
readonly HTMLPreElement: typeof HTMLElement;
|
210
|
+
readonly HTMLUListElement: typeof HTMLElement;
|
211
|
+
readonly HTMLOListElement: typeof HTMLElement;
|
212
|
+
readonly HTMLLIElement: typeof HTMLElement;
|
213
|
+
readonly HTMLMenuElement: typeof HTMLElement;
|
214
|
+
readonly HTMLDListElement: typeof HTMLElement;
|
215
|
+
readonly HTMLDivElement: typeof HTMLElement;
|
216
|
+
readonly HTMLAnchorElement: typeof HTMLElement;
|
217
|
+
readonly HTMLAreaElement: typeof HTMLElement;
|
218
|
+
readonly HTMLBRElement: typeof HTMLElement;
|
219
|
+
readonly HTMLButtonElement: typeof HTMLElement;
|
220
|
+
readonly HTMLCanvasElement: typeof HTMLElement;
|
221
|
+
readonly HTMLDataElement: typeof HTMLElement;
|
222
|
+
readonly HTMLDataListElement: typeof HTMLElement;
|
223
|
+
readonly HTMLDetailsElement: typeof HTMLElement;
|
224
|
+
readonly HTMLDirectoryElement: typeof HTMLElement;
|
225
|
+
readonly HTMLFieldSetElement: typeof HTMLElement;
|
226
|
+
readonly HTMLFontElement: typeof HTMLElement;
|
227
|
+
readonly HTMLHtmlElement: typeof HTMLElement;
|
228
|
+
readonly HTMLLegendElement: typeof HTMLElement;
|
229
|
+
readonly HTMLMapElement: typeof HTMLElement;
|
230
|
+
readonly HTMLMarqueeElement: typeof HTMLElement;
|
231
|
+
readonly HTMLMeterElement: typeof HTMLElement;
|
232
|
+
readonly HTMLModElement: typeof HTMLElement;
|
233
|
+
readonly HTMLOutputElement: typeof HTMLElement;
|
234
|
+
readonly HTMLPictureElement: typeof HTMLElement;
|
235
|
+
readonly HTMLProgressElement: typeof HTMLElement;
|
236
|
+
readonly HTMLQuoteElement: typeof HTMLElement;
|
237
|
+
readonly HTMLSourceElement: typeof HTMLElement;
|
238
|
+
readonly HTMLSpanElement: typeof HTMLElement;
|
239
|
+
readonly HTMLTableCaptionElement: typeof HTMLElement;
|
240
|
+
readonly HTMLTableCellElement: typeof HTMLElement;
|
241
|
+
readonly HTMLTableColElement: typeof HTMLElement;
|
242
|
+
readonly HTMLTableElement: typeof HTMLElement;
|
243
|
+
readonly HTMLTimeElement: typeof HTMLElement;
|
244
|
+
readonly HTMLTableRowElement: typeof HTMLElement;
|
245
|
+
readonly HTMLTableSectionElement: typeof HTMLElement;
|
246
|
+
readonly HTMLFrameElement: typeof HTMLElement;
|
247
|
+
readonly HTMLFrameSetElement: typeof HTMLElement;
|
248
|
+
readonly HTMLEmbedElement: typeof HTMLElement;
|
249
|
+
readonly HTMLObjectElement: typeof HTMLElement;
|
250
|
+
readonly HTMLParamElement: typeof HTMLElement;
|
251
|
+
readonly HTMLTrackElement: typeof HTMLElement;
|
252
|
+
|
253
|
+
// Event classes
|
198
254
|
readonly Event: typeof Event;
|
199
255
|
readonly UIEvent: typeof UIEvent;
|
200
256
|
readonly CustomEvent: typeof CustomEvent;
|
@@ -212,6 +268,55 @@ export default interface IWindow extends IEventTarget, INodeJSGlobal {
|
|
212
268
|
readonly MessagePort: typeof MessagePort;
|
213
269
|
readonly ProgressEvent: typeof ProgressEvent;
|
214
270
|
readonly MediaQueryListEvent: typeof MediaQueryListEvent;
|
271
|
+
readonly ClipboardEvent: typeof ClipboardEvent;
|
272
|
+
|
273
|
+
/**
|
274
|
+
* Non-implemented event classes
|
275
|
+
*/
|
276
|
+
readonly AudioProcessingEvent: typeof Event;
|
277
|
+
readonly BeforeInputEvent: typeof Event;
|
278
|
+
readonly BeforeUnloadEvent: typeof Event;
|
279
|
+
readonly BlobEvent: typeof Event;
|
280
|
+
readonly CloseEvent: typeof Event;
|
281
|
+
readonly CompositionEvent: typeof Event;
|
282
|
+
readonly CSSFontFaceLoadEvent: typeof Event;
|
283
|
+
readonly DeviceLightEvent: typeof Event;
|
284
|
+
readonly DeviceMotionEvent: typeof Event;
|
285
|
+
readonly DeviceOrientationEvent: typeof Event;
|
286
|
+
readonly DeviceProximityEvent: typeof Event;
|
287
|
+
readonly DOMTransactionEvent: typeof Event;
|
288
|
+
readonly DragEvent: typeof Event;
|
289
|
+
readonly EditingBeforeInputEvent: typeof Event;
|
290
|
+
readonly FetchEvent: typeof Event;
|
291
|
+
readonly GamepadEvent: typeof Event;
|
292
|
+
readonly HashChangeEvent: typeof Event;
|
293
|
+
readonly IDBVersionChangeEvent: typeof Event;
|
294
|
+
readonly MediaStreamEvent: typeof Event;
|
295
|
+
readonly MutationEvent: typeof Event;
|
296
|
+
readonly OfflineAudioCompletionEvent: typeof Event;
|
297
|
+
readonly OverconstrainedError: typeof Event;
|
298
|
+
readonly PageTransitionEvent: typeof Event;
|
299
|
+
readonly PaymentRequestUpdateEvent: typeof Event;
|
300
|
+
readonly PopStateEvent: typeof Event;
|
301
|
+
readonly RelatedEvent: typeof Event;
|
302
|
+
readonly RTCDataChannelEvent: typeof Event;
|
303
|
+
readonly RTCIdentityErrorEvent: typeof Event;
|
304
|
+
readonly RTCIdentityEvent: typeof Event;
|
305
|
+
readonly RTCPeerConnectionIceEvent: typeof Event;
|
306
|
+
readonly SensorEvent: typeof Event;
|
307
|
+
readonly SVGEvent: typeof Event;
|
308
|
+
readonly SVGZoomEvent: typeof Event;
|
309
|
+
readonly TimeEvent: typeof Event;
|
310
|
+
readonly TouchEvent: typeof Event;
|
311
|
+
readonly TrackEvent: typeof Event;
|
312
|
+
readonly TransitionEvent: typeof Event;
|
313
|
+
readonly UserProximityEvent: typeof Event;
|
314
|
+
readonly WebGLContextEvent: typeof Event;
|
315
|
+
readonly TextEvent: typeof Event;
|
316
|
+
|
317
|
+
// Other classes
|
318
|
+
readonly Image: typeof Image;
|
319
|
+
readonly NamedNodeMap: typeof NamedNodeMap;
|
215
320
|
readonly EventTarget: typeof EventTarget;
|
216
321
|
readonly DataTransfer: typeof DataTransfer;
|
217
322
|
readonly DataTransferItem: typeof DataTransferItem;
|
@@ -268,6 +373,17 @@ export default interface IWindow extends IEventTarget, INodeJSGlobal {
|
|
268
373
|
readonly AbortSignal: typeof AbortSignal;
|
269
374
|
readonly RadioNodeList: typeof RadioNodeList;
|
270
375
|
readonly ValidityState: typeof ValidityState;
|
376
|
+
readonly Permissions: typeof Permissions;
|
377
|
+
readonly PermissionStatus: typeof PermissionStatus;
|
378
|
+
readonly Clipboard: typeof Clipboard;
|
379
|
+
readonly ClipboardItem: typeof ClipboardItem;
|
380
|
+
|
381
|
+
readonly NodeFilter: typeof NodeFilter;
|
382
|
+
readonly NodeIterator: typeof NodeIterator;
|
383
|
+
readonly TreeWalker: typeof TreeWalker;
|
384
|
+
readonly DOMParser: typeof DOMParser;
|
385
|
+
readonly MutationObserver: typeof MutationObserver;
|
386
|
+
readonly MutationRecord: typeof MutationRecord;
|
271
387
|
|
272
388
|
// Events
|
273
389
|
onload: (event: Event) => void;
|