happy-dom 2.31.0 → 2.33.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.
- package/README.md +1 -1
- package/lib/config/ElementClass.d.ts +0 -22
- package/lib/config/ElementClass.js +1 -23
- package/lib/config/ElementClass.js.map +1 -1
- 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/EventTarget.js +5 -1
- package/lib/event/EventTarget.js.map +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +6 -2
- package/lib/index.js.map +1 -1
- package/lib/match-media/MediaQueryList.d.ts +39 -0
- package/lib/match-media/MediaQueryList.js +82 -0
- package/lib/match-media/MediaQueryList.js.map +1 -0
- package/lib/nodes/html-input-element/IHTMLInputElement.d.ts +1 -1
- package/lib/nodes/html-label-element/HTMLLabelElement.d.ts +45 -0
- package/lib/nodes/html-label-element/HTMLLabelElement.js +113 -0
- package/lib/nodes/html-label-element/HTMLLabelElement.js.map +1 -0
- package/lib/nodes/html-label-element/IHTMLLabelElement.d.ts +13 -0
- package/lib/nodes/html-label-element/IHTMLLabelElement.js +3 -0
- package/lib/nodes/html-label-element/IHTMLLabelElement.js.map +1 -0
- package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +1 -1
- package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
- package/lib/nodes/html-text-area-element/IHTMLTextAreaElement.d.ts +1 -1
- package/lib/nodes/node/Node.js +0 -4
- package/lib/nodes/node/Node.js.map +1 -1
- package/lib/window/IWindow.d.ts +6 -2
- package/lib/window/Window.d.ts +16 -2
- package/lib/window/Window.js +20 -2
- package/lib/window/Window.js.map +1 -1
- package/package.json +3 -3
- package/src/config/ElementClass.ts +1 -23
- package/src/config/ElementTag.ts +2 -0
- package/src/event/EventTarget.ts +7 -1
- package/src/index.ts +8 -0
- package/src/match-media/MediaQueryList.ts +52 -0
- package/src/nodes/html-input-element/IHTMLInputElement.ts +1 -1
- package/src/nodes/html-label-element/HTMLLabelElement.ts +80 -0
- package/src/nodes/html-label-element/IHTMLLabelElement.ts +14 -0
- package/src/nodes/html-text-area-element/HTMLTextAreaElement.ts +1 -1
- package/src/nodes/html-text-area-element/IHTMLTextAreaElement.ts +1 -1
- package/src/nodes/node/Node.ts +0 -6
- package/src/window/IWindow.ts +6 -2
- package/src/window/Window.ts +21 -2
@@ -361,7 +361,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
|
|
361
361
|
public get form(): IHTMLFormElement {
|
362
362
|
let parent = <IHTMLElement>this.parentNode;
|
363
363
|
while (parent && parent.tagName !== 'FORM') {
|
364
|
-
parent = <IHTMLElement>
|
364
|
+
parent = <IHTMLElement>parent.parentNode;
|
365
365
|
}
|
366
366
|
return <IHTMLFormElement>parent;
|
367
367
|
}
|
@@ -10,6 +10,7 @@ import HTMLInputElementSelectionModeEnum from '../html-input-element/HTMLInputEl
|
|
10
10
|
*/
|
11
11
|
export default interface IHTMLTextAreaElement extends IHTMLElement {
|
12
12
|
readonly type: string;
|
13
|
+
readonly form: IHTMLFormElement;
|
13
14
|
defaultValue: string;
|
14
15
|
minLength: number;
|
15
16
|
maxLength: number;
|
@@ -27,7 +28,6 @@ export default interface IHTMLTextAreaElement extends IHTMLElement {
|
|
27
28
|
selectionStart: number;
|
28
29
|
selectionEnd: number;
|
29
30
|
selectionDirection: string;
|
30
|
-
form: IHTMLFormElement;
|
31
31
|
textLength: number;
|
32
32
|
|
33
33
|
/**
|
package/src/nodes/node/Node.ts
CHANGED
@@ -387,12 +387,6 @@ export default class Node extends EventTarget implements INode {
|
|
387
387
|
* @override
|
388
388
|
*/
|
389
389
|
public dispatchEvent(event: Event): boolean {
|
390
|
-
const onEventName = 'on' + event.type.toLowerCase();
|
391
|
-
|
392
|
-
if (typeof this[onEventName] === 'function') {
|
393
|
-
this[onEventName].call(this, event);
|
394
|
-
}
|
395
|
-
|
396
390
|
const returnValue = super.dispatchEvent(event);
|
397
391
|
|
398
392
|
if (event.bubbles && !event._propagationStopped) {
|
package/src/window/IWindow.ts
CHANGED
@@ -13,6 +13,10 @@ import HTMLFormElement from '../nodes/html-form-element/HTMLFormElement';
|
|
13
13
|
import HTMLElement from '../nodes/html-element/HTMLElement';
|
14
14
|
import HTMLInputElement from '../nodes/html-input-element/HTMLInputElement';
|
15
15
|
import HTMLTextAreaElement from '../nodes/html-text-area-element/HTMLTextAreaElement';
|
16
|
+
import HTMLLinkElement from '../nodes/html-link-element/HTMLLinkElement';
|
17
|
+
import HTMLStyleElement from '../nodes/html-style-element/HTMLStyleElement';
|
18
|
+
import HTMLSlotElement from '../nodes/html-slot-element/HTMLSlotElement';
|
19
|
+
import HTMLLabelElement from '../nodes/html-label-element/HTMLLabelElement';
|
16
20
|
import SVGSVGElement from '../nodes/svg-element/SVGSVGElement';
|
17
21
|
import SVGElement from '../nodes/svg-element/SVGElement';
|
18
22
|
import HTMLScriptElement from '../nodes/html-script-element/HTMLScriptElement';
|
@@ -54,8 +58,6 @@ import Screen from '../screen/Screen';
|
|
54
58
|
import AsyncTaskManager from './AsyncTaskManager';
|
55
59
|
import IResponse from './IResponse';
|
56
60
|
import Storage from '../storage/Storage';
|
57
|
-
import HTMLLinkElement from '../nodes/html-link-element/HTMLLinkElement';
|
58
|
-
import HTMLStyleElement from '../nodes/html-style-element/HTMLStyleElement';
|
59
61
|
import IFetchOptions from './IFetchOptions';
|
60
62
|
import NodeFilter from '../tree-walker/NodeFilter';
|
61
63
|
import Window from './Window';
|
@@ -85,6 +87,8 @@ export default interface IWindow {
|
|
85
87
|
readonly HTMLScriptElement: typeof HTMLScriptElement;
|
86
88
|
readonly HTMLLinkElement: typeof HTMLLinkElement;
|
87
89
|
readonly HTMLStyleElement: typeof HTMLStyleElement;
|
90
|
+
readonly HTMLSlotElement: typeof HTMLSlotElement;
|
91
|
+
readonly HTMLLabelElement: typeof HTMLLabelElement;
|
88
92
|
readonly SVGSVGElement: typeof SVGSVGElement;
|
89
93
|
readonly SVGElement: typeof SVGElement;
|
90
94
|
readonly Text: typeof Text;
|
package/src/window/Window.ts
CHANGED
@@ -14,6 +14,10 @@ import HTMLFormElement from '../nodes/html-form-element/HTMLFormElement';
|
|
14
14
|
import HTMLElement from '../nodes/html-element/HTMLElement';
|
15
15
|
import HTMLInputElement from '../nodes/html-input-element/HTMLInputElement';
|
16
16
|
import HTMLTextAreaElement from '../nodes/html-text-area-element/HTMLTextAreaElement';
|
17
|
+
import HTMLLinkElement from '../nodes/html-link-element/HTMLLinkElement';
|
18
|
+
import HTMLStyleElement from '../nodes/html-style-element/HTMLStyleElement';
|
19
|
+
import HTMLSlotElement from '../nodes/html-slot-element/HTMLSlotElement';
|
20
|
+
import HTMLLabelElement from '../nodes/html-label-element/HTMLLabelElement';
|
17
21
|
import SVGSVGElement from '../nodes/svg-element/SVGSVGElement';
|
18
22
|
import SVGElement from '../nodes/svg-element/SVGElement';
|
19
23
|
import HTMLScriptElement from '../nodes/html-script-element/HTMLScriptElement';
|
@@ -59,13 +63,12 @@ import IResponse from './IResponse';
|
|
59
63
|
import AsyncTaskTypeEnum from './AsyncTaskTypeEnum';
|
60
64
|
import RelativeURL from '../location/RelativeURL';
|
61
65
|
import Storage from '../storage/Storage';
|
62
|
-
import HTMLLinkElement from '../nodes/html-link-element/HTMLLinkElement';
|
63
|
-
import HTMLStyleElement from '../nodes/html-style-element/HTMLStyleElement';
|
64
66
|
import IFetchOptions from './IFetchOptions';
|
65
67
|
import IWindow from './IWindow';
|
66
68
|
import URLSearchParams from '../url-search-params/URLSearchParams';
|
67
69
|
import HTMLCollection from '../nodes/element/HTMLCollection';
|
68
70
|
import NodeList from '../nodes/node/NodeList';
|
71
|
+
import MediaQueryList from '../match-media/MediaQueryList';
|
69
72
|
|
70
73
|
const FETCH_RESPONSE_TYPE_METHODS = ['blob', 'json', 'text'];
|
71
74
|
|
@@ -95,6 +98,8 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
95
98
|
public readonly HTMLScriptElement = HTMLScriptElement;
|
96
99
|
public readonly HTMLLinkElement = HTMLLinkElement;
|
97
100
|
public readonly HTMLStyleElement = HTMLStyleElement;
|
101
|
+
public readonly HTMLLabelElement = HTMLLabelElement;
|
102
|
+
public readonly HTMLSlotElement = HTMLSlotElement;
|
98
103
|
public readonly SVGSVGElement = SVGSVGElement;
|
99
104
|
public readonly SVGElement = SVGElement;
|
100
105
|
public readonly Text = Text;
|
@@ -146,6 +151,7 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
146
151
|
public readonly URLSearchParams = URLSearchParams;
|
147
152
|
public readonly HTMLCollection = HTMLCollection;
|
148
153
|
public readonly NodeList = NodeList;
|
154
|
+
public readonly MediaQueryList = MediaQueryList;
|
149
155
|
|
150
156
|
// Events
|
151
157
|
public onload: (event: Event) => void = null;
|
@@ -165,6 +171,7 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
165
171
|
public readonly screen = new Screen();
|
166
172
|
public readonly innerWidth = 1024;
|
167
173
|
public readonly innerHeight = 768;
|
174
|
+
public readonly devicePixelRatio = 1;
|
168
175
|
public readonly sessionStorage = new Storage();
|
169
176
|
public readonly localStorage = new Storage();
|
170
177
|
|
@@ -346,6 +353,18 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
346
353
|
this.scroll(x, y);
|
347
354
|
}
|
348
355
|
|
356
|
+
/**
|
357
|
+
* Returns a new MediaQueryList object that can then be used to determine if the document matches the media query string.
|
358
|
+
*
|
359
|
+
* @param mediaQueryString A string specifying the media query to parse into a MediaQueryList.
|
360
|
+
* @returns A new MediaQueryList.
|
361
|
+
*/
|
362
|
+
public matchMedia(mediaQueryString: string): MediaQueryList {
|
363
|
+
const mediaQueryList = new MediaQueryList();
|
364
|
+
mediaQueryList._media = mediaQueryString;
|
365
|
+
return mediaQueryList;
|
366
|
+
}
|
367
|
+
|
349
368
|
/**
|
350
369
|
* Sets a timer which executes a function once the timer expires.
|
351
370
|
*
|