pseudo-dom 0.6.0 → 0.7.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.
Files changed (122) hide show
  1. package/README.md +432 -13
  2. package/browser/pseudo-dom.js +3364 -603
  3. package/browser/pseudo-dom.min.js +1 -1
  4. package/dist/classes/PseudoEventListener.d.ts +96 -96
  5. package/dist/classes/PseudoEventListener.js +151 -151
  6. package/dist/classes/PseudoHTMLDocument.d.ts +67 -67
  7. package/dist/classes/PseudoHTMLDocument.js +144 -144
  8. package/dist/classes/PseudoNodeList.d.ts +34 -34
  9. package/dist/classes/PseudoNodeList.js +71 -71
  10. package/dist/classes.d.ts +20 -20
  11. package/dist/classes.js +31 -31
  12. package/dist/factories/createEvent.d.ts +28 -28
  13. package/dist/factories/createEvent.js +56 -56
  14. package/dist/factories/cssSelectAdapter.d.ts +23 -0
  15. package/dist/factories/cssSelectAdapter.js +87 -0
  16. package/dist/factories/cssSelectAdapter.min.js +1 -0
  17. package/dist/factories/eventDefaults.d.ts +31 -31
  18. package/dist/factories/eventDefaults.js +105 -105
  19. package/dist/factories/generateDocument.d.ts +11 -11
  20. package/dist/factories/generateDocument.js +65 -65
  21. package/dist/factories/generateNode.d.ts +32 -32
  22. package/dist/factories/generateNode.js +85 -85
  23. package/dist/factories/generateNodeList.d.ts +9 -9
  24. package/dist/factories/generateNodeList.js +13 -13
  25. package/dist/factories/query.d.ts +33 -0
  26. package/dist/factories/query.js +66 -0
  27. package/dist/factories/query.min.js +1 -0
  28. package/dist/factories.d.ts +11 -11
  29. package/dist/factories.js +27 -27
  30. package/dist/functions/activeElement.d.ts +14 -14
  31. package/dist/functions/activeElement.js +33 -33
  32. package/dist/functions/getParentNodes.d.ts +11 -11
  33. package/dist/functions/getParentNodes.js +22 -22
  34. package/dist/functions/getParentNodesFromAttribute.d.ts +14 -14
  35. package/dist/functions/getParentNodesFromAttribute.js +29 -29
  36. package/dist/functions/modifierState.d.ts +29 -29
  37. package/dist/functions/modifierState.js +41 -41
  38. package/dist/functions.d.ts +5 -5
  39. package/dist/functions.js +23 -23
  40. package/dist/interfaces/PseudoAnimation.d.ts +3 -3
  41. package/dist/interfaces/PseudoAnimation.js +5 -5
  42. package/dist/interfaces/PseudoAttr.d.ts +11 -11
  43. package/dist/interfaces/PseudoAttr.js +5 -5
  44. package/dist/interfaces/PseudoDOMTokenList.d.ts +16 -16
  45. package/dist/interfaces/PseudoDOMTokenList.js +5 -5
  46. package/dist/interfaces/PseudoDocument.d.ts +7 -0
  47. package/dist/interfaces/PseudoDocument.js +5 -5
  48. package/dist/interfaces/PseudoDocumentFragment.d.ts +3 -3
  49. package/dist/interfaces/PseudoDocumentFragment.js +5 -5
  50. package/dist/interfaces/PseudoElement.d.ts +20 -7
  51. package/dist/interfaces/PseudoElement.js +5 -5
  52. package/dist/interfaces/PseudoEvent.d.ts +79 -79
  53. package/dist/interfaces/PseudoEvent.js +10 -10
  54. package/dist/interfaces/PseudoEventTarget.d.ts +46 -46
  55. package/dist/interfaces/PseudoEventTarget.js +5 -5
  56. package/dist/interfaces/PseudoHTMLCollection.d.ts +23 -23
  57. package/dist/interfaces/PseudoHTMLCollection.js +5 -5
  58. package/dist/interfaces/PseudoHTMLElement.d.ts +22 -22
  59. package/dist/interfaces/PseudoHTMLElement.js +5 -5
  60. package/dist/interfaces/PseudoHTMLSlotElement.d.ts +3 -3
  61. package/dist/interfaces/PseudoHTMLSlotElement.js +5 -5
  62. package/dist/interfaces/PseudoNamedNodeMap.d.ts +11 -11
  63. package/dist/interfaces/PseudoNamedNodeMap.js +5 -5
  64. package/dist/interfaces/PseudoNode.d.ts +179 -179
  65. package/dist/interfaces/PseudoNode.js +5 -5
  66. package/dist/interfaces/PseudoShadowRoot.d.ts +3 -3
  67. package/dist/interfaces/PseudoShadowRoot.js +5 -5
  68. package/dist/main.d.ts +63 -63
  69. package/dist/main.js +155 -155
  70. package/dist/services/AnimationService.d.ts +4 -4
  71. package/dist/services/AnimationService.js +16 -16
  72. package/dist/services/AttrService.d.ts +37 -37
  73. package/dist/services/AttrService.js +81 -81
  74. package/dist/services/CommentService.d.ts +1 -1
  75. package/dist/services/CommentService.js +13 -13
  76. package/dist/services/CustomEventService.d.ts +37 -37
  77. package/dist/services/CustomEventService.js +35 -35
  78. package/dist/services/DOMTokenListService.d.ts +33 -33
  79. package/dist/services/DOMTokenListService.js +117 -117
  80. package/dist/services/DocumentFragmentService.d.ts +13 -13
  81. package/dist/services/DocumentFragmentService.js +24 -24
  82. package/dist/services/DocumentService.d.ts +7 -0
  83. package/dist/services/DocumentService.js +23 -0
  84. package/dist/services/DocumentService.min.js +1 -1
  85. package/dist/services/ElementService.d.ts +13 -0
  86. package/dist/services/ElementService.js +20 -0
  87. package/dist/services/ElementService.min.js +1 -1
  88. package/dist/services/EventService.d.ts +120 -120
  89. package/dist/services/EventService.js +250 -250
  90. package/dist/services/EventTargetService.d.ts +84 -84
  91. package/dist/services/EventTargetService.js +232 -232
  92. package/dist/services/FocusEventService.d.ts +32 -32
  93. package/dist/services/FocusEventService.js +35 -35
  94. package/dist/services/HTMLCollectionService.d.ts +11 -6
  95. package/dist/services/HTMLCollectionService.js +25 -8
  96. package/dist/services/HTMLCollectionService.min.js +1 -1
  97. package/dist/services/HTMLElementService.d.ts +57 -57
  98. package/dist/services/HTMLElementService.js +163 -163
  99. package/dist/services/HTMLSlotElementService.d.ts +4 -4
  100. package/dist/services/HTMLSlotElementService.js +9 -9
  101. package/dist/services/InputEventService.d.ts +41 -41
  102. package/dist/services/InputEventService.js +47 -47
  103. package/dist/services/KeyboardEventService.d.ts +70 -70
  104. package/dist/services/KeyboardEventService.js +86 -86
  105. package/dist/services/MouseEventService.d.ts +80 -80
  106. package/dist/services/MouseEventService.js +108 -108
  107. package/dist/services/NamedNodeMapService.d.ts +23 -23
  108. package/dist/services/NamedNodeMapService.js +77 -77
  109. package/dist/services/NodeService.d.ts +26 -0
  110. package/dist/services/NodeService.js +42 -0
  111. package/dist/services/NodeService.min.js +1 -1
  112. package/dist/services/PointerEventService.d.ts +51 -51
  113. package/dist/services/PointerEventService.js +67 -67
  114. package/dist/services/ShadowRootService.d.ts +4 -4
  115. package/dist/services/ShadowRootService.js +9 -9
  116. package/dist/services/TextService.d.ts +1 -1
  117. package/dist/services/TextService.js +13 -13
  118. package/dist/services/UIEventService.d.ts +43 -43
  119. package/dist/services/UIEventService.js +42 -42
  120. package/dist/simulate.d.ts +32 -32
  121. package/dist/simulate.js +115 -115
  122. package/package.json +3 -2
@@ -1,120 +1,120 @@
1
- /**
2
- * @file Substitute for the DOM Event Class.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.0.0
5
- */
6
- import { PseudoEventTarget } from '../interfaces/PseudoEventTarget';
7
- import { PseudoEvent } from '../interfaces/PseudoEvent';
8
- /**
9
- * The parts of an event which the dispatching of it (EventTargetService) needs to change or read. Not part of the DOM's
10
- * Event, which is why they are kept apart from the event's own properties.
11
- */
12
- export type EventInner = {
13
- currentTarget: PseudoEventTarget | null;
14
- eventPhase: number;
15
- target: PseudoEventTarget;
16
- immediatePropagationStopped: boolean;
17
- propagationStopped: boolean;
18
- /** True for an event which the browser created for a user action, an event which a script created is not trusted. */
19
- trusted: boolean;
20
- /** True while the event is being dispatched. */
21
- dispatching: boolean;
22
- /** True while a passive listener is running, in which preventDefault does nothing. */
23
- inPassiveListener: boolean;
24
- /** The targets the event travels through, the target first and the root last, set while dispatching. */
25
- path: Array<PseudoEventTarget>;
26
- /** Finish the dispatch: no phase, no current target, no path and the stop flags are cleared so the event can be dispatched again. */
27
- finishDispatch: () => void;
28
- };
29
- /**
30
- * Simulate the behaviour of the Event Class when there is no DOM available.
31
- * @author Joshua Heagle <joshuaheagle@gmail.com>
32
- * @class
33
- * @property {number} NONE
34
- * @property {number} CAPTURING_PHASE
35
- * @property {number} AT_TARGET
36
- * @property {number} BUBBLING_PHASE
37
- * @property {boolean} bubbles - A Boolean indicating whether the event bubbles up through the Dom or not.
38
- * @property {boolean} cancelable - A Boolean indicating whether the event is cancelable.
39
- * @property {boolean} composed - A Boolean value indicating whether the event can bubble across the boundary
40
- * between the shadow Dom and the regular Dom.
41
- * @property {function|PseudoEventTarget} currentTarget - A reference to the currently registered target for the event. This
42
- * is the object to which the event is currently slated to be sent; it's possible this has been changed along the way
43
- * through re-targeting.
44
- * @property {boolean} defaultPrevented - Indicates whether event.preventDefault() has been called on the event.
45
- * @property {boolean} immediatePropagationStopped - Flag that no further propagation should occur, including on current
46
- * target.
47
- * @property {boolean} propagationStopped - Flag that no further propagation should occur.
48
- * @property {int} eventPhase - Indicates which phase of the event flow is being processed. Uses EventService constants.
49
- * @property {EventTarget|PseudoEventTarget} target - A reference to the target to which the event was originally
50
- * dispatched.
51
- * @property {int} timeStamp - The time at which the event was created (in milliseconds). By specification, this
52
- * value is time since epoch, but in reality browsers' definitions vary; in addition, work is underway to change this
53
- * to be a DomHighResTimeStamp instead.
54
- * @property {string} type - The name of the event (case-insensitive).
55
- * @property {boolean} isTrusted - Indicates whether the event was initiated by the browser (after a user
56
- * click for instance) or by a script (using an event creation method, like event.initEvent)
57
- */
58
- export declare class EventService implements PseudoEvent {
59
- static readonly NONE = 0;
60
- static readonly CAPTURING_PHASE = 1;
61
- static readonly AT_TARGET = 2;
62
- static readonly BUBBLING_PHASE = 3;
63
- private properties;
64
- /**
65
- *
66
- * @param {string} typeArg
67
- * @param {Object} [eventOptions={}]
68
- * @param {boolean} [eventOptions.bubbles=false]
69
- * @param {boolean} [eventOptions.cancelable=false]
70
- * @param {boolean} [eventOptions.composed=false]
71
- * @constructor
72
- */
73
- constructor(typeArg?: string, { bubbles, cancelable, composed }?: {
74
- bubbles?: boolean;
75
- cancelable?: boolean;
76
- composed?: boolean;
77
- });
78
- get bubbles(): boolean;
79
- get cancelable(): boolean;
80
- get composed(): boolean;
81
- get currentTarget(): PseudoEventTarget;
82
- get defaultPrevented(): boolean;
83
- get eventPhase(): number;
84
- get isTrusted(): boolean;
85
- get target(): PseudoEventTarget;
86
- get timeStamp(): number;
87
- get type(): string;
88
- /**
89
- * Scope several accessors inside the inner object. These are only intended for usage by other DOM classes.
90
- * @returns {EventInner}
91
- */
92
- get inner(): EventInner;
93
- /**
94
- * Return an array of targets that will have the event executed open them. The order is based on the eventPhase
95
- * @method
96
- * @returns {Array.<PseudoEventTarget>}
97
- */
98
- composedPath(): Array<PseudoEventTarget>;
99
- /**
100
- * Cancels the event (if it is cancelable).
101
- * @method
102
- * @returns {null}
103
- */
104
- preventDefault(): null;
105
- /**
106
- * For this particular event, no other listener will be called.
107
- * Neither those attached on the same element, nor those attached on elements which will be traversed later (in
108
- * capture phase, for instance)
109
- * @method
110
- * @returns {null}
111
- */
112
- stopImmediatePropagation(): null;
113
- /**
114
- * Stops the propagation of events further along in the Dom.
115
- * @method
116
- * @returns {null}
117
- */
118
- stopPropagation(): null;
119
- private setReadOnlyProperties;
120
- }
1
+ /**
2
+ * @file Substitute for the DOM Event Class.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.0.0
5
+ */
6
+ import { PseudoEventTarget } from '../interfaces/PseudoEventTarget';
7
+ import { PseudoEvent } from '../interfaces/PseudoEvent';
8
+ /**
9
+ * The parts of an event which the dispatching of it (EventTargetService) needs to change or read. Not part of the DOM's
10
+ * Event, which is why they are kept apart from the event's own properties.
11
+ */
12
+ export type EventInner = {
13
+ currentTarget: PseudoEventTarget | null;
14
+ eventPhase: number;
15
+ target: PseudoEventTarget;
16
+ immediatePropagationStopped: boolean;
17
+ propagationStopped: boolean;
18
+ /** True for an event which the browser created for a user action, an event which a script created is not trusted. */
19
+ trusted: boolean;
20
+ /** True while the event is being dispatched. */
21
+ dispatching: boolean;
22
+ /** True while a passive listener is running, in which preventDefault does nothing. */
23
+ inPassiveListener: boolean;
24
+ /** The targets the event travels through, the target first and the root last, set while dispatching. */
25
+ path: Array<PseudoEventTarget>;
26
+ /** Finish the dispatch: no phase, no current target, no path and the stop flags are cleared so the event can be dispatched again. */
27
+ finishDispatch: () => void;
28
+ };
29
+ /**
30
+ * Simulate the behaviour of the Event Class when there is no DOM available.
31
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
32
+ * @class
33
+ * @property {number} NONE
34
+ * @property {number} CAPTURING_PHASE
35
+ * @property {number} AT_TARGET
36
+ * @property {number} BUBBLING_PHASE
37
+ * @property {boolean} bubbles - A Boolean indicating whether the event bubbles up through the Dom or not.
38
+ * @property {boolean} cancelable - A Boolean indicating whether the event is cancelable.
39
+ * @property {boolean} composed - A Boolean value indicating whether the event can bubble across the boundary
40
+ * between the shadow Dom and the regular Dom.
41
+ * @property {function|PseudoEventTarget} currentTarget - A reference to the currently registered target for the event. This
42
+ * is the object to which the event is currently slated to be sent; it's possible this has been changed along the way
43
+ * through re-targeting.
44
+ * @property {boolean} defaultPrevented - Indicates whether event.preventDefault() has been called on the event.
45
+ * @property {boolean} immediatePropagationStopped - Flag that no further propagation should occur, including on current
46
+ * target.
47
+ * @property {boolean} propagationStopped - Flag that no further propagation should occur.
48
+ * @property {int} eventPhase - Indicates which phase of the event flow is being processed. Uses EventService constants.
49
+ * @property {EventTarget|PseudoEventTarget} target - A reference to the target to which the event was originally
50
+ * dispatched.
51
+ * @property {int} timeStamp - The time at which the event was created (in milliseconds). By specification, this
52
+ * value is time since epoch, but in reality browsers' definitions vary; in addition, work is underway to change this
53
+ * to be a DomHighResTimeStamp instead.
54
+ * @property {string} type - The name of the event (case-insensitive).
55
+ * @property {boolean} isTrusted - Indicates whether the event was initiated by the browser (after a user
56
+ * click for instance) or by a script (using an event creation method, like event.initEvent)
57
+ */
58
+ export declare class EventService implements PseudoEvent {
59
+ static readonly NONE = 0;
60
+ static readonly CAPTURING_PHASE = 1;
61
+ static readonly AT_TARGET = 2;
62
+ static readonly BUBBLING_PHASE = 3;
63
+ private properties;
64
+ /**
65
+ *
66
+ * @param {string} typeArg
67
+ * @param {Object} [eventOptions={}]
68
+ * @param {boolean} [eventOptions.bubbles=false]
69
+ * @param {boolean} [eventOptions.cancelable=false]
70
+ * @param {boolean} [eventOptions.composed=false]
71
+ * @constructor
72
+ */
73
+ constructor(typeArg?: string, { bubbles, cancelable, composed }?: {
74
+ bubbles?: boolean;
75
+ cancelable?: boolean;
76
+ composed?: boolean;
77
+ });
78
+ get bubbles(): boolean;
79
+ get cancelable(): boolean;
80
+ get composed(): boolean;
81
+ get currentTarget(): PseudoEventTarget;
82
+ get defaultPrevented(): boolean;
83
+ get eventPhase(): number;
84
+ get isTrusted(): boolean;
85
+ get target(): PseudoEventTarget;
86
+ get timeStamp(): number;
87
+ get type(): string;
88
+ /**
89
+ * Scope several accessors inside the inner object. These are only intended for usage by other DOM classes.
90
+ * @returns {EventInner}
91
+ */
92
+ get inner(): EventInner;
93
+ /**
94
+ * Return an array of targets that will have the event executed open them. The order is based on the eventPhase
95
+ * @method
96
+ * @returns {Array.<PseudoEventTarget>}
97
+ */
98
+ composedPath(): Array<PseudoEventTarget>;
99
+ /**
100
+ * Cancels the event (if it is cancelable).
101
+ * @method
102
+ * @returns {null}
103
+ */
104
+ preventDefault(): null;
105
+ /**
106
+ * For this particular event, no other listener will be called.
107
+ * Neither those attached on the same element, nor those attached on elements which will be traversed later (in
108
+ * capture phase, for instance)
109
+ * @method
110
+ * @returns {null}
111
+ */
112
+ stopImmediatePropagation(): null;
113
+ /**
114
+ * Stops the propagation of events further along in the Dom.
115
+ * @method
116
+ * @returns {null}
117
+ */
118
+ stopPropagation(): null;
119
+ private setReadOnlyProperties;
120
+ }