happy-dom 12.4.0 → 12.5.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/cjs/async-task-manager/AsyncTaskManager.d.ts +1 -1
- package/cjs/console/VirtualConsole.d.ts +1 -1
- package/cjs/fetch/Request.d.ts +2 -2
- package/cjs/fetch/Response.d.ts +2 -2
- package/cjs/fetch/data-uri/DataURIParser.d.ts +1 -1
- package/cjs/fetch/multipart/MultipartFormDataParser.d.ts +2 -2
- package/cjs/fetch/types/IRequest.d.ts +2 -2
- package/cjs/fetch/types/IRequestBody.d.ts +2 -2
- package/cjs/fetch/types/IResponse.d.ts +2 -2
- package/cjs/fetch/types/IResponseBody.d.ts +2 -2
- package/cjs/fetch/utilities/FetchBodyUtility.d.ts +2 -2
- package/cjs/file/Blob.d.ts +1 -1
- package/cjs/file/File.d.ts +1 -1
- package/cjs/file/FileReader.d.ts +1 -1
- package/cjs/nodes/document/Document.cjs +1 -0
- package/cjs/nodes/document/Document.cjs.map +1 -1
- package/cjs/nodes/document/Document.d.ts +1 -0
- package/cjs/nodes/document/Document.d.ts.map +1 -1
- package/cjs/nodes/html-element/HTMLElementUtility.cjs +10 -0
- package/cjs/nodes/html-element/HTMLElementUtility.cjs.map +1 -1
- package/cjs/nodes/html-element/HTMLElementUtility.d.ts.map +1 -1
- package/cjs/nodes/html-media-element/HTMLMediaElement.cjs +1 -1
- package/cjs/nodes/html-media-element/HTMLMediaElement.cjs.map +1 -1
- package/cjs/url/URL.d.ts +2 -2
- package/cjs/version.cjs +1 -1
- package/cjs/window/GlobalWindow.d.ts +1 -1
- package/cjs/window/IHappyDOMOptions.d.ts +1 -1
- package/cjs/window/INodeJSGlobal.d.ts +2 -2
- package/cjs/window/IWindow.d.ts +6 -6
- package/cjs/window/VMGlobalPropertyScript.d.ts +1 -1
- package/cjs/window/Window.cjs +5 -1
- package/cjs/window/Window.cjs.map +1 -1
- package/cjs/window/Window.d.ts +8 -9
- package/cjs/window/Window.d.ts.map +1 -1
- package/cjs/xml-http-request/utilities/XMLHttpRequestSyncRequestScriptBuilder.d.ts +1 -1
- package/cjs/xml-http-request/utilities/XMLHttpRequestURLUtility.d.ts +1 -1
- package/lib/nodes/document/Document.d.ts +1 -0
- package/lib/nodes/document/Document.d.ts.map +1 -1
- package/lib/nodes/document/Document.js +1 -0
- package/lib/nodes/document/Document.js.map +1 -1
- package/lib/nodes/html-element/HTMLElementUtility.d.ts.map +1 -1
- package/lib/nodes/html-element/HTMLElementUtility.js +10 -0
- package/lib/nodes/html-element/HTMLElementUtility.js.map +1 -1
- package/lib/nodes/html-media-element/HTMLMediaElement.js +2 -1
- package/lib/nodes/html-media-element/HTMLMediaElement.js.map +1 -1
- package/lib/version.js +1 -1
- package/lib/window/Window.d.ts +1 -2
- package/lib/window/Window.d.ts.map +1 -1
- package/lib/window/Window.js +6 -2
- package/lib/window/Window.js.map +1 -1
- package/package.json +2 -2
- package/src/nodes/document/Document.ts +1 -0
- package/src/nodes/html-element/HTMLElementUtility.ts +14 -0
- package/src/window/Window.ts +7 -2
- package/tsconfig.json +3 -3
@@ -16,16 +16,20 @@ export default class HTMLElementUtility {
|
|
16
16
|
return;
|
17
17
|
}
|
18
18
|
|
19
|
+
const relatedTarget = element.ownerDocument['_nextActiveElement'] ?? null;
|
20
|
+
|
19
21
|
element.ownerDocument['_activeElement'] = null;
|
20
22
|
|
21
23
|
element.dispatchEvent(
|
22
24
|
new FocusEvent('blur', {
|
25
|
+
relatedTarget,
|
23
26
|
bubbles: false,
|
24
27
|
composed: true
|
25
28
|
})
|
26
29
|
);
|
27
30
|
element.dispatchEvent(
|
28
31
|
new FocusEvent('focusout', {
|
32
|
+
relatedTarget,
|
29
33
|
bubbles: true,
|
30
34
|
composed: true
|
31
35
|
})
|
@@ -42,20 +46,30 @@ export default class HTMLElementUtility {
|
|
42
46
|
return;
|
43
47
|
}
|
44
48
|
|
49
|
+
// Set the next active element so `blur` can use it for `relatedTarget`.
|
50
|
+
element.ownerDocument['_nextActiveElement'] = element;
|
51
|
+
|
52
|
+
const relatedTarget = element.ownerDocument['_activeElement'];
|
53
|
+
|
45
54
|
if (element.ownerDocument['_activeElement'] !== null) {
|
46
55
|
element.ownerDocument['_activeElement'].blur();
|
47
56
|
}
|
48
57
|
|
58
|
+
// Clean up after blur, so it does not affect next blur call.
|
59
|
+
element.ownerDocument['_nextActiveElement'] = null;
|
60
|
+
|
49
61
|
element.ownerDocument['_activeElement'] = element;
|
50
62
|
|
51
63
|
element.dispatchEvent(
|
52
64
|
new FocusEvent('focus', {
|
65
|
+
relatedTarget,
|
53
66
|
bubbles: false,
|
54
67
|
composed: true
|
55
68
|
})
|
56
69
|
);
|
57
70
|
element.dispatchEvent(
|
58
71
|
new FocusEvent('focusin', {
|
72
|
+
relatedTarget,
|
59
73
|
bubbles: true,
|
60
74
|
composed: true
|
61
75
|
})
|
package/src/window/Window.ts
CHANGED
@@ -34,7 +34,7 @@ import SVGGraphicsElement from '../nodes/svg-element/SVGGraphicsElement.js';
|
|
34
34
|
import HTMLScriptElement from '../nodes/html-script-element/HTMLScriptElement.js';
|
35
35
|
import HTMLImageElement from '../nodes/html-image-element/HTMLImageElement.js';
|
36
36
|
import ImageImplementation from '../nodes/html-image-element/Image.js';
|
37
|
-
import
|
37
|
+
import DocumentFragmentImplementation from '../nodes/document-fragment/DocumentFragment.js';
|
38
38
|
import CharacterData from '../nodes/character-data/CharacterData.js';
|
39
39
|
import NodeIterator from '../tree-walker/NodeIterator.js';
|
40
40
|
import TreeWalker from '../tree-walker/TreeWalker.js';
|
@@ -259,7 +259,6 @@ export default class Window extends EventTarget implements IWindow {
|
|
259
259
|
public readonly ShadowRoot = ShadowRoot;
|
260
260
|
public readonly ProcessingInstruction = ProcessingInstruction;
|
261
261
|
public readonly Element = Element;
|
262
|
-
public readonly DocumentFragment = DocumentFragment;
|
263
262
|
public readonly CharacterData = CharacterData;
|
264
263
|
public readonly NodeFilter = NodeFilter;
|
265
264
|
public readonly NodeIterator = NodeIterator;
|
@@ -346,6 +345,7 @@ export default class Window extends EventTarget implements IWindow {
|
|
346
345
|
public readonly Range;
|
347
346
|
public readonly FileReader;
|
348
347
|
public readonly Image;
|
348
|
+
public readonly DocumentFragment;
|
349
349
|
public readonly Audio;
|
350
350
|
|
351
351
|
// Events
|
@@ -562,6 +562,7 @@ export default class Window extends EventTarget implements IWindow {
|
|
562
562
|
ResponseImplementation._ownerDocument = document;
|
563
563
|
RequestImplementation._ownerDocument = document;
|
564
564
|
ImageImplementation._ownerDocument = document;
|
565
|
+
DocumentFragmentImplementation._ownerDocument = document;
|
565
566
|
FileReaderImplementation._ownerDocument = document;
|
566
567
|
DOMParserImplementation._ownerDocument = document;
|
567
568
|
RangeImplementation._ownerDocument = document;
|
@@ -577,6 +578,9 @@ export default class Window extends EventTarget implements IWindow {
|
|
577
578
|
class Image extends ImageImplementation {
|
578
579
|
public static _ownerDocument: IDocument = document;
|
579
580
|
}
|
581
|
+
class DocumentFragment extends DocumentFragmentImplementation {
|
582
|
+
public static _ownerDocument: IDocument = document;
|
583
|
+
}
|
580
584
|
class FileReader extends FileReaderImplementation {
|
581
585
|
public static _ownerDocument: IDocument = document;
|
582
586
|
}
|
@@ -597,6 +601,7 @@ export default class Window extends EventTarget implements IWindow {
|
|
597
601
|
this.Response = Response;
|
598
602
|
this.Request = Request;
|
599
603
|
this.Image = Image;
|
604
|
+
this.DocumentFragment = DocumentFragment;
|
600
605
|
this.FileReader = FileReader;
|
601
606
|
this.DOMParser = DOMParser;
|
602
607
|
this.XMLHttpRequest = XMLHttpRequest;
|
package/tsconfig.json
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
"compilerOptions": {
|
3
3
|
"outDir": "lib",
|
4
4
|
"rootDir": "src",
|
5
|
-
"target": "
|
5
|
+
"target": "ES2020",
|
6
6
|
"declaration": true,
|
7
7
|
"declarationMap": true,
|
8
|
-
"module": "
|
9
|
-
"moduleResolution": "
|
8
|
+
"module": "Node16",
|
9
|
+
"moduleResolution": "Node16",
|
10
10
|
"esModuleInterop": true,
|
11
11
|
"experimentalDecorators": true,
|
12
12
|
"allowSyntheticDefaultImports": true,
|