happy-dom 7.2.0 → 7.4.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.

Files changed (127) hide show
  1. package/lib/event/EventTarget.d.ts +14 -1
  2. package/lib/event/EventTarget.js +16 -1
  3. package/lib/event/EventTarget.js.map +1 -1
  4. package/lib/event/IEventTarget.d.ts +20 -0
  5. package/lib/event/NonImplementedEventTypes.js +2 -1
  6. package/lib/event/NonImplementedEventTypes.js.map +1 -1
  7. package/lib/fetch/IRequestInit.d.ts +1 -0
  8. package/lib/form-data/IFormData.d.ts +2 -0
  9. package/lib/index.d.ts +5 -1
  10. package/lib/index.js +5 -1
  11. package/lib/index.js.map +1 -1
  12. package/lib/nodes/attr/Attr.d.ts +1 -0
  13. package/lib/nodes/attr/Attr.js +1 -0
  14. package/lib/nodes/attr/Attr.js.map +1 -1
  15. package/lib/nodes/document/Document.d.ts +118 -1
  16. package/lib/nodes/document/Document.js +131 -1
  17. package/lib/nodes/document/Document.js.map +1 -1
  18. package/lib/nodes/document/IDocument.d.ts +118 -1
  19. package/lib/nodes/element/Element.d.ts +36 -0
  20. package/lib/nodes/element/Element.js +36 -0
  21. package/lib/nodes/element/Element.js.map +1 -1
  22. package/lib/nodes/element/IElement.d.ts +36 -0
  23. package/lib/nodes/html-dialog-element/HTMLDialogElement.d.ts +3 -0
  24. package/lib/nodes/html-dialog-element/HTMLDialogElement.js +3 -0
  25. package/lib/nodes/html-dialog-element/HTMLDialogElement.js.map +1 -1
  26. package/lib/nodes/html-dialog-element/IHTMLDialogElement.d.ts +3 -0
  27. package/lib/nodes/html-element/HTMLElement.d.ts +26 -0
  28. package/lib/nodes/html-element/HTMLElement.js +26 -0
  29. package/lib/nodes/html-element/HTMLElement.js.map +1 -1
  30. package/lib/nodes/html-element/IHTMLElement.d.ts +26 -0
  31. package/lib/nodes/html-form-element/HTMLFormElement.d.ts +4 -0
  32. package/lib/nodes/html-form-element/HTMLFormElement.js +7 -0
  33. package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
  34. package/lib/nodes/html-form-element/IHTMLFormElement.d.ts +4 -0
  35. package/lib/nodes/html-input-element/HTMLInputElement.d.ts +4 -0
  36. package/lib/nodes/html-input-element/HTMLInputElement.js +4 -0
  37. package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
  38. package/lib/nodes/html-input-element/IHTMLInputElement.d.ts +4 -0
  39. package/lib/nodes/html-media-element/HTMLMediaElement.d.ts +23 -8
  40. package/lib/nodes/html-media-element/HTMLMediaElement.js +15 -0
  41. package/lib/nodes/html-media-element/HTMLMediaElement.js.map +1 -1
  42. package/lib/nodes/html-media-element/IHTMLMediaElement.d.ts +24 -0
  43. package/lib/nodes/html-select-element/HTMLSelectElement.d.ts +3 -0
  44. package/lib/nodes/html-select-element/HTMLSelectElement.js +3 -0
  45. package/lib/nodes/html-select-element/HTMLSelectElement.js.map +1 -1
  46. package/lib/nodes/html-select-element/IHTMLSelectElement.d.ts +3 -0
  47. package/lib/nodes/html-slot-element/HTMLSlotElement.d.ts +2 -0
  48. package/lib/nodes/html-slot-element/HTMLSlotElement.js +5 -0
  49. package/lib/nodes/html-slot-element/HTMLSlotElement.js.map +1 -1
  50. package/lib/nodes/html-slot-element/IHTMLSlotElement.d.ts +2 -0
  51. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.d.ts +4 -1
  52. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +4 -1
  53. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
  54. package/lib/nodes/html-text-area-element/IHTMLTextAreaElement.d.ts +3 -0
  55. package/lib/nodes/node/INode.d.ts +8 -0
  56. package/lib/nodes/node/Node.d.ts +20 -0
  57. package/lib/nodes/node/Node.js +154 -0
  58. package/lib/nodes/node/Node.js.map +1 -1
  59. package/lib/nodes/node/NodeDocumentPositionEnum.d.ts +9 -0
  60. package/lib/nodes/node/NodeDocumentPositionEnum.js +13 -0
  61. package/lib/nodes/node/NodeDocumentPositionEnum.js.map +1 -0
  62. package/lib/nodes/node/NodeUtility.d.ts +16 -0
  63. package/lib/nodes/node/NodeUtility.js +100 -0
  64. package/lib/nodes/node/NodeUtility.js.map +1 -1
  65. package/lib/nodes/processing-instruction/IProcessingInstruction.d.ts +4 -0
  66. package/lib/nodes/processing-instruction/IProcessingInstruction.js +3 -0
  67. package/lib/nodes/processing-instruction/IProcessingInstruction.js.map +1 -0
  68. package/lib/nodes/processing-instruction/ProcessingInstruction.d.ts +12 -0
  69. package/lib/nodes/processing-instruction/ProcessingInstruction.js +20 -0
  70. package/lib/nodes/processing-instruction/ProcessingInstruction.js.map +1 -0
  71. package/lib/nodes/shadow-root/IShadowRoot.d.ts +2 -0
  72. package/lib/nodes/shadow-root/ShadowRoot.d.ts +2 -0
  73. package/lib/nodes/shadow-root/ShadowRoot.js +2 -0
  74. package/lib/nodes/shadow-root/ShadowRoot.js.map +1 -1
  75. package/lib/nodes/svg-element/ISVGElement.d.ts +7 -0
  76. package/lib/nodes/svg-element/ISVGSVGElement.d.ts +19 -0
  77. package/lib/nodes/svg-element/SVGElement.d.ts +7 -0
  78. package/lib/nodes/svg-element/SVGElement.js +7 -0
  79. package/lib/nodes/svg-element/SVGElement.js.map +1 -1
  80. package/lib/nodes/svg-element/SVGSVGElement.d.ts +19 -0
  81. package/lib/nodes/svg-element/SVGSVGElement.js +22 -0
  82. package/lib/nodes/svg-element/SVGSVGElement.js.map +1 -1
  83. package/lib/window/GlobalWindow.d.ts +2 -0
  84. package/lib/window/IWindow.d.ts +6 -0
  85. package/lib/window/Window.d.ts +5 -0
  86. package/lib/window/Window.js +2 -0
  87. package/lib/window/Window.js.map +1 -1
  88. package/package.json +2 -2
  89. package/src/event/EventTarget.ts +17 -1
  90. package/src/event/IEventTarget.ts +22 -0
  91. package/src/event/NonImplementedEventTypes.ts +2 -1
  92. package/src/index.ts +9 -1
  93. package/src/nodes/attr/Attr.ts +1 -0
  94. package/src/nodes/document/Document.ts +139 -1
  95. package/src/nodes/document/IDocument.ts +121 -1
  96. package/src/nodes/element/Element.ts +38 -0
  97. package/src/nodes/element/IElement.ts +38 -0
  98. package/src/nodes/html-dialog-element/HTMLDialogElement.ts +4 -0
  99. package/src/nodes/html-dialog-element/IHTMLDialogElement.ts +5 -0
  100. package/src/nodes/html-element/HTMLElement.ts +28 -0
  101. package/src/nodes/html-element/IHTMLElement.ts +28 -0
  102. package/src/nodes/html-form-element/HTMLFormElement.ts +6 -0
  103. package/src/nodes/html-form-element/IHTMLFormElement.ts +6 -0
  104. package/src/nodes/html-input-element/HTMLInputElement.ts +5 -0
  105. package/src/nodes/html-input-element/IHTMLInputElement.ts +6 -0
  106. package/src/nodes/html-media-element/HTMLMediaElement.ts +23 -8
  107. package/src/nodes/html-media-element/IHTMLMediaElement.ts +26 -0
  108. package/src/nodes/html-select-element/HTMLSelectElement.ts +5 -0
  109. package/src/nodes/html-select-element/IHTMLSelectElement.ts +5 -0
  110. package/src/nodes/html-slot-element/HTMLSlotElement.ts +4 -0
  111. package/src/nodes/html-slot-element/IHTMLSlotElement.ts +4 -0
  112. package/src/nodes/html-text-area-element/HTMLTextAreaElement.ts +6 -1
  113. package/src/nodes/html-text-area-element/IHTMLTextAreaElement.ts +5 -0
  114. package/src/nodes/node/INode.ts +8 -0
  115. package/src/nodes/node/Node.ts +191 -1
  116. package/src/nodes/node/NodeDocumentPositionEnum.ts +10 -0
  117. package/src/nodes/node/NodeUtility.ts +137 -0
  118. package/src/nodes/processing-instruction/IProcessingInstruction.ts +5 -0
  119. package/src/nodes/processing-instruction/ProcessingInstruction.ts +13 -0
  120. package/src/nodes/shadow-root/IShadowRoot.ts +4 -0
  121. package/src/nodes/shadow-root/ShadowRoot.ts +4 -0
  122. package/src/nodes/svg-element/ISVGElement.ts +9 -0
  123. package/src/nodes/svg-element/ISVGSVGElement.ts +21 -0
  124. package/src/nodes/svg-element/SVGElement.ts +9 -0
  125. package/src/nodes/svg-element/SVGSVGElement.ts +21 -0
  126. package/src/window/IWindow.ts +2 -0
  127. package/src/window/Window.ts +2 -0
@@ -7,6 +7,7 @@ import IChildNode from '../child-node/IChildNode';
7
7
  import IParentNode from '../parent-node/IParentNode';
8
8
  import INonDocumentTypeChildNode from '../child-node/INonDocumentTypeChildNode';
9
9
  import IDOMRectList from './IDOMRectList';
10
+ import Event from '../../event/Event';
10
11
 
11
12
  export type TInsertAdjacentPositions = 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend';
12
13
 
@@ -18,6 +19,7 @@ export default interface IElement extends IChildNode, INonDocumentTypeChildNode,
18
19
  readonly shadowRoot: IShadowRoot;
19
20
  readonly classList: IDOMTokenList;
20
21
  readonly namespaceURI: string;
22
+ prefix: string | null;
21
23
  scrollTop: number;
22
24
  scrollLeft: number;
23
25
  id: string;
@@ -29,6 +31,42 @@ export default interface IElement extends IChildNode, INonDocumentTypeChildNode,
29
31
  readonly localName: string;
30
32
  readonly attributes: { [k: string | number]: IAttr } & { length: number };
31
33
 
34
+ // Events
35
+ oncancel: (event: Event) => void | null;
36
+ onerror: (event: Event) => void | null;
37
+ onscroll: (event: Event) => void | null;
38
+ onselect: (event: Event) => void | null;
39
+ onwheel: (event: Event) => void | null;
40
+ oncopy: (event: Event) => void | null;
41
+ oncut: (event: Event) => void | null;
42
+ onpaste: (event: Event) => void | null;
43
+ oncompositionend: (event: Event) => void | null;
44
+ oncompositionstart: (event: Event) => void | null;
45
+ oncompositionupdate: (event: Event) => void | null;
46
+ onblur: (event: Event) => void | null;
47
+ onfocus: (event: Event) => void | null;
48
+ onfocusin: (event: Event) => void | null;
49
+ onfocusout: (event: Event) => void | null;
50
+ onfullscreenchange: (event: Event) => void | null;
51
+ onfullscreenerror: (event: Event) => void | null;
52
+ onkeydown: (event: Event) => void | null;
53
+ onkeyup: (event: Event) => void | null;
54
+ onauxclick: (event: Event) => void | null;
55
+ onclick: (event: Event) => void | null;
56
+ oncontextmenu: (event: Event) => void | null;
57
+ ondblclick: (event: Event) => void | null;
58
+ onmousedown: (event: Event) => void | null;
59
+ onmouseenter: (event: Event) => void | null;
60
+ onmouseleave: (event: Event) => void | null;
61
+ onmousemove: (event: Event) => void | null;
62
+ onmouseout: (event: Event) => void | null;
63
+ onmouseover: (event: Event) => void | null;
64
+ onmouseup: (event: Event) => void | null;
65
+ ontouchcancel: (event: Event) => void | null;
66
+ ontouchend: (event: Event) => void | null;
67
+ ontouchmove: (event: Event) => void | null;
68
+ ontouchstart: (event: Event) => void | null;
69
+
32
70
  /**
33
71
  * Attribute changed callback.
34
72
  *
@@ -11,6 +11,10 @@ import IHTMLDialogElement from './IHTMLDialogElement';
11
11
  export default class HTMLDialogElement extends HTMLElement implements IHTMLDialogElement {
12
12
  public returnValue = '';
13
13
 
14
+ // Events
15
+ public oncancel: (event: Event) => void | null = null;
16
+ public onclose: (event: Event) => void | null = null;
17
+
14
18
  /**
15
19
  * Returns open.
16
20
  *
@@ -1,3 +1,4 @@
1
+ import Event from '../../event/Event';
1
2
  import IHTMLElement from '../html-element/IHTMLElement';
2
3
 
3
4
  /**
@@ -10,6 +11,10 @@ export default interface IHTMLDialogElement extends IHTMLElement {
10
11
  open: boolean;
11
12
  returnValue: string;
12
13
 
14
+ // Events
15
+ oncancel: (event: Event) => void | null;
16
+ onclose: (event: Event) => void | null;
17
+
13
18
  /**
14
19
  * Closes the dialog.
15
20
  *
@@ -7,6 +7,7 @@ import PointerEvent from '../../event/events/PointerEvent';
7
7
  import DatasetUtility from './DatasetUtility';
8
8
  import NodeTypeEnum from '../node/NodeTypeEnum';
9
9
  import DOMException from '../../exception/DOMException';
10
+ import Event from '../../event/Event';
10
11
 
11
12
  /**
12
13
  * HTML Element.
@@ -29,6 +30,33 @@ export default class HTMLElement extends Element implements IHTMLElement {
29
30
  private _style: CSSStyleDeclaration = null;
30
31
  private _dataset: { [key: string]: string } = null;
31
32
 
33
+ // Events
34
+ public oncopy: (event: Event) => void | null = null;
35
+ public oncut: (event: Event) => void | null = null;
36
+ public onpaste: (event: Event) => void | null = null;
37
+ public oninvalid: (event: Event) => void | null = null;
38
+ public onanimationcancel: (event: Event) => void | null = null;
39
+ public onanimationend: (event: Event) => void | null = null;
40
+ public onanimationiteration: (event: Event) => void | null = null;
41
+ public onanimationstart: (event: Event) => void | null = null;
42
+ public onbeforeinput: (event: Event) => void | null = null;
43
+ public oninput: (event: Event) => void | null = null;
44
+ public onchange: (event: Event) => void | null = null;
45
+ public ongotpointercapture: (event: Event) => void | null = null;
46
+ public onlostpointercapture: (event: Event) => void | null = null;
47
+ public onpointercancel: (event: Event) => void | null = null;
48
+ public onpointerdown: (event: Event) => void | null = null;
49
+ public onpointerenter: (event: Event) => void | null = null;
50
+ public onpointerleave: (event: Event) => void | null = null;
51
+ public onpointermove: (event: Event) => void | null = null;
52
+ public onpointerout: (event: Event) => void | null = null;
53
+ public onpointerover: (event: Event) => void | null = null;
54
+ public onpointerup: (event: Event) => void | null = null;
55
+ public ontransitioncancel: (event: Event) => void | null = null;
56
+ public ontransitionend: (event: Event) => void | null = null;
57
+ public ontransitionrun: (event: Event) => void | null = null;
58
+ public ontransitionstart: (event: Event) => void | null = null;
59
+
32
60
  /**
33
61
  * Returns tab index.
34
62
  *
@@ -1,3 +1,4 @@
1
+ import Event from '../../event/Event';
1
2
  import CSSStyleDeclaration from '../../css/declaration/CSSStyleDeclaration';
2
3
  import IElement from '../element/IElement';
3
4
 
@@ -20,6 +21,33 @@ export default interface IHTMLElement extends IElement {
20
21
  innerText: string;
21
22
  outerText: string;
22
23
 
24
+ // Events
25
+ oncopy: (event: Event) => void | null;
26
+ oncut: (event: Event) => void | null;
27
+ onpaste: (event: Event) => void | null;
28
+ oninvalid: (event: Event) => void | null;
29
+ onanimationcancel: (event: Event) => void | null;
30
+ onanimationend: (event: Event) => void | null;
31
+ onanimationiteration: (event: Event) => void | null;
32
+ onanimationstart: (event: Event) => void | null;
33
+ onbeforeinput: (event: Event) => void | null;
34
+ oninput: (event: Event) => void | null;
35
+ onchange: (event: Event) => void | null;
36
+ ongotpointercapture: (event: Event) => void | null;
37
+ onlostpointercapture: (event: Event) => void | null;
38
+ onpointercancel: (event: Event) => void | null;
39
+ onpointerdown: (event: Event) => void | null;
40
+ onpointerenter: (event: Event) => void | null;
41
+ onpointerleave: (event: Event) => void | null;
42
+ onpointermove: (event: Event) => void | null;
43
+ onpointerout: (event: Event) => void | null;
44
+ onpointerover: (event: Event) => void | null;
45
+ onpointerup: (event: Event) => void | null;
46
+ ontransitioncancel: (event: Event) => void | null;
47
+ ontransitionend: (event: Event) => void | null;
48
+ ontransitionrun: (event: Event) => void | null;
49
+ ontransitionstart: (event: Event) => void | null;
50
+
23
51
  /**
24
52
  * Triggers a click event.
25
53
  */
@@ -1,6 +1,7 @@
1
1
  import HTMLElement from '../html-element/HTMLElement';
2
2
  import IElement from '../element/IElement';
3
3
  import IHTMLFormElement from './IHTMLFormElement';
4
+ import Event from '../../event/Event';
4
5
 
5
6
  /**
6
7
  * HTML Form Element.
@@ -9,6 +10,11 @@ import IHTMLFormElement from './IHTMLFormElement';
9
10
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement.
10
11
  */
11
12
  export default class HTMLFormElement extends HTMLElement implements IHTMLFormElement {
13
+ // Events
14
+ public onformdata: (event: Event) => void | null = null;
15
+ public onreset: (event: Event) => void | null = null;
16
+ public onsubmit: (event: Event) => void | null = null;
17
+
12
18
  /**
13
19
  * Returns name.
14
20
  *
@@ -1,3 +1,4 @@
1
+ import Event from '../../event/Event';
1
2
  import IElement from '../element/IElement';
2
3
  import IHTMLElement from '../html-element/IHTMLElement';
3
4
 
@@ -20,6 +21,11 @@ export default interface IHTMLFormElement extends IHTMLElement {
20
21
  elements: IElement[];
21
22
  length: number;
22
23
 
24
+ // Events
25
+ onformdata: (event: Event) => void | null;
26
+ onreset: (event: Event) => void | null;
27
+ onsubmit: (event: Event) => void | null;
28
+
23
29
  /**
24
30
  * Submits form.
25
31
  */
@@ -38,6 +38,11 @@ export default class HTMLInputElement extends HTMLElement implements IHTMLInputE
38
38
  // Type specific: file
39
39
  public files: File[] = [];
40
40
 
41
+ // Events
42
+ public oninput: (event: Event) => void | null = null;
43
+ public oninvalid: (event: Event) => void | null = null;
44
+ public onselectionchange: (event: Event) => void | null = null;
45
+
41
46
  // Type specific: text/password/search/tel/url/week/month
42
47
  private _selectionStart: number = null;
43
48
  private _selectionEnd: number = null;
@@ -3,6 +3,7 @@ import IHTMLElement from '../html-element/IHTMLElement';
3
3
  import IHTMLFormElement from '../html-form-element/IHTMLFormElement';
4
4
  import HTMLInputElementSelectionModeEnum from './HTMLInputElementSelectionModeEnum';
5
5
  import ValidityState from '../validity-state/ValidityState';
6
+ import Event from '../../event/Event';
6
7
 
7
8
  /**
8
9
  * HTML Input Element.
@@ -53,6 +54,11 @@ export default interface IHTMLInputElement extends IHTMLElement {
53
54
  valueAsNumber: number;
54
55
  validationMessage: string;
55
56
 
57
+ // Events
58
+ oninput: (event: Event) => void | null;
59
+ oninvalid: (event: Event) => void | null;
60
+ onselectionchange: (event: Event) => void | null;
61
+
56
62
  /**
57
63
  * Sets validation message.
58
64
  *
@@ -44,14 +44,29 @@ export default class HTMLMediaElement extends HTMLElement implements IHTMLMediaE
44
44
  public readonly played = getTimeRangeDummy();
45
45
 
46
46
  // Events
47
- public onabort: (event: Event) => void = null;
48
- public oncanplay: (event: Event) => void = null;
49
- public oncanplaythrough: (event: Event) => void = null;
50
- public ondurationchange: (event: Event) => void = null;
51
- public onemptied: (event: Event) => void = null;
52
- public onended: (event: Event) => void = null;
53
- public onerror: (event: ErrorEvent) => void = null;
54
- public onloadeddata: (event: Event) => void = null;
47
+ public onabort: (event: Event) => void | null = null;
48
+ public oncanplay: (event: Event) => void | null = null;
49
+ public oncanplaythrough: (event: Event) => void | null = null;
50
+ public ondurationchange: (event: Event) => void | null = null;
51
+ public onemptied: (event: Event) => void | null = null;
52
+ public onended: (event: Event) => void | null = null;
53
+ public onerror: (event: ErrorEvent) => void | null = null;
54
+ public onloadeddata: (event: Event) => void | null = null;
55
+ public onloadedmetadata: (event: Event) => void | null = null;
56
+ public onloadstart: (event: Event) => void | null = null;
57
+ public onpause: (event: Event) => void | null = null;
58
+ public onplay: (event: Event) => void | null = null;
59
+ public onplaying: (event: Event) => void | null = null;
60
+ public onprogress: (event: Event) => void | null = null;
61
+ public onratechange: (event: Event) => void | null = null;
62
+ public onresize: (event: Event) => void | null = null;
63
+ public onseeked: (event: Event) => void | null = null;
64
+ public onseeking: (event: Event) => void | null = null;
65
+ public onstalled: (event: Event) => void | null = null;
66
+ public onsuspend: (event: Event) => void | null = null;
67
+ public ontimeupdate: (event: Event) => void | null = null;
68
+ public onvolumechange: (event: Event) => void | null = null;
69
+ public onwaiting: (event: Event) => void | null = null;
55
70
 
56
71
  #volume = 1;
57
72
  #paused = true;
@@ -1,3 +1,4 @@
1
+ import Event from '../../event/Event';
1
2
  import IHTMLElement from '../html-element/IHTMLElement';
2
3
 
3
4
  /**
@@ -39,6 +40,31 @@ export default interface IHTMLMediaElement extends IHTMLElement {
39
40
  src: string;
40
41
  volume: number | string;
41
42
 
43
+ // Events
44
+ onabort: (event: Event) => void | null;
45
+ oncanplay: (event: Event) => void | null;
46
+ oncanplaythrough: (event: Event) => void | null;
47
+ ondurationchange: (event: Event) => void | null;
48
+ onemptied: (event: Event) => void | null;
49
+ onended: (event: Event) => void | null;
50
+ onerror: (event: Event) => void | null;
51
+ onloadeddata: (event: Event) => void | null;
52
+ onloadedmetadata: (event: Event) => void | null;
53
+ onloadstart: (event: Event) => void | null;
54
+ onpause: (event: Event) => void | null;
55
+ onplay: (event: Event) => void | null;
56
+ onplaying: (event: Event) => void | null;
57
+ onprogress: (event: Event) => void | null;
58
+ onratechange: (event: Event) => void | null;
59
+ onresize: (event: Event) => void | null;
60
+ onseeked: (event: Event) => void | null;
61
+ onseeking: (event: Event) => void | null;
62
+ onstalled: (event: Event) => void | null;
63
+ onsuspend: (event: Event) => void | null;
64
+ ontimeupdate: (event: Event) => void | null;
65
+ onvolumechange: (event: Event) => void | null;
66
+ onwaiting: (event: Event) => void | null;
67
+
42
68
  /**
43
69
  * A MediaStream object which can be used as a source for audio and/or video data by other media processing code,
44
70
  * or as a source for WebRTC.
@@ -12,6 +12,7 @@ import IHTMLOptionsCollection from '../html-option-element/IHTMLOptionsCollectio
12
12
  import INodeList from '../node/INodeList';
13
13
  import HTMLSelectElementValueSanitizer from './HTMLSelectElementValueSanitizer';
14
14
  import IHTMLSelectElement from './IHTMLSelectElement';
15
+ import Event from '../../event/Event';
15
16
 
16
17
  /**
17
18
  * HTML Select Element.
@@ -23,6 +24,10 @@ export default class HTMLSelectElement extends HTMLElement implements IHTMLSelec
23
24
  public type: string;
24
25
  public labels: INodeList<IHTMLLabelElement>;
25
26
 
27
+ // Events
28
+ public onchange: (event: Event) => void | null = null;
29
+ public oninput: (event: Event) => void | null = null;
30
+
26
31
  public _value = null;
27
32
  public _selectedIndex = -1;
28
33
  public _options: IHTMLOptionsCollection = null;
@@ -4,6 +4,7 @@ import IHTMLLabelElement from '../html-label-element/IHTMLLabelElement';
4
4
  import INodeList from '../node/INodeList';
5
5
  import IHTMLOptionsCollection from '../html-option-element/IHTMLOptionsCollection';
6
6
  import ValidityState from '../validity-state/ValidityState';
7
+ import Event from '../../event/Event';
7
8
 
8
9
  /**
9
10
  * HTML Select Element.
@@ -24,4 +25,8 @@ export default interface IHTMLSelectElement extends IHTMLElement {
24
25
  willValidate: boolean;
25
26
  name: string;
26
27
  multiple: boolean;
28
+
29
+ // Events
30
+ onchange: (event: Event) => void | null;
31
+ oninput: (event: Event) => void | null;
27
32
  }
@@ -4,6 +4,7 @@ import IHTMLSlotElement from './IHTMLSlotElement';
4
4
  import IText from '../text/IText';
5
5
  import IElement from '../element/IElement';
6
6
  import INode from '../node/INode';
7
+ import Event from '../../event/Event';
7
8
 
8
9
  /**
9
10
  * HTML Slot Element.
@@ -12,6 +13,9 @@ import INode from '../node/INode';
12
13
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement.
13
14
  */
14
15
  export default class HTMLSlotElement extends HTMLElement implements IHTMLSlotElement {
16
+ // Events
17
+ public onslotchange: (event: Event) => void | null = null;
18
+
15
19
  /**
16
20
  * Returns name.
17
21
  *
@@ -2,6 +2,7 @@ import IHTMLElement from '../html-element/IHTMLElement';
2
2
  import IText from '../text/IText';
3
3
  import IElement from '../element/IElement';
4
4
  import INode from '../node/INode';
5
+ import Event from '../../event/Event';
5
6
 
6
7
  /**
7
8
  * HTML Slot Element.
@@ -10,6 +11,9 @@ import INode from '../node/INode';
10
11
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement.
11
12
  */
12
13
  export default interface IHTMLSlotElement extends IHTMLElement {
14
+ // Events
15
+ onslotchange: (event: Event) => void | null;
16
+
13
17
  name: string;
14
18
 
15
19
  /**
@@ -16,11 +16,16 @@ import IHTMLTextAreaElement from './IHTMLTextAreaElement';
16
16
  */
17
17
  export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTextAreaElement {
18
18
  public readonly type = 'textarea';
19
+ public defaultValue = '';
20
+
21
+ // Events
22
+ public oninput: (event: Event) => void | null = null;
23
+ public onselectionchange: (event: Event) => void | null = null;
24
+
19
25
  public _value = null;
20
26
  public _selectionStart = null;
21
27
  public _selectionEnd = null;
22
28
  public _selectionDirection = HTMLInputElementSelectionDirectionEnum.none;
23
- public defaultValue = '';
24
29
 
25
30
  /**
26
31
  * Returns minlength.
@@ -1,3 +1,4 @@
1
+ import Event from '../../event/Event';
1
2
  import IHTMLElement from '../html-element/IHTMLElement';
2
3
  import IHTMLFormElement from '../html-form-element/IHTMLFormElement';
3
4
  import HTMLInputElementSelectionModeEnum from '../html-input-element/HTMLInputElementSelectionModeEnum';
@@ -30,6 +31,10 @@ export default interface IHTMLTextAreaElement extends IHTMLElement {
30
31
  selectionDirection: string;
31
32
  textLength: number;
32
33
 
34
+ // Events
35
+ oninput: (event: Event) => void | null;
36
+ onselectionchange: (event: Event) => void | null;
37
+
33
38
  /**
34
39
  * Set selection range.
35
40
  *
@@ -3,6 +3,7 @@ import IDocument from '../document/IDocument';
3
3
  import IElement from '../element/IElement';
4
4
  import INodeList from './INodeList';
5
5
  import NodeTypeEnum from './NodeTypeEnum';
6
+ import NodeDocumentPositionEnum from './NodeDocumentPositionEnum';
6
7
 
7
8
  export default interface INode extends IEventTarget {
8
9
  readonly ELEMENT_NODE: NodeTypeEnum;
@@ -14,6 +15,12 @@ export default interface INode extends IEventTarget {
14
15
  readonly DOCUMENT_TYPE_NODE: NodeTypeEnum;
15
16
  readonly DOCUMENT_FRAGMENT_NODE: NodeTypeEnum;
16
17
  readonly PROCESSING_INSTRUCTION_NODE: NodeTypeEnum;
18
+ readonly DOCUMENT_POSITION_DISCONNECTED: NodeDocumentPositionEnum;
19
+ readonly DOCUMENT_POSITION_PRECEDING: NodeDocumentPositionEnum;
20
+ readonly DOCUMENT_POSITION_FOLLOWING: NodeDocumentPositionEnum;
21
+ readonly DOCUMENT_POSITION_CONTAINS: NodeDocumentPositionEnum;
22
+ readonly DOCUMENT_POSITION_CONTAINED_BY: NodeDocumentPositionEnum;
23
+ readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: NodeDocumentPositionEnum;
17
24
  readonly ownerDocument: IDocument;
18
25
  readonly parentNode: INode;
19
26
  readonly parentElement: IElement;
@@ -39,4 +46,5 @@ export default interface INode extends IEventTarget {
39
46
  insertBefore(newNode: INode, referenceNode?: INode | null): INode;
40
47
  replaceChild(newChild: INode, oldChild: INode): INode;
41
48
  toString(): string;
49
+ compareDocumentPosition(otherNode: INode): number;
42
50
  }
@@ -11,6 +11,9 @@ import IHTMLBaseElement from '../html-base-element/IHTMLBaseElement';
11
11
  import INodeList from './INodeList';
12
12
  import NodeListFactory from './NodeListFactory';
13
13
  import NodeTypeEnum from './NodeTypeEnum';
14
+ import NodeDocumentPositionEnum from './NodeDocumentPositionEnum';
15
+ import NodeUtility from './NodeUtility';
16
+ import IAttr from '../attr/IAttr';
14
17
 
15
18
  /**
16
19
  * Node.
@@ -29,6 +32,13 @@ export default class Node extends EventTarget implements INode {
29
32
  public static readonly DOCUMENT_TYPE_NODE = NodeTypeEnum.documentTypeNode;
30
33
  public static readonly DOCUMENT_FRAGMENT_NODE = NodeTypeEnum.documentFragmentNode;
31
34
  public static readonly PROCESSING_INSTRUCTION_NODE = NodeTypeEnum.processingInstructionNode;
35
+ public static readonly DOCUMENT_POSITION_CONTAINED_BY = NodeDocumentPositionEnum.containedBy;
36
+ public static readonly DOCUMENT_POSITION_CONTAINS = NodeDocumentPositionEnum.contains;
37
+ public static readonly DOCUMENT_POSITION_DISCONNECTED = NodeDocumentPositionEnum.disconnect;
38
+ public static readonly DOCUMENT_POSITION_FOLLOWING = NodeDocumentPositionEnum.following;
39
+ public static readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC =
40
+ NodeDocumentPositionEnum.implementationSpecific;
41
+ public static readonly DOCUMENT_POSITION_PRECEDING = NodeDocumentPositionEnum.preceding;
32
42
  public readonly ELEMENT_NODE = NodeTypeEnum.elementNode;
33
43
  public readonly ATTRIBUTE_NODE = NodeTypeEnum.attributeNode;
34
44
  public readonly TEXT_NODE = NodeTypeEnum.textNode;
@@ -38,6 +48,13 @@ export default class Node extends EventTarget implements INode {
38
48
  public readonly DOCUMENT_TYPE_NODE = NodeTypeEnum.documentTypeNode;
39
49
  public readonly DOCUMENT_FRAGMENT_NODE = NodeTypeEnum.documentFragmentNode;
40
50
  public readonly PROCESSING_INSTRUCTION_NODE = NodeTypeEnum.processingInstructionNode;
51
+ public readonly DOCUMENT_POSITION_CONTAINED_BY = NodeDocumentPositionEnum.containedBy;
52
+ public readonly DOCUMENT_POSITION_CONTAINS = NodeDocumentPositionEnum.contains;
53
+ public readonly DOCUMENT_POSITION_DISCONNECTED = NodeDocumentPositionEnum.disconnect;
54
+ public readonly DOCUMENT_POSITION_FOLLOWING = NodeDocumentPositionEnum.following;
55
+ public readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC =
56
+ NodeDocumentPositionEnum.implementationSpecific;
57
+ public readonly DOCUMENT_POSITION_PRECEDING = NodeDocumentPositionEnum.preceding;
41
58
  public readonly ownerDocument: IDocument = null;
42
59
  public readonly parentNode: INode = null;
43
60
  public readonly nodeType: number;
@@ -444,7 +461,7 @@ export default class Node extends EventTarget implements INode {
444
461
  }
445
462
 
446
463
  // eslint-disable-next-line
447
- if(event.composed && (<any>this).host) {
464
+ if (event.composed && (<any>this).host) {
448
465
  // eslint-disable-next-line
449
466
  return (<any>this).host.dispatchEvent(event);
450
467
  }
@@ -528,4 +545,177 @@ export default class Node extends EventTarget implements INode {
528
545
  }
529
546
  }
530
547
  }
548
+
549
+ /**
550
+ * Reports the position of its argument node relative to the node on which it is called.
551
+ *
552
+ * @see https://dom.spec.whatwg.org/#dom-node-comparedocumentposition
553
+ * @param otherNode Other node.
554
+ */
555
+ public compareDocumentPosition(otherNode: INode): number {
556
+ /**
557
+ * 1. If this is other, then return zero.
558
+ */
559
+ if (this === otherNode) {
560
+ return 0;
561
+ }
562
+
563
+ /**
564
+ * 2. Let node1 be other and node2 be this.
565
+ */
566
+ let node1: INode = otherNode;
567
+ let node2: INode = this;
568
+
569
+ /**
570
+ * 3. Let attr1 and attr2 be null.
571
+ */
572
+ let attr1 = null;
573
+ let attr2 = null;
574
+
575
+ /**
576
+ * 4. If node1 is an attribute, then set attr1 to node1 and node1 to attr1’s element.
577
+ */
578
+ if (node1.nodeType === Node.ATTRIBUTE_NODE) {
579
+ attr1 = node1;
580
+ node1 = (<IAttr>attr1).ownerElement;
581
+ }
582
+
583
+ /**
584
+ * 5. If node2 is an attribute, then:
585
+ * 5.1. Set attr2 to node2 and node2 to attr2’s element.
586
+ */
587
+ if (node2.nodeType === Node.ATTRIBUTE_NODE) {
588
+ attr2 = node2;
589
+ node2 = (<IAttr>attr2).ownerElement;
590
+
591
+ /**
592
+ * 5.2. If attr1 and node1 are non-null, and node2 is node1, then:
593
+ */
594
+ if (attr1 !== null && node1 !== null && node2 === node1) {
595
+ /**
596
+ * 5.2.1. For each attr in node2’s attribute list:
597
+ */
598
+ for (const attr of Object.values((<IElement>node2).attributes)) {
599
+ /**
600
+ * 5.2.1.1. If attr equals attr1, then return the result of adding DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC and DOCUMENT_POSITION_PRECEDING.
601
+ */
602
+ if (NodeUtility.nodeEquals(<IAttr>attr, attr1)) {
603
+ return (
604
+ Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | Node.DOCUMENT_POSITION_PRECEDING
605
+ );
606
+ }
607
+
608
+ /**
609
+ * 5.2.1.2. If attr equals attr2, then return the result of adding DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC and DOCUMENT_POSITION_FOLLOWING.
610
+ */
611
+ if (NodeUtility.nodeEquals(<IAttr>attr, attr2)) {
612
+ return (
613
+ Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | Node.DOCUMENT_POSITION_FOLLOWING
614
+ );
615
+ }
616
+ }
617
+ }
618
+ }
619
+
620
+ const node2Ancestors: INode[] = [];
621
+ let node2Ancestor: INode = node2;
622
+
623
+ while (node2Ancestor) {
624
+ /**
625
+ * 7. If node1 is an ancestor of node2 […] then return the result of adding DOCUMENT_POSITION_CONTAINS to DOCUMENT_POSITION_PRECEDING.
626
+ */
627
+ if (node2Ancestor === node1) {
628
+ return Node.DOCUMENT_POSITION_CONTAINS | Node.DOCUMENT_POSITION_PRECEDING;
629
+ }
630
+
631
+ node2Ancestors.push(node2Ancestor);
632
+ node2Ancestor = node2Ancestor.parentNode;
633
+ }
634
+
635
+ const node1Ancestors: INode[] = [];
636
+ let node1Ancestor: INode = node1;
637
+
638
+ while (node1Ancestor) {
639
+ /**
640
+ * 8. If node1 is a descendant of node2 […] then return the result of adding DOCUMENT_POSITION_CONTAINED_BY to DOCUMENT_POSITION_FOLLOWING.
641
+ */
642
+ if (node1Ancestor === node2) {
643
+ return Node.DOCUMENT_POSITION_CONTAINED_BY | Node.DOCUMENT_POSITION_FOLLOWING;
644
+ }
645
+
646
+ node1Ancestors.push(node1Ancestor);
647
+ node1Ancestor = node1Ancestor.parentNode;
648
+ }
649
+
650
+ const reverseArrayIndex = (array: INode[], reverseIndex: number): INode => {
651
+ return array[array.length - 1 - reverseIndex];
652
+ };
653
+
654
+ const root = reverseArrayIndex(node2Ancestors, 0);
655
+
656
+ /**
657
+ * 6. If node1 or node2 is null, or node1’s root is not node2’s root, then return the result of adding
658
+ * DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, and either
659
+ * DOCUMENT_POSITION_PRECEDING or DOCUMENT_POSITION_FOLLOWING, with the constraint that this is to be consistent, together.
660
+ */
661
+ if (!root || root !== reverseArrayIndex(node1Ancestors, 0)) {
662
+ return (
663
+ Node.DOCUMENT_POSITION_DISCONNECTED |
664
+ Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC |
665
+ Node.DOCUMENT_POSITION_FOLLOWING
666
+ );
667
+ }
668
+
669
+ // Find the lowest common ancestor
670
+ let commonAncestorIndex = 0;
671
+ const ancestorsMinLength = Math.min(node2Ancestors.length, node1Ancestors.length);
672
+
673
+ for (let i = 0; i < ancestorsMinLength; ++i) {
674
+ const node2Ancestor = reverseArrayIndex(node2Ancestors, i);
675
+ const node1Ancestor = reverseArrayIndex(node1Ancestors, i);
676
+
677
+ if (node2Ancestor !== node1Ancestor) {
678
+ break;
679
+ }
680
+
681
+ commonAncestorIndex = i;
682
+ }
683
+
684
+ const commonAncestor = reverseArrayIndex(node2Ancestors, commonAncestorIndex);
685
+
686
+ // Indexes within the common ancestor
687
+ let indexes = 0;
688
+ let node2Index = -1;
689
+ let node1Index = -1;
690
+ const node2Node = reverseArrayIndex(node2Ancestors, commonAncestorIndex + 1);
691
+ const node1Node = reverseArrayIndex(node1Ancestors, commonAncestorIndex + 1);
692
+
693
+ const computeNodeIndexes = (nodes: INode[]): void => {
694
+ for (const childNode of nodes) {
695
+ computeNodeIndexes(childNode.childNodes);
696
+
697
+ if (childNode === node2Node) {
698
+ node2Index = indexes;
699
+ } else if (childNode === node1Node) {
700
+ node1Index = indexes;
701
+ }
702
+
703
+ if (node2Index !== -1 && node1Index !== -1) {
704
+ break;
705
+ }
706
+
707
+ indexes++;
708
+ }
709
+ };
710
+
711
+ computeNodeIndexes(commonAncestor.childNodes);
712
+
713
+ /**
714
+ * 9. If node1 is preceding node2, then return DOCUMENT_POSITION_PRECEDING.
715
+ * 10. Return DOCUMENT_POSITION_FOLLOWING.
716
+ */
717
+ return node1Index < node2Index
718
+ ? Node.DOCUMENT_POSITION_PRECEDING
719
+ : Node.DOCUMENT_POSITION_FOLLOWING;
720
+ }
531
721
  }