pseudo-dom 0.17.0 → 1.0.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.
- package/README.md +63 -5869
- package/browser/pseudo-dom.js +14889 -15288
- package/dist/classes/PseudoEventListener.d.ts +11 -37
- package/dist/classes/PseudoEventListener.js +11 -37
- package/dist/classes/PseudoHTMLDocument.d.ts +4 -12
- package/dist/classes/PseudoHTMLDocument.js +1 -11
- package/dist/classes/PseudoNodeList.d.ts +1 -9
- package/dist/classes/PseudoNodeList.js +1 -9
- package/dist/factories/createDataset.d.ts +1 -3
- package/dist/factories/createDataset.js +3 -8
- package/dist/factories/createEvent.d.ts +5 -9
- package/dist/factories/createEvent.js +3 -5
- package/dist/factories/createStyleDeclaration.d.ts +4 -10
- package/dist/factories/createStyleDeclaration.js +4 -10
- package/dist/factories/cssSelectAdapter.d.ts +0 -2
- package/dist/factories/cssSelectAdapter.js +3 -8
- package/dist/factories/eventDefaults.d.ts +5 -9
- package/dist/factories/eventDefaults.js +1 -4
- package/dist/factories/generateDocument.d.ts +2 -4
- package/dist/factories/generateDocument.js +2 -13
- package/dist/factories/generateNodeList.d.ts +1 -2
- package/dist/factories/generateNodeList.js +1 -2
- package/dist/factories/installGlobal.d.ts +2 -3
- package/dist/factories/installGlobal.js +3 -6
- package/dist/factories/logElement.d.ts +2 -4
- package/dist/factories/logElement.js +3 -7
- package/dist/factories/parseHTML.d.ts +3 -5
- package/dist/factories/parseHTML.js +4 -8
- package/dist/factories/query.d.ts +8 -16
- package/dist/factories/query.js +9 -19
- package/dist/factories/serializeHTML.d.ts +4 -10
- package/dist/factories/serializeHTML.js +12 -25
- package/dist/functions/activeElement.d.ts +3 -6
- package/dist/functions/activeElement.js +3 -6
- package/dist/functions/getElementById.d.ts +2 -4
- package/dist/functions/getElementById.js +2 -4
- package/dist/functions/getParentNodes.d.ts +1 -3
- package/dist/functions/getParentNodes.js +1 -3
- package/dist/functions/getParentNodesFromAttribute.d.ts +3 -5
- package/dist/functions/getParentNodesFromAttribute.js +3 -5
- package/dist/functions/modifierState.d.ts +3 -12
- package/dist/functions/modifierState.js +3 -7
- package/dist/interfaces/PseudoCSSStyleDeclaration.d.ts +1 -1
- package/dist/interfaces/PseudoDocument.d.ts +4 -9
- package/dist/interfaces/PseudoDocumentFragment.d.ts +1 -2
- package/dist/interfaces/PseudoElement.d.ts +39 -78
- package/dist/interfaces/PseudoEvent.d.ts +11 -43
- package/dist/interfaces/PseudoEvent.js +1 -3
- package/dist/interfaces/PseudoEventTarget.d.ts +7 -16
- package/dist/interfaces/PseudoHTMLCollection.d.ts +2 -4
- package/dist/interfaces/PseudoHTMLElement.d.ts +8 -13
- package/dist/interfaces/PseudoNode.d.ts +3 -13
- package/dist/main.d.ts +1 -6
- package/dist/main.js +1 -6
- package/dist/services/AttrService.d.ts +5 -9
- package/dist/services/AttrService.js +5 -9
- package/dist/services/CSSStyleDeclarationService.d.ts +10 -23
- package/dist/services/CSSStyleDeclarationService.js +10 -23
- package/dist/services/CustomEventService.d.ts +4 -15
- package/dist/services/CustomEventService.js +3 -10
- package/dist/services/DOMTokenListService.d.ts +2 -5
- package/dist/services/DOMTokenListService.js +2 -5
- package/dist/services/DocumentFragmentService.d.ts +1 -5
- package/dist/services/DocumentFragmentService.js +1 -5
- package/dist/services/DocumentService.d.ts +4 -12
- package/dist/services/DocumentService.js +4 -12
- package/dist/services/ElementService.d.ts +62 -120
- package/dist/services/ElementService.js +61 -117
- package/dist/services/EventService.d.ts +6 -44
- package/dist/services/EventService.js +18 -44
- package/dist/services/EventTargetService.d.ts +16 -28
- package/dist/services/EventTargetService.js +16 -28
- package/dist/services/FocusEventService.d.ts +4 -12
- package/dist/services/FocusEventService.js +3 -10
- package/dist/services/HTMLCollectionService.d.ts +6 -16
- package/dist/services/HTMLCollectionService.js +6 -16
- package/dist/services/HTMLElementService.d.ts +132 -154
- package/dist/services/HTMLElementService.js +333 -353
- package/dist/services/InputEventService.d.ts +5 -16
- package/dist/services/InputEventService.js +3 -12
- package/dist/services/KeyboardEventService.d.ts +8 -26
- package/dist/services/KeyboardEventService.js +4 -16
- package/dist/services/MouseEventService.d.ts +7 -30
- package/dist/services/MouseEventService.js +4 -18
- package/dist/services/NamedNodeMapService.d.ts +1 -4
- package/dist/services/NamedNodeMapService.js +1 -4
- package/dist/services/NodeService.d.ts +38 -69
- package/dist/services/NodeService.js +39 -72
- package/dist/services/PointerEventService.d.ts +4 -22
- package/dist/services/PointerEventService.js +3 -15
- package/dist/services/ShadowRootService.d.ts +0 -3
- package/dist/services/ShadowRootService.js +0 -3
- package/dist/services/UIEventService.d.ts +5 -17
- package/dist/services/UIEventService.js +3 -11
- package/dist/simulate.d.ts +7 -9
- package/dist/simulate.js +9 -15
- package/package.json +8 -7
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
6
|
-
* @version 1.0.0
|
|
4
|
+
* Substitute for the DOM Event Class.
|
|
7
5
|
*/
|
|
8
6
|
Object.defineProperty(exports, '__esModule', {
|
|
9
7
|
value: true
|
|
@@ -11,42 +9,15 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
11
9
|
exports.EventService = void 0
|
|
12
10
|
/**
|
|
13
11
|
* Simulate the behaviour of the Event Class when there is no DOM available.
|
|
14
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
15
|
-
* @class
|
|
16
|
-
* @property {number} NONE
|
|
17
|
-
* @property {number} CAPTURING_PHASE
|
|
18
|
-
* @property {number} AT_TARGET
|
|
19
|
-
* @property {number} BUBBLING_PHASE
|
|
20
|
-
* @property {boolean} bubbles - A Boolean indicating whether the event bubbles up through the Dom or not.
|
|
21
|
-
* @property {boolean} cancelable - A Boolean indicating whether the event is cancelable.
|
|
22
|
-
* @property {boolean} composed - A Boolean value indicating whether the event can bubble across the boundary
|
|
23
|
-
* between the shadow Dom and the regular Dom.
|
|
24
|
-
* @property {function|PseudoEventTarget} currentTarget - A reference to the currently registered target for the event. This
|
|
25
|
-
* is the object to which the event is currently slated to be sent; it's possible this has been changed along the way
|
|
26
|
-
* through re-targeting.
|
|
27
|
-
* @property {boolean} defaultPrevented - Indicates whether event.preventDefault() has been called on the event.
|
|
28
|
-
* @property {boolean} immediatePropagationStopped - Flag that no further propagation should occur, including on current
|
|
29
|
-
* target.
|
|
30
|
-
* @property {boolean} propagationStopped - Flag that no further propagation should occur.
|
|
31
|
-
* @property {int} eventPhase - Indicates which phase of the event flow is being processed. Uses EventService constants.
|
|
32
|
-
* @property {EventTarget|PseudoEventTarget} target - A reference to the target to which the event was originally
|
|
33
|
-
* dispatched.
|
|
34
|
-
* @property {int} timeStamp - The time at which the event was created (in milliseconds). By specification, this
|
|
35
|
-
* value is time since epoch, but in reality browsers' definitions vary; in addition, work is underway to change this
|
|
36
|
-
* to be a DomHighResTimeStamp instead.
|
|
37
|
-
* @property {string} type - The name of the event (case-insensitive).
|
|
38
|
-
* @property {boolean} isTrusted - Indicates whether the event was initiated by the browser (after a user
|
|
39
|
-
* click for instance) or by a script (using an event creation method, like event.initEvent)
|
|
40
12
|
*/
|
|
41
13
|
class EventService {
|
|
42
14
|
/**
|
|
43
15
|
*
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
49
|
-
* @constructor
|
|
16
|
+
* @param typeArg
|
|
17
|
+
* @param eventOptions
|
|
18
|
+
* @param eventOptions.bubbles
|
|
19
|
+
* @param eventOptions.cancelable
|
|
20
|
+
* @param eventOptions.composed
|
|
50
21
|
*/
|
|
51
22
|
constructor (typeArg = '', {
|
|
52
23
|
bubbles = false,
|
|
@@ -54,17 +25,29 @@ class EventService {
|
|
|
54
25
|
composed = false
|
|
55
26
|
} = {}) {
|
|
56
27
|
this.properties = {
|
|
28
|
+
/** A Boolean indicating whether the event bubbles up through the Dom or not. */
|
|
57
29
|
bubbles: false,
|
|
30
|
+
/** A Boolean indicating whether the event is cancelable. */
|
|
58
31
|
cancelable: false,
|
|
32
|
+
/** A Boolean value indicating whether the event can bubble across the boundary between the shadow Dom and the regular Dom. */
|
|
59
33
|
composed: false,
|
|
34
|
+
/** A reference to the currently registered target for the event. This is the object to which the event is currently slated to be sent; it's possible this has been changed along the way through re-targeting. */
|
|
60
35
|
currentTarget: null,
|
|
36
|
+
/** Indicates whether event.preventDefault() has been called on the event. */
|
|
61
37
|
defaultPrevented: false,
|
|
38
|
+
/** Flag that no further propagation should occur, including on current target. */
|
|
62
39
|
immediatePropagationStopped: false,
|
|
40
|
+
/** Flag that no further propagation should occur. */
|
|
63
41
|
propagationStopped: false,
|
|
42
|
+
/** Indicates which phase of the event flow is being processed. Uses EventService constants. */
|
|
64
43
|
eventPhase: 0,
|
|
44
|
+
/** A reference to the target to which the event was originally dispatched. */
|
|
65
45
|
target: null,
|
|
46
|
+
/** The time at which the event was created (in milliseconds). By specification, this value is time since epoch, but in reality browsers' definitions vary; in addition, work is underway to change this to be a DomHighResTimeStamp instead. */
|
|
66
47
|
timeStamp: Math.floor(Date.now() / 1000),
|
|
48
|
+
/** The name of the event (case-insensitive). */
|
|
67
49
|
type: '',
|
|
50
|
+
/** Indicates whether the event was initiated by the browser (after a user click for instance) or by a script (using an event creation method, like event.initEvent) */
|
|
68
51
|
isTrusted: false,
|
|
69
52
|
dispatching: false,
|
|
70
53
|
inPassiveListener: false,
|
|
@@ -120,7 +103,6 @@ class EventService {
|
|
|
120
103
|
|
|
121
104
|
/**
|
|
122
105
|
* Scope several accessors inside the inner object. These are only intended for usage by other DOM classes.
|
|
123
|
-
* @returns {EventInner}
|
|
124
106
|
*/
|
|
125
107
|
get inner () {
|
|
126
108
|
const self = this
|
|
@@ -189,8 +171,6 @@ class EventService {
|
|
|
189
171
|
|
|
190
172
|
/**
|
|
191
173
|
* Return an array of targets that will have the event executed open them. The order is based on the eventPhase
|
|
192
|
-
* @method
|
|
193
|
-
* @returns {Array.<PseudoEventTarget>}
|
|
194
174
|
*/
|
|
195
175
|
composedPath () {
|
|
196
176
|
// While the event is being dispatched this is every target it travels through, the target first and the root last
|
|
@@ -199,8 +179,6 @@ class EventService {
|
|
|
199
179
|
|
|
200
180
|
/**
|
|
201
181
|
* Cancels the event (if it is cancelable).
|
|
202
|
-
* @method
|
|
203
|
-
* @returns {null}
|
|
204
182
|
*/
|
|
205
183
|
preventDefault () {
|
|
206
184
|
// Only an event which can be cancelled can be prevented, and a passive listener cannot prevent the default
|
|
@@ -216,8 +194,6 @@ class EventService {
|
|
|
216
194
|
* For this particular event, no other listener will be called.
|
|
217
195
|
* Neither those attached on the same element, nor those attached on elements which will be traversed later (in
|
|
218
196
|
* capture phase, for instance)
|
|
219
|
-
* @method
|
|
220
|
-
* @returns {null}
|
|
221
197
|
*/
|
|
222
198
|
stopImmediatePropagation () {
|
|
223
199
|
this.setReadOnlyProperties({
|
|
@@ -228,8 +204,6 @@ class EventService {
|
|
|
228
204
|
|
|
229
205
|
/**
|
|
230
206
|
* Stops the propagation of events further along in the Dom.
|
|
231
|
-
* @method
|
|
232
|
-
* @returns {null}
|
|
233
207
|
*/
|
|
234
208
|
stopPropagation () {
|
|
235
209
|
this.setReadOnlyProperties({
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
2
|
+
* Substitute for the DOM EventTarget Class.
|
|
5
3
|
*/
|
|
6
4
|
import { EventService } from './EventService';
|
|
7
5
|
import { listenerOptions, PseudoEventTarget } from '../interfaces/PseudoEventTarget';
|
|
@@ -10,24 +8,14 @@ import { listenerOptions, PseudoEventTarget } from '../interfaces/PseudoEventTar
|
|
|
10
8
|
* Dispatching an event sends it through the tree the way the DOM does: down from the root to the target (capture
|
|
11
9
|
* listeners), to the target itself, then back up to the root (the listeners which are not capture listeners, when the
|
|
12
10
|
* event bubbles).
|
|
13
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
14
|
-
* @class
|
|
15
|
-
* @property {Object.<string, Array.<PseudoEventListener>>} listeners
|
|
16
|
-
* @property {function} addEventListener
|
|
17
|
-
* @property {function} removeEventListener
|
|
18
|
-
* @property {function} dispatchEvent
|
|
19
11
|
*/
|
|
20
12
|
declare class EventTargetService implements PseudoEventTarget {
|
|
21
13
|
private readonly listeners;
|
|
22
14
|
private readonly defaultEvent;
|
|
23
|
-
/**
|
|
24
|
-
* @constructor
|
|
25
|
-
*/
|
|
26
15
|
constructor();
|
|
27
16
|
/**
|
|
28
17
|
* The listeners registered for a type of event, creating the (empty) list of them when there are none yet.
|
|
29
|
-
* @param
|
|
30
|
-
* @returns {LinkedList}
|
|
18
|
+
* @param type
|
|
31
19
|
*/
|
|
32
20
|
private listenersFor;
|
|
33
21
|
/**
|
|
@@ -35,37 +23,37 @@ declare class EventTargetService implements PseudoEventTarget {
|
|
|
35
23
|
* (at the target, the capture listeners run before the others). Listeners which are added while this runs do not run
|
|
36
24
|
* for this event, and listeners which are removed while it runs no longer do. Running stops as soon as immediate
|
|
37
25
|
* propagation is stopped. A listener which throws does not stop the others.
|
|
38
|
-
* @param
|
|
39
|
-
* @returns
|
|
26
|
+
* @param event The event, which is at a phase and has a current target
|
|
27
|
+
* @returns The errors which the listeners threw
|
|
40
28
|
*/
|
|
41
29
|
private runEvents;
|
|
42
30
|
/**
|
|
43
31
|
* Take a listener out of the registered listeners, so that it does not run again.
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
32
|
+
* @param type
|
|
33
|
+
* @param listener
|
|
46
34
|
*/
|
|
47
35
|
private removeListener;
|
|
48
36
|
/**
|
|
49
37
|
* Register the function to run when nothing else has prevented the default for this type of event.
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
38
|
+
* @param type
|
|
39
|
+
* @param callback
|
|
52
40
|
*/
|
|
53
41
|
protected setDefaultEvent(type: string, callback: Function): void;
|
|
54
42
|
/**
|
|
55
43
|
* Registers an event handler of a specific event type. Adding the same handler again for the same type and phase does
|
|
56
44
|
* nothing, like the DOM.
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
45
|
+
* @param type The type of event to listen for
|
|
46
|
+
* @param callback The function to call (or an object with a handleEvent function)
|
|
47
|
+
* @param useCapture Listen while the event travels down to the target (true), or an object with capture, once and passive
|
|
60
48
|
*/
|
|
61
49
|
addEventListener(type: string, callback: Function | {
|
|
62
50
|
handleEvent: Function;
|
|
63
51
|
} | any, useCapture?: listenerOptions | boolean): void;
|
|
64
52
|
/**
|
|
65
53
|
* Removes an event listener, the one which was added with the same type, handler and phase.
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
68
|
-
* @param
|
|
54
|
+
* @param type The type of event
|
|
55
|
+
* @param callback The handler which was added
|
|
56
|
+
* @param options Whether the listener was a capture listener (true), or an object with capture
|
|
69
57
|
*/
|
|
70
58
|
removeEventListener(type: string, callback: Function, options?: listenerOptions | boolean): void;
|
|
71
59
|
/**
|
|
@@ -74,8 +62,8 @@ declare class EventTargetService implements PseudoEventTarget {
|
|
|
74
62
|
* parent up to the root. stopPropagation() stops it reaching further targets, stopImmediatePropagation() also stops
|
|
75
63
|
* the remaining listeners of the current target. Afterwards, unless the default was prevented, the default action
|
|
76
64
|
* of this target (see setDefaultEvent) runs. The event can be dispatched again afterwards.
|
|
77
|
-
* @param
|
|
78
|
-
* @returns
|
|
65
|
+
* @param event The event to dispatch
|
|
66
|
+
* @returns False when the event was cancelable and a listener prevented the default, otherwise true
|
|
79
67
|
* @throws {Error} When the event is already being dispatched, or (after the whole dispatch has finished) the error
|
|
80
68
|
* which a listener threw (an error with all of them in its errors property when several did)
|
|
81
69
|
*/
|
|
@@ -17,9 +17,7 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
17
17
|
value: true
|
|
18
18
|
})
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
22
|
-
* @version 1.0.0
|
|
20
|
+
* Substitute for the DOM EventTarget Class.
|
|
23
21
|
*/
|
|
24
22
|
const EventService_1 = require('./EventService')
|
|
25
23
|
const PseudoEventListener_1 = __importDefault(require('../classes/PseudoEventListener'))
|
|
@@ -30,17 +28,8 @@ const LinkedList_1 = require('collect-your-stuff/dist/collections/linked-list/Li
|
|
|
30
28
|
* Dispatching an event sends it through the tree the way the DOM does: down from the root to the target (capture
|
|
31
29
|
* listeners), to the target itself, then back up to the root (the listeners which are not capture listeners, when the
|
|
32
30
|
* event bubbles).
|
|
33
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
34
|
-
* @class
|
|
35
|
-
* @property {Object.<string, Array.<PseudoEventListener>>} listeners
|
|
36
|
-
* @property {function} addEventListener
|
|
37
|
-
* @property {function} removeEventListener
|
|
38
|
-
* @property {function} dispatchEvent
|
|
39
31
|
*/
|
|
40
32
|
class EventTargetService {
|
|
41
|
-
/**
|
|
42
|
-
* @constructor
|
|
43
|
-
*/
|
|
44
33
|
constructor () {
|
|
45
34
|
this.listeners = {}
|
|
46
35
|
this.defaultEvent = {}
|
|
@@ -48,8 +37,7 @@ class EventTargetService {
|
|
|
48
37
|
|
|
49
38
|
/**
|
|
50
39
|
* The listeners registered for a type of event, creating the (empty) list of them when there are none yet.
|
|
51
|
-
* @param
|
|
52
|
-
* @returns {LinkedList}
|
|
40
|
+
* @param type
|
|
53
41
|
*/
|
|
54
42
|
listenersFor (type) {
|
|
55
43
|
if (!(type in this.listeners)) {
|
|
@@ -63,8 +51,8 @@ class EventTargetService {
|
|
|
63
51
|
* (at the target, the capture listeners run before the others). Listeners which are added while this runs do not run
|
|
64
52
|
* for this event, and listeners which are removed while it runs no longer do. Running stops as soon as immediate
|
|
65
53
|
* propagation is stopped. A listener which throws does not stop the others.
|
|
66
|
-
* @param
|
|
67
|
-
* @returns
|
|
54
|
+
* @param event The event, which is at a phase and has a current target
|
|
55
|
+
* @returns The errors which the listeners threw
|
|
68
56
|
*/
|
|
69
57
|
runEvents (event) {
|
|
70
58
|
const errors = []
|
|
@@ -97,8 +85,8 @@ class EventTargetService {
|
|
|
97
85
|
|
|
98
86
|
/**
|
|
99
87
|
* Take a listener out of the registered listeners, so that it does not run again.
|
|
100
|
-
* @param
|
|
101
|
-
* @param
|
|
88
|
+
* @param type
|
|
89
|
+
* @param listener
|
|
102
90
|
*/
|
|
103
91
|
removeListener (type, listener) {
|
|
104
92
|
listener.removed = true
|
|
@@ -108,8 +96,8 @@ class EventTargetService {
|
|
|
108
96
|
|
|
109
97
|
/**
|
|
110
98
|
* Register the function to run when nothing else has prevented the default for this type of event.
|
|
111
|
-
* @param
|
|
112
|
-
* @param
|
|
99
|
+
* @param type
|
|
100
|
+
* @param callback
|
|
113
101
|
*/
|
|
114
102
|
setDefaultEvent (type, callback) {
|
|
115
103
|
this.listenersFor(type)
|
|
@@ -119,9 +107,9 @@ class EventTargetService {
|
|
|
119
107
|
/**
|
|
120
108
|
* Registers an event handler of a specific event type. Adding the same handler again for the same type and phase does
|
|
121
109
|
* nothing, like the DOM.
|
|
122
|
-
* @param
|
|
123
|
-
* @param
|
|
124
|
-
* @param
|
|
110
|
+
* @param type The type of event to listen for
|
|
111
|
+
* @param callback The function to call (or an object with a handleEvent function)
|
|
112
|
+
* @param useCapture Listen while the event travels down to the target (true), or an object with capture, once and passive
|
|
125
113
|
*/
|
|
126
114
|
addEventListener (type, callback, useCapture = false) {
|
|
127
115
|
let options = {
|
|
@@ -155,9 +143,9 @@ class EventTargetService {
|
|
|
155
143
|
|
|
156
144
|
/**
|
|
157
145
|
* Removes an event listener, the one which was added with the same type, handler and phase.
|
|
158
|
-
* @param
|
|
159
|
-
* @param
|
|
160
|
-
* @param
|
|
146
|
+
* @param type The type of event
|
|
147
|
+
* @param callback The handler which was added
|
|
148
|
+
* @param options Whether the listener was a capture listener (true), or an object with capture
|
|
161
149
|
*/
|
|
162
150
|
removeEventListener (type, callback, options = false) {
|
|
163
151
|
if (!(type in this.listeners)) {
|
|
@@ -173,8 +161,8 @@ class EventTargetService {
|
|
|
173
161
|
* parent up to the root. stopPropagation() stops it reaching further targets, stopImmediatePropagation() also stops
|
|
174
162
|
* the remaining listeners of the current target. Afterwards, unless the default was prevented, the default action
|
|
175
163
|
* of this target (see setDefaultEvent) runs. The event can be dispatched again afterwards.
|
|
176
|
-
* @param
|
|
177
|
-
* @returns
|
|
164
|
+
* @param event The event to dispatch
|
|
165
|
+
* @returns False when the event was cancelable and a listener prevented the default, otherwise true
|
|
178
166
|
* @throws {Error} When the event is already being dispatched, or (after the whole dispatch has finished) the error
|
|
179
167
|
* which a listener threw (an error with all of them in its errors property when several did)
|
|
180
168
|
*/
|
|
@@ -1,31 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
2
|
+
* Substitute for the DOM FocusEvent Class.
|
|
5
3
|
*/
|
|
6
4
|
import { UIEventInit, UIEventService } from './UIEventService';
|
|
7
5
|
import { PseudoEventTarget } from '../interfaces/PseudoEventTarget';
|
|
8
6
|
/**
|
|
9
7
|
* The options for creating a focus event, on top of the ones every UI event has.
|
|
10
|
-
* @typedef {Object} FocusEventInit
|
|
11
|
-
* @property {PseudoEventTarget|null} [relatedTarget=null] The other target involved (the one losing or gaining the focus)
|
|
12
8
|
*/
|
|
13
9
|
export type FocusEventInit = UIEventInit & {
|
|
10
|
+
/** The other target involved (the one losing or gaining the focus) (default null) */
|
|
14
11
|
relatedTarget?: PseudoEventTarget | null;
|
|
15
12
|
};
|
|
16
13
|
/**
|
|
17
14
|
* Simulate the behaviour of the FocusEvent Class when there is no DOM available.
|
|
18
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
19
|
-
* @class
|
|
20
|
-
* @augments UIEventService
|
|
21
|
-
* @property {PseudoEventTarget|null} relatedTarget
|
|
22
15
|
*/
|
|
23
16
|
export declare class FocusEventService extends UIEventService {
|
|
24
17
|
private readonly related;
|
|
25
18
|
/**
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @constructor
|
|
19
|
+
* @param typeArg The type of the event
|
|
20
|
+
* @param init The options for the event
|
|
29
21
|
*/
|
|
30
22
|
constructor(typeArg?: string, init?: FocusEventInit);
|
|
31
23
|
get relatedTarget(): PseudoEventTarget | null;
|
|
@@ -5,23 +5,16 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
5
5
|
})
|
|
6
6
|
exports.FocusEventService = void 0
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
10
|
-
* @version 1.0.0
|
|
8
|
+
* Substitute for the DOM FocusEvent Class.
|
|
11
9
|
*/
|
|
12
10
|
const UIEventService_1 = require('./UIEventService')
|
|
13
11
|
/**
|
|
14
12
|
* Simulate the behaviour of the FocusEvent Class when there is no DOM available.
|
|
15
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
16
|
-
* @class
|
|
17
|
-
* @augments UIEventService
|
|
18
|
-
* @property {PseudoEventTarget|null} relatedTarget
|
|
19
13
|
*/
|
|
20
14
|
class FocusEventService extends UIEventService_1.UIEventService {
|
|
21
15
|
/**
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @constructor
|
|
16
|
+
* @param typeArg The type of the event
|
|
17
|
+
* @param init The options for the event
|
|
25
18
|
*/
|
|
26
19
|
constructor (typeArg = '', init = {}) {
|
|
27
20
|
super(typeArg, init)
|
|
@@ -1,53 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
2
|
+
* Substitute for the DOM HTMLCollection Class.
|
|
5
3
|
*/
|
|
6
4
|
import { NodeService } from './NodeService';
|
|
7
5
|
import { PseudoHTMLCollection } from '../interfaces/PseudoHTMLCollection';
|
|
8
6
|
/**
|
|
9
7
|
* Simulate the behaviour of the HTMLCollection Class when there is no DOM available: a live view of some of a node's
|
|
10
8
|
* element descendants, recomputed each time it is used rather than kept in sync as they change.
|
|
11
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
12
|
-
* @class
|
|
13
9
|
*/
|
|
14
10
|
export declare class HTMLCollectionService implements PseudoHTMLCollection {
|
|
15
11
|
private readonly owner;
|
|
16
12
|
private readonly predicate;
|
|
17
13
|
private readonly deep;
|
|
18
14
|
/**
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
15
|
+
* @param owner The node this is a live view of a part of
|
|
16
|
+
* @param predicate Only elements which pass this are included (every element by default)
|
|
17
|
+
* @param deep Include every matching descendant (true, like getElementsByTagName), not just the
|
|
22
18
|
* direct element children (false, like Element.children)
|
|
23
|
-
* @constructor
|
|
24
19
|
*/
|
|
25
20
|
constructor(owner: NodeService, predicate?: (element: any) => boolean, deep?: boolean);
|
|
26
21
|
/**
|
|
27
22
|
* The current elements the collection holds, in tree order.
|
|
28
|
-
* @returns {Array<PseudoNode>}
|
|
29
23
|
*/
|
|
30
24
|
private elements;
|
|
31
25
|
/**
|
|
32
26
|
* How many elements are in the collection right now.
|
|
33
|
-
* @returns {number}
|
|
34
27
|
*/
|
|
35
28
|
get length(): number;
|
|
36
29
|
/**
|
|
37
30
|
* The element at the given index, or null when there is none.
|
|
38
|
-
* @param
|
|
39
|
-
* @returns {*}
|
|
31
|
+
* @param index
|
|
40
32
|
*/
|
|
41
33
|
item(index: number): any | null;
|
|
42
34
|
/**
|
|
43
35
|
* The element whose id, or (failing that) whose name attribute, is the given value, or null when there is none.
|
|
44
|
-
* @param
|
|
45
|
-
* @returns {*}
|
|
36
|
+
* @param name
|
|
46
37
|
*/
|
|
47
38
|
namedItem(name: string): any | null;
|
|
48
39
|
/**
|
|
49
40
|
* Iterate over the current elements.
|
|
50
|
-
* @returns {Iterator}
|
|
51
41
|
*/
|
|
52
42
|
[Symbol.iterator](): Iterator<any>;
|
|
53
43
|
}
|
|
@@ -8,24 +8,19 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
8
8
|
})
|
|
9
9
|
exports.HTMLCollectionService = void 0
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
13
|
-
* @version 1.0.0
|
|
11
|
+
* Substitute for the DOM HTMLCollection Class.
|
|
14
12
|
*/
|
|
15
13
|
const NodeService_1 = require('./NodeService')
|
|
16
14
|
/**
|
|
17
15
|
* Simulate the behaviour of the HTMLCollection Class when there is no DOM available: a live view of some of a node's
|
|
18
16
|
* element descendants, recomputed each time it is used rather than kept in sync as they change.
|
|
19
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
20
|
-
* @class
|
|
21
17
|
*/
|
|
22
18
|
class HTMLCollectionService {
|
|
23
19
|
/**
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
20
|
+
* @param owner The node this is a live view of a part of
|
|
21
|
+
* @param predicate Only elements which pass this are included (every element by default)
|
|
22
|
+
* @param deep Include every matching descendant (true, like getElementsByTagName), not just the
|
|
27
23
|
* direct element children (false, like Element.children)
|
|
28
|
-
* @constructor
|
|
29
24
|
*/
|
|
30
25
|
constructor (owner, predicate = () => true, deep = false) {
|
|
31
26
|
this.owner = owner
|
|
@@ -35,7 +30,6 @@ class HTMLCollectionService {
|
|
|
35
30
|
|
|
36
31
|
/**
|
|
37
32
|
* The current elements the collection holds, in tree order.
|
|
38
|
-
* @returns {Array<PseudoNode>}
|
|
39
33
|
*/
|
|
40
34
|
elements () {
|
|
41
35
|
const results = []
|
|
@@ -55,7 +49,6 @@ class HTMLCollectionService {
|
|
|
55
49
|
|
|
56
50
|
/**
|
|
57
51
|
* How many elements are in the collection right now.
|
|
58
|
-
* @returns {number}
|
|
59
52
|
*/
|
|
60
53
|
get length () {
|
|
61
54
|
return this.elements().length
|
|
@@ -63,8 +56,7 @@ class HTMLCollectionService {
|
|
|
63
56
|
|
|
64
57
|
/**
|
|
65
58
|
* The element at the given index, or null when there is none.
|
|
66
|
-
* @param
|
|
67
|
-
* @returns {*}
|
|
59
|
+
* @param index
|
|
68
60
|
*/
|
|
69
61
|
item (index) {
|
|
70
62
|
return this.elements()[index] || null
|
|
@@ -72,8 +64,7 @@ class HTMLCollectionService {
|
|
|
72
64
|
|
|
73
65
|
/**
|
|
74
66
|
* The element whose id, or (failing that) whose name attribute, is the given value, or null when there is none.
|
|
75
|
-
* @param
|
|
76
|
-
* @returns {*}
|
|
67
|
+
* @param name
|
|
77
68
|
*/
|
|
78
69
|
namedItem (name) {
|
|
79
70
|
const elements = this.elements()
|
|
@@ -82,7 +73,6 @@ class HTMLCollectionService {
|
|
|
82
73
|
|
|
83
74
|
/**
|
|
84
75
|
* Iterate over the current elements.
|
|
85
|
-
* @returns {Iterator}
|
|
86
76
|
*/
|
|
87
77
|
[Symbol.iterator] () {
|
|
88
78
|
return this.elements()[Symbol.iterator]()
|