pseudo-dom 0.2.0 → 0.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.
Files changed (62) hide show
  1. package/README.md +903 -43
  2. package/browser/pseudo-dom.js +1489 -376
  3. package/browser/pseudo-dom.min.js +1 -1
  4. package/dist/classes/PseudoEventListener.d.ts +25 -25
  5. package/dist/classes/PseudoEventListener.js +37 -34
  6. package/dist/classes/PseudoEventListener.min.js +1 -1
  7. package/dist/factories/createEvent.d.ts +28 -0
  8. package/dist/factories/createEvent.js +56 -0
  9. package/dist/factories/createEvent.min.js +1 -0
  10. package/dist/factories/eventDefaults.d.ts +31 -0
  11. package/dist/factories/eventDefaults.js +105 -0
  12. package/dist/factories/eventDefaults.min.js +1 -0
  13. package/dist/factories.d.ts +6 -0
  14. package/dist/factories.js +5 -1
  15. package/dist/factories.min.js +1 -1
  16. package/dist/functions/activeElement.d.ts +14 -0
  17. package/dist/functions/activeElement.js +33 -0
  18. package/dist/functions/activeElement.min.js +1 -0
  19. package/dist/functions/modifierState.d.ts +29 -0
  20. package/dist/functions/modifierState.js +41 -0
  21. package/dist/functions/modifierState.min.js +1 -0
  22. package/dist/interfaces/PseudoEventTarget.d.ts +2 -2
  23. package/dist/main.d.ts +32 -1
  24. package/dist/main.js +66 -1
  25. package/dist/main.min.js +1 -1
  26. package/dist/services/CustomEventService.d.ts +37 -0
  27. package/dist/services/CustomEventService.js +35 -0
  28. package/dist/services/CustomEventService.min.js +1 -0
  29. package/dist/services/ElementService.d.ts +1 -0
  30. package/dist/services/ElementService.js +17 -10
  31. package/dist/services/ElementService.min.js +1 -1
  32. package/dist/services/EventService.d.ts +18 -4
  33. package/dist/services/EventService.js +65 -31
  34. package/dist/services/EventService.min.js +1 -1
  35. package/dist/services/EventTargetService.d.ts +41 -9
  36. package/dist/services/EventTargetService.js +121 -52
  37. package/dist/services/EventTargetService.min.js +1 -1
  38. package/dist/services/FocusEventService.d.ts +32 -0
  39. package/dist/services/FocusEventService.js +35 -0
  40. package/dist/services/FocusEventService.min.js +1 -0
  41. package/dist/services/HTMLElementService.d.ts +20 -0
  42. package/dist/services/HTMLElementService.js +95 -0
  43. package/dist/services/HTMLElementService.min.js +1 -1
  44. package/dist/services/InputEventService.d.ts +41 -0
  45. package/dist/services/InputEventService.js +47 -0
  46. package/dist/services/InputEventService.min.js +1 -0
  47. package/dist/services/KeyboardEventService.d.ts +70 -0
  48. package/dist/services/KeyboardEventService.js +86 -0
  49. package/dist/services/KeyboardEventService.min.js +1 -0
  50. package/dist/services/MouseEventService.d.ts +80 -0
  51. package/dist/services/MouseEventService.js +108 -0
  52. package/dist/services/MouseEventService.min.js +1 -0
  53. package/dist/services/PointerEventService.d.ts +51 -0
  54. package/dist/services/PointerEventService.js +67 -0
  55. package/dist/services/PointerEventService.min.js +1 -0
  56. package/dist/services/UIEventService.d.ts +43 -0
  57. package/dist/services/UIEventService.js +42 -0
  58. package/dist/services/UIEventService.min.js +1 -0
  59. package/dist/simulate.d.ts +32 -0
  60. package/dist/simulate.js +115 -0
  61. package/dist/simulate.min.js +1 -0
  62. package/package.json +1 -1
package/README.md CHANGED
@@ -7,7 +7,10 @@ Mock the DOM for server side-side DOM state and in tests.
7
7
  Pseudo DOM recreates the browser DOM API (following the MDN documentation) so DOM-dependent code can run in Node, for
8
8
  example in tests, without a real or headless browser. It is written in TypeScript and ships type definitions.
9
9
 
10
- Working today: `EventService` (Event), `EventTargetService` (EventTarget listeners for the target itself), `NodeService`
10
+ Working today: `EventService` (Event) and `EventTargetService` (EventTarget), which dispatch an event through the tree the
11
+ way the DOM does (capture down from the root, the target, then bubbling back up, with `stopPropagation`,
12
+ `stopImmediatePropagation`, `once`, `passive`, `preventDefault` and the default action of the target; clicking a submit
13
+ button sends a `submit` event to its form), `NodeService`
11
14
  (Node: a real tree with `parentNode`, `previousSibling` / `nextSibling`, `firstChild` / `lastChild`, `appendChild`,
12
15
  `insertBefore`, `removeChild`, `replaceChild`, `contains` and `getRootNode`; nodes move when they are added somewhere
13
16
  else, document fragments insert their children, and a node cannot be put inside itself), `ElementService` /
@@ -15,13 +18,26 @@ else, document fragments insert their children, and a node cannot be put inside
15
18
  `DOMTokenListService`, `NamedNodeMapService`, `DocumentService` / `DocumentFragmentService`, `PseudoNodeList`, and
16
19
  `generateDocument` for creating a document.
17
20
 
18
- Not implemented yet (these throw a "not implemented" error or are missing): event dispatch through the tree (capture,
19
- target and bubble phases), `cloneNode`, `compareDocumentPosition`, `isEqualNode`, `querySelector` /
21
+ Standard events: `createEvent(type, init, { browser, trusted })` makes the kind of event which suits the type (a click is a
22
+ `MouseEvent`, a keydown a `KeyboardEvent`, ...). Like the constructor in a browser it gives nothing (no bubbling, no
23
+ cancelling, not trusted) unless asked, but with `browser: true` it uses `eventDefaults`, the table of how the browser
24
+ creates each standard type (click bubbles and can be cancelled, focus does not bubble but focusin does, input bubbles
25
+ but cannot be cancelled, ...), and `trusted: true` makes `isTrusted` true, as for a real user action. The kinds of event
26
+ are `PseudoUIEvent`, `PseudoMouseEvent`, `PseudoPointerEvent`, `PseudoKeyboardEvent`, `PseudoFocusEvent`,
27
+ `PseudoInputEvent` and `PseudoCustomEvent`. Elements have `click()` (an untrusted click, like a script's),
28
+ `focus()` and `blur()` (with blur / focusout / focus / focusin and the related targets, and a focused element for each
29
+ tree), and `simulate.click(element)` / `simulate.keyPress(element, key)` send what a user's action sends (pointerdown,
30
+ mousedown, the focus moving, pointerup, mouseup, click; keydown, keyup), all trusted.
31
+
32
+ Not implemented yet (these throw a "not implemented" error or are missing): `cloneNode`, `compareDocumentPosition`, `isEqualNode`, `querySelector` /
20
33
  `querySelectorAll`, `innerHTML` / `outerHTML` parsing, and most of the rest of the Element and Document APIs. The API
21
34
  will change before 1.0.
22
35
  ## Modules
23
36
 
24
37
  <dl>
38
+ <dt><a href="#module_pseudoDom/simulate">pseudoDom/simulate</a></dt>
39
+ <dd><p>Simulate what a user does, with the events the browser sends for it.</p>
40
+ </dd>
25
41
  <dt><a href="#module_pseudoDom/objects">pseudoDom/objects</a> : <code>Object</code></dt>
26
42
  <dd><p>All methods exported from this module are encapsulated within pseudoDom.</p>
27
43
  </dd>
@@ -30,17 +46,39 @@ will change before 1.0.
30
46
  ## Classes
31
47
 
32
48
  <dl>
49
+ <dt><a href="#UIEventService">UIEventService</a> ⇐ <code><a href="#EventService">EventService</a></code></dt>
50
+ <dd><p>Simulate the behaviour of the UIEvent Class when there is no DOM available: the events which come from a user
51
+ interface (the mouse, the keyboard, focus and input).</p>
52
+ </dd>
53
+ <dt><a href="#PointerEventService">PointerEventService</a> ⇐ <code><a href="#MouseEventService">MouseEventService</a></code></dt>
54
+ <dd><p>Simulate the behaviour of the PointerEvent Class when there is no DOM available.</p>
55
+ </dd>
33
56
  <dt><a href="#NodeService">NodeService</a> ⇐ <code>PseudoEventTarget</code></dt>
34
57
  <dd><p>Simulate the behaviour of the Node Class when there is no DOM available.</p>
35
58
  </dd>
36
59
  <dt><a href="#NamedNodeMapService">NamedNodeMapService</a></dt>
37
60
  <dd><p>Simulate the behaviour of the NamedNodeMap Class when there is no DOM available.</p>
38
61
  </dd>
62
+ <dt><a href="#MouseEventService">MouseEventService</a> ⇐ <code><a href="#UIEventService">UIEventService</a></code></dt>
63
+ <dd><p>Simulate the behaviour of the MouseEvent Class when there is no DOM available.</p>
64
+ </dd>
65
+ <dt><a href="#KeyboardEventService">KeyboardEventService</a> ⇐ <code><a href="#UIEventService">UIEventService</a></code></dt>
66
+ <dd><p>Simulate the behaviour of the KeyboardEvent Class when there is no DOM available.</p>
67
+ </dd>
68
+ <dt><a href="#InputEventService">InputEventService</a> ⇐ <code><a href="#UIEventService">UIEventService</a></code></dt>
69
+ <dd><p>Simulate the behaviour of the InputEvent Class when there is no DOM available.</p>
70
+ </dd>
39
71
  <dt><a href="#HTMLElementService">HTMLElementService</a> ⇐ <code>PseudoElement</code></dt>
40
72
  <dd><p>Simulate the behaviour of the HTMLElement Class when there is no DOM available.</p>
41
73
  </dd>
74
+ <dt><a href="#FocusEventService">FocusEventService</a> ⇐ <code><a href="#UIEventService">UIEventService</a></code></dt>
75
+ <dd><p>Simulate the behaviour of the FocusEvent Class when there is no DOM available.</p>
76
+ </dd>
42
77
  <dt><a href="#EventTargetService">EventTargetService</a></dt>
43
- <dd><p>Simulate the behaviour of the EventTarget Class when there is no DOM available.</p>
78
+ <dd><p>Simulate the behaviour of the EventTarget Class when there is no DOM available.
79
+ Dispatching an event sends it through the tree the way the DOM does: down from the root to the target (capture
80
+ listeners), to the target itself, then back up to the root (the listeners which are not capture listeners, when the
81
+ event bubbles).</p>
44
82
  </dd>
45
83
  <dt><a href="#EventService">EventService</a></dt>
46
84
  <dd><p>Simulate the behaviour of the Event Class when there is no DOM available.</p>
@@ -58,6 +96,9 @@ not part of a tree, when it is inserted its children are moved into the tree ins
58
96
  <dt><a href="#DOMTokenListService">DOMTokenListService</a></dt>
59
97
  <dd><p>Simulate the behaviour of the DOMTokenList Class when there is no DOM available.</p>
60
98
  </dd>
99
+ <dt><a href="#CustomEventService">CustomEventService</a> ⇐ <code><a href="#EventService">EventService</a></code></dt>
100
+ <dd><p>Simulate the behaviour of the CustomEvent Class when there is no DOM available: an event which carries data.</p>
101
+ </dd>
61
102
  <dt><a href="#AttrService">AttrService</a> ⇐ <code><a href="#NodeService">NodeService</a></code></dt>
62
103
  <dd><p>Simulate the behaviour of the Attr Class when there is no DOM available.</p>
63
104
  </dd>
@@ -77,9 +118,23 @@ the linkers that hold them.</p>
77
118
  </dd>
78
119
  </dl>
79
120
 
121
+ ## Members
122
+
123
+ <dl>
124
+ <dt><a href="#eventDefaults">eventDefaults</a> : <code>Object.&lt;string, EventDefinition&gt;</code></dt>
125
+ <dd><p>The events which the browser itself creates (for a user action, or for something like element.click()) have these
126
+ options. A script which creates an event with the constructor gets none of them (everything is false) unless it asks
127
+ for them, which is why createEvent only uses this table when it is told the browser is creating the event.
128
+ The values follow the UI Events, HTML, Pointer Events, Clipboard, Drag and Drop, Touch and CSS specifications.</p>
129
+ </dd>
130
+ </dl>
131
+
80
132
  ## Constants
81
133
 
82
134
  <dl>
135
+ <dt><a href="#focused">focused</a></dt>
136
+ <dd><p>The element which has the focus, kept for each tree (the root node of the tree it is in), like document.activeElement.</p>
137
+ </dd>
83
138
  <dt><a href="#HTMLElementService_1">HTMLElementService_1</a> : <code>PseudoHTMLElement</code></dt>
84
139
  <dd></dd>
85
140
  </dl>
@@ -87,6 +142,12 @@ the linkers that hold them.</p>
87
142
  ## Functions
88
143
 
89
144
  <dl>
145
+ <dt><a href="#modifierKeys">modifierKeys([init])</a> ⇒ <code>ModifierKeys</code></dt>
146
+ <dd><p>Pick the modifier keys out of the init object of an event.</p>
147
+ </dd>
148
+ <dt><a href="#modifierState">modifierState(keys, key)</a> ⇒ <code>boolean</code></dt>
149
+ <dd><p>Answer getModifierState for a set of held modifier keys.</p>
150
+ </dd>
90
151
  <dt><a href="#getParentNodesFromAttribute">getParentNodesFromAttribute(attr, value, node)</a> ⇒ <code>Array.&lt;PseudoNode&gt;</code></dt>
91
152
  <dd><p>A selector function for retrieving existing parent PseudoNode from the given child item.
92
153
  This function will check all the parents starting from node, and scan the attributes
@@ -96,6 +157,12 @@ property for matches. The return array contains all matching parent ancestors, s
96
157
  <dd><p>Get all of the ancestors of a node, starting with the root of the tree and ending with the node&#39;s own parent (the
97
158
  order in which an event travels down through them). A node which has no parent has no ancestors.</p>
98
159
  </dd>
160
+ <dt><a href="#getActiveElement">getActiveElement(root)</a> ⇒ <code>Object</code> | <code>null</code></dt>
161
+ <dd><p>Find the element which has the focus in a tree.</p>
162
+ </dd>
163
+ <dt><a href="#setActiveElement">setActiveElement(root, element)</a></dt>
164
+ <dd><p>Remember the element which has the focus in a tree.</p>
165
+ </dd>
99
166
  <dt><a href="#generateNodeList">generateNodeList([innerList])</a> ⇒ <code><a href="#PseudoNodeList">PseudoNodeList</a></code></dt>
100
167
  <dd><p>Create a PseudoNodeList, optionally starting from an existing chain of linkers.</p>
101
168
  </dd>
@@ -107,14 +174,232 @@ tree (or list) of nodes from plain values.</p>
107
174
  <dd><p>Construct the Pseudo Dom to provide access to Dom objects which are otherwise not available outside the browser
108
175
  context.</p>
109
176
  </dd>
177
+ <dt><a href="#createEvent">createEvent(type, [init], [options])</a> ⇒ <code><a href="#EventService">EventService</a></code></dt>
178
+ <dd><p>Create an event of the kind which suits its type (a click is a MouseEvent, a keydown a KeyboardEvent, ...).
179
+ By default this is like using the constructor of the event in a script: nothing bubbles or can be cancelled unless
180
+ the init says so, and the event is not trusted. With browser: true the event is created the way the browser creates
181
+ it, using the standard options for its type (see eventDefaults), and trusted: true makes it look like it came from a
182
+ real user action (isTrusted).</p>
183
+ </dd>
110
184
  </dl>
111
185
 
186
+ <a name="module_pseudoDom/simulate"></a>
187
+
188
+ ## pseudoDom/simulate
189
+ Simulate what a user does, with the events the browser sends for it.
190
+
191
+ **Version**: 1.0.0
192
+ **Author**: Joshua Heagle <joshuaheagle@gmail.com>
193
+
194
+ * [pseudoDom/simulate](#module_pseudoDom/simulate)
195
+ * [~focusableFrom(element)](#module_pseudoDom/simulate..focusableFrom) ⇒ <code>\*</code> \| <code>null</code>
196
+ * [~click(element, [init])](#module_pseudoDom/simulate..click) ⇒ <code>boolean</code>
197
+ * [~keyPress(element, key, [init])](#module_pseudoDom/simulate..keyPress) ⇒ <code>boolean</code>
198
+
199
+ <a name="module_pseudoDom/simulate..focusableFrom"></a>
200
+
201
+ ### pseudoDom/simulate~focusableFrom(element) ⇒ <code>\*</code> \| <code>null</code>
202
+ The nearest element (starting with the element itself) which can have the focus.
203
+
204
+ **Kind**: inner method of [<code>pseudoDom/simulate</code>](#module_pseudoDom/simulate)
205
+
206
+ | Param | Type | Description |
207
+ | --- | --- | --- |
208
+ | element | <code>\*</code> | Where to start |
209
+
210
+ <a name="module_pseudoDom/simulate..click"></a>
211
+
212
+ ### pseudoDom/simulate~click(element, [init]) ⇒ <code>boolean</code>
213
+ Click an element the way a user does: pointerdown and mousedown, then the focus moves to the nearest element which
214
+ can have it (or is taken away from the one which had it) unless mousedown was cancelled, then pointerup, mouseup
215
+ and finally click. Every event is trusted and has the options the browser gives it. A disabled element gets nothing.
216
+
217
+ **Kind**: inner method of [<code>pseudoDom/simulate</code>](#module_pseudoDom/simulate)
218
+ **Returns**: <code>boolean</code> - False when the click was cancelled (or the element is disabled), so its default action did not happen
219
+
220
+ | Param | Type | Default | Description |
221
+ | --- | --- | --- | --- |
222
+ | element | <code>\*</code> | | The element to click |
223
+ | [init] | <code>Object</code> | <code>{}</code> | Options for the events (for example clientX, clientY, shiftKey) |
224
+
225
+ <a name="module_pseudoDom/simulate..keyPress"></a>
226
+
227
+ ### pseudoDom/simulate~keyPress(element, key, [init]) ⇒ <code>boolean</code>
228
+ Press and release a key on an element (the element which has the focus, or one given): keydown and then keyup.
229
+
230
+ **Kind**: inner method of [<code>pseudoDom/simulate</code>](#module_pseudoDom/simulate)
231
+ **Returns**: <code>boolean</code> - False when keydown was cancelled, so its default action did not happen
232
+
233
+ | Param | Type | Default | Description |
234
+ | --- | --- | --- | --- |
235
+ | element | <code>\*</code> | | The element which gets the key |
236
+ | key | <code>string</code> | | The value of the key, such as a or Enter |
237
+ | [init] | <code>Object</code> | <code>{}</code> | Options for the events (for example code, shiftKey) |
238
+
112
239
  <a name="module_pseudoDom/objects"></a>
113
240
 
114
241
  ## pseudoDom/objects : <code>Object</code>
115
242
  All methods exported from this module are encapsulated within pseudoDom.
116
243
 
117
244
  **Author**: Joshua Heagle <joshuaheagle@gmail.com>
245
+ <a name="UIEventService"></a>
246
+
247
+ ## UIEventService ⇐ [<code>EventService</code>](#EventService)
248
+ Simulate the behaviour of the UIEvent Class when there is no DOM available: the events which come from a user
249
+ interface (the mouse, the keyboard, focus and input).
250
+
251
+ **Kind**: global class
252
+ **Extends**: [<code>EventService</code>](#EventService)
253
+ **Author**: Joshua Heagle <joshuaheagle@gmail.com>
254
+ **Properties**
255
+
256
+ | Name | Type |
257
+ | --- | --- |
258
+ | detail | <code>number</code> |
259
+ | view | <code>\*</code> |
260
+
261
+
262
+ * [UIEventService](#UIEventService) ⇐ [<code>EventService</code>](#EventService)
263
+ * [new UIEventService([typeArg], [init])](#new_UIEventService_new)
264
+ * [.inner](#EventService+inner) ⇒ <code>EventInner</code>
265
+ * [.composedPath()](#EventService+composedPath) ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
266
+ * [.preventDefault()](#EventService+preventDefault) ⇒ <code>null</code>
267
+ * [.stopImmediatePropagation()](#EventService+stopImmediatePropagation) ⇒ <code>null</code>
268
+ * [.stopPropagation()](#EventService+stopPropagation) ⇒ <code>null</code>
269
+
270
+ <a name="new_UIEventService_new"></a>
271
+
272
+ ### new UIEventService([typeArg], [init])
273
+
274
+ | Param | Type | Default | Description |
275
+ | --- | --- | --- | --- |
276
+ | [typeArg] | <code>string</code> | <code>&quot;&#x27;&#x27;&quot;</code> | The type of the event |
277
+ | [init] | <code>UIEventInit</code> | <code>{}</code> | The options for the event |
278
+
279
+ <a name="EventService+inner"></a>
280
+
281
+ ### uiEventService.inner ⇒ <code>EventInner</code>
282
+ Scope several accessors inside the inner object. These are only intended for usage by other DOM classes.
283
+
284
+ **Kind**: instance property of [<code>UIEventService</code>](#UIEventService)
285
+ **Overrides**: [<code>inner</code>](#EventService+inner)
286
+ <a name="EventService+composedPath"></a>
287
+
288
+ ### uiEventService.composedPath() ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
289
+ Return an array of targets that will have the event executed open them. The order is based on the eventPhase
290
+
291
+ **Kind**: instance method of [<code>UIEventService</code>](#UIEventService)
292
+ **Overrides**: [<code>composedPath</code>](#EventService+composedPath)
293
+ <a name="EventService+preventDefault"></a>
294
+
295
+ ### uiEventService.preventDefault() ⇒ <code>null</code>
296
+ Cancels the event (if it is cancelable).
297
+
298
+ **Kind**: instance method of [<code>UIEventService</code>](#UIEventService)
299
+ **Overrides**: [<code>preventDefault</code>](#EventService+preventDefault)
300
+ <a name="EventService+stopImmediatePropagation"></a>
301
+
302
+ ### uiEventService.stopImmediatePropagation() ⇒ <code>null</code>
303
+ For this particular event, no other listener will be called.
304
+ Neither those attached on the same element, nor those attached on elements which will be traversed later (in
305
+ capture phase, for instance)
306
+
307
+ **Kind**: instance method of [<code>UIEventService</code>](#UIEventService)
308
+ **Overrides**: [<code>stopImmediatePropagation</code>](#EventService+stopImmediatePropagation)
309
+ <a name="EventService+stopPropagation"></a>
310
+
311
+ ### uiEventService.stopPropagation() ⇒ <code>null</code>
312
+ Stops the propagation of events further along in the Dom.
313
+
314
+ **Kind**: instance method of [<code>UIEventService</code>](#UIEventService)
315
+ **Overrides**: [<code>stopPropagation</code>](#EventService+stopPropagation)
316
+ <a name="PointerEventService"></a>
317
+
318
+ ## PointerEventService ⇐ [<code>MouseEventService</code>](#MouseEventService)
319
+ Simulate the behaviour of the PointerEvent Class when there is no DOM available.
320
+
321
+ **Kind**: global class
322
+ **Extends**: [<code>MouseEventService</code>](#MouseEventService)
323
+ **Author**: Joshua Heagle <joshuaheagle@gmail.com>
324
+ **Properties**
325
+
326
+ | Name | Type |
327
+ | --- | --- |
328
+ | pointerId | <code>number</code> |
329
+ | width | <code>number</code> |
330
+ | height | <code>number</code> |
331
+ | pressure | <code>number</code> |
332
+ | pointerType | <code>string</code> |
333
+ | isPrimary | <code>boolean</code> |
334
+
335
+
336
+ * [PointerEventService](#PointerEventService) ⇐ [<code>MouseEventService</code>](#MouseEventService)
337
+ * [new PointerEventService([typeArg], [init])](#new_PointerEventService_new)
338
+ * [.inner](#EventService+inner) ⇒ <code>EventInner</code>
339
+ * [.getModifierState(key)](#MouseEventService+getModifierState) ⇒ <code>boolean</code>
340
+ * [.composedPath()](#EventService+composedPath) ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
341
+ * [.preventDefault()](#EventService+preventDefault) ⇒ <code>null</code>
342
+ * [.stopImmediatePropagation()](#EventService+stopImmediatePropagation) ⇒ <code>null</code>
343
+ * [.stopPropagation()](#EventService+stopPropagation) ⇒ <code>null</code>
344
+
345
+ <a name="new_PointerEventService_new"></a>
346
+
347
+ ### new PointerEventService([typeArg], [init])
348
+
349
+ | Param | Type | Default | Description |
350
+ | --- | --- | --- | --- |
351
+ | [typeArg] | <code>string</code> | <code>&quot;&#x27;&#x27;&quot;</code> | The type of the event |
352
+ | [init] | <code>PointerEventInit</code> | <code>{}</code> | The options for the event |
353
+
354
+ <a name="EventService+inner"></a>
355
+
356
+ ### pointerEventService.inner ⇒ <code>EventInner</code>
357
+ Scope several accessors inside the inner object. These are only intended for usage by other DOM classes.
358
+
359
+ **Kind**: instance property of [<code>PointerEventService</code>](#PointerEventService)
360
+ **Overrides**: [<code>inner</code>](#EventService+inner)
361
+ <a name="MouseEventService+getModifierState"></a>
362
+
363
+ ### pointerEventService.getModifierState(key) ⇒ <code>boolean</code>
364
+ Whether a modifier key was held down when the event happened.
365
+
366
+ **Kind**: instance method of [<code>PointerEventService</code>](#PointerEventService)
367
+ **Overrides**: [<code>getModifierState</code>](#MouseEventService+getModifierState)
368
+
369
+ | Param | Type | Description |
370
+ | --- | --- | --- |
371
+ | key | <code>string</code> | Control, Shift, Alt or Meta |
372
+
373
+ <a name="EventService+composedPath"></a>
374
+
375
+ ### pointerEventService.composedPath() ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
376
+ Return an array of targets that will have the event executed open them. The order is based on the eventPhase
377
+
378
+ **Kind**: instance method of [<code>PointerEventService</code>](#PointerEventService)
379
+ **Overrides**: [<code>composedPath</code>](#EventService+composedPath)
380
+ <a name="EventService+preventDefault"></a>
381
+
382
+ ### pointerEventService.preventDefault() ⇒ <code>null</code>
383
+ Cancels the event (if it is cancelable).
384
+
385
+ **Kind**: instance method of [<code>PointerEventService</code>](#PointerEventService)
386
+ **Overrides**: [<code>preventDefault</code>](#EventService+preventDefault)
387
+ <a name="EventService+stopImmediatePropagation"></a>
388
+
389
+ ### pointerEventService.stopImmediatePropagation() ⇒ <code>null</code>
390
+ For this particular event, no other listener will be called.
391
+ Neither those attached on the same element, nor those attached on elements which will be traversed later (in
392
+ capture phase, for instance)
393
+
394
+ **Kind**: instance method of [<code>PointerEventService</code>](#PointerEventService)
395
+ **Overrides**: [<code>stopImmediatePropagation</code>](#EventService+stopImmediatePropagation)
396
+ <a name="EventService+stopPropagation"></a>
397
+
398
+ ### pointerEventService.stopPropagation() ⇒ <code>null</code>
399
+ Stops the propagation of events further along in the Dom.
400
+
401
+ **Kind**: instance method of [<code>PointerEventService</code>](#PointerEventService)
402
+ **Overrides**: [<code>stopPropagation</code>](#EventService+stopPropagation)
118
403
  <a name="NodeService"></a>
119
404
 
120
405
  ## NodeService ⇐ <code>PseudoEventTarget</code>
@@ -274,6 +559,249 @@ Simulate the behaviour of the NamedNodeMap Class when there is no DOM available.
274
559
  | --- | --- | --- | --- |
275
560
  | [attributes] | <code>Array.&lt;PseudoAttr&gt;</code> | <code>[]</code> | The attributes to start with |
276
561
 
562
+ <a name="MouseEventService"></a>
563
+
564
+ ## MouseEventService ⇐ [<code>UIEventService</code>](#UIEventService)
565
+ Simulate the behaviour of the MouseEvent Class when there is no DOM available.
566
+
567
+ **Kind**: global class
568
+ **Extends**: [<code>UIEventService</code>](#UIEventService)
569
+ **Author**: Joshua Heagle <joshuaheagle@gmail.com>
570
+ **Properties**
571
+
572
+ | Name | Type |
573
+ | --- | --- |
574
+ | screenX | <code>number</code> |
575
+ | screenY | <code>number</code> |
576
+ | clientX | <code>number</code> |
577
+ | clientY | <code>number</code> |
578
+ | button | <code>number</code> |
579
+ | buttons | <code>number</code> |
580
+ | relatedTarget | <code>PseudoEventTarget</code> \| <code>null</code> |
581
+
582
+
583
+ * [MouseEventService](#MouseEventService) ⇐ [<code>UIEventService</code>](#UIEventService)
584
+ * [new MouseEventService([typeArg], [init])](#new_MouseEventService_new)
585
+ * [.inner](#EventService+inner) ⇒ <code>EventInner</code>
586
+ * [.getModifierState(key)](#MouseEventService+getModifierState) ⇒ <code>boolean</code>
587
+ * [.composedPath()](#EventService+composedPath) ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
588
+ * [.preventDefault()](#EventService+preventDefault) ⇒ <code>null</code>
589
+ * [.stopImmediatePropagation()](#EventService+stopImmediatePropagation) ⇒ <code>null</code>
590
+ * [.stopPropagation()](#EventService+stopPropagation) ⇒ <code>null</code>
591
+
592
+ <a name="new_MouseEventService_new"></a>
593
+
594
+ ### new MouseEventService([typeArg], [init])
595
+
596
+ | Param | Type | Default | Description |
597
+ | --- | --- | --- | --- |
598
+ | [typeArg] | <code>string</code> | <code>&quot;&#x27;&#x27;&quot;</code> | The type of the event |
599
+ | [init] | <code>MouseEventInit</code> | <code>{}</code> | The options for the event |
600
+
601
+ <a name="EventService+inner"></a>
602
+
603
+ ### mouseEventService.inner ⇒ <code>EventInner</code>
604
+ Scope several accessors inside the inner object. These are only intended for usage by other DOM classes.
605
+
606
+ **Kind**: instance property of [<code>MouseEventService</code>](#MouseEventService)
607
+ **Overrides**: [<code>inner</code>](#EventService+inner)
608
+ <a name="MouseEventService+getModifierState"></a>
609
+
610
+ ### mouseEventService.getModifierState(key) ⇒ <code>boolean</code>
611
+ Whether a modifier key was held down when the event happened.
612
+
613
+ **Kind**: instance method of [<code>MouseEventService</code>](#MouseEventService)
614
+
615
+ | Param | Type | Description |
616
+ | --- | --- | --- |
617
+ | key | <code>string</code> | Control, Shift, Alt or Meta |
618
+
619
+ <a name="EventService+composedPath"></a>
620
+
621
+ ### mouseEventService.composedPath() ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
622
+ Return an array of targets that will have the event executed open them. The order is based on the eventPhase
623
+
624
+ **Kind**: instance method of [<code>MouseEventService</code>](#MouseEventService)
625
+ **Overrides**: [<code>composedPath</code>](#EventService+composedPath)
626
+ <a name="EventService+preventDefault"></a>
627
+
628
+ ### mouseEventService.preventDefault() ⇒ <code>null</code>
629
+ Cancels the event (if it is cancelable).
630
+
631
+ **Kind**: instance method of [<code>MouseEventService</code>](#MouseEventService)
632
+ **Overrides**: [<code>preventDefault</code>](#EventService+preventDefault)
633
+ <a name="EventService+stopImmediatePropagation"></a>
634
+
635
+ ### mouseEventService.stopImmediatePropagation() ⇒ <code>null</code>
636
+ For this particular event, no other listener will be called.
637
+ Neither those attached on the same element, nor those attached on elements which will be traversed later (in
638
+ capture phase, for instance)
639
+
640
+ **Kind**: instance method of [<code>MouseEventService</code>](#MouseEventService)
641
+ **Overrides**: [<code>stopImmediatePropagation</code>](#EventService+stopImmediatePropagation)
642
+ <a name="EventService+stopPropagation"></a>
643
+
644
+ ### mouseEventService.stopPropagation() ⇒ <code>null</code>
645
+ Stops the propagation of events further along in the Dom.
646
+
647
+ **Kind**: instance method of [<code>MouseEventService</code>](#MouseEventService)
648
+ **Overrides**: [<code>stopPropagation</code>](#EventService+stopPropagation)
649
+ <a name="KeyboardEventService"></a>
650
+
651
+ ## KeyboardEventService ⇐ [<code>UIEventService</code>](#UIEventService)
652
+ Simulate the behaviour of the KeyboardEvent Class when there is no DOM available.
653
+
654
+ **Kind**: global class
655
+ **Extends**: [<code>UIEventService</code>](#UIEventService)
656
+ **Author**: Joshua Heagle <joshuaheagle@gmail.com>
657
+ **Properties**
658
+
659
+ | Name | Type |
660
+ | --- | --- |
661
+ | key | <code>string</code> |
662
+ | code | <code>string</code> |
663
+ | location | <code>number</code> |
664
+ | repeat | <code>boolean</code> |
665
+ | isComposing | <code>boolean</code> |
666
+
667
+
668
+ * [KeyboardEventService](#KeyboardEventService) ⇐ [<code>UIEventService</code>](#UIEventService)
669
+ * [new KeyboardEventService([typeArg], [init])](#new_KeyboardEventService_new)
670
+ * [.inner](#EventService+inner) ⇒ <code>EventInner</code>
671
+ * [.getModifierState(key)](#KeyboardEventService+getModifierState) ⇒ <code>boolean</code>
672
+ * [.composedPath()](#EventService+composedPath) ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
673
+ * [.preventDefault()](#EventService+preventDefault) ⇒ <code>null</code>
674
+ * [.stopImmediatePropagation()](#EventService+stopImmediatePropagation) ⇒ <code>null</code>
675
+ * [.stopPropagation()](#EventService+stopPropagation) ⇒ <code>null</code>
676
+
677
+ <a name="new_KeyboardEventService_new"></a>
678
+
679
+ ### new KeyboardEventService([typeArg], [init])
680
+
681
+ | Param | Type | Default | Description |
682
+ | --- | --- | --- | --- |
683
+ | [typeArg] | <code>string</code> | <code>&quot;&#x27;&#x27;&quot;</code> | The type of the event |
684
+ | [init] | <code>KeyboardEventInit</code> | <code>{}</code> | The options for the event |
685
+
686
+ <a name="EventService+inner"></a>
687
+
688
+ ### keyboardEventService.inner ⇒ <code>EventInner</code>
689
+ Scope several accessors inside the inner object. These are only intended for usage by other DOM classes.
690
+
691
+ **Kind**: instance property of [<code>KeyboardEventService</code>](#KeyboardEventService)
692
+ **Overrides**: [<code>inner</code>](#EventService+inner)
693
+ <a name="KeyboardEventService+getModifierState"></a>
694
+
695
+ ### keyboardEventService.getModifierState(key) ⇒ <code>boolean</code>
696
+ Whether a modifier key was held down when the event happened.
697
+
698
+ **Kind**: instance method of [<code>KeyboardEventService</code>](#KeyboardEventService)
699
+
700
+ | Param | Type | Description |
701
+ | --- | --- | --- |
702
+ | key | <code>string</code> | Control, Shift, Alt or Meta |
703
+
704
+ <a name="EventService+composedPath"></a>
705
+
706
+ ### keyboardEventService.composedPath() ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
707
+ Return an array of targets that will have the event executed open them. The order is based on the eventPhase
708
+
709
+ **Kind**: instance method of [<code>KeyboardEventService</code>](#KeyboardEventService)
710
+ **Overrides**: [<code>composedPath</code>](#EventService+composedPath)
711
+ <a name="EventService+preventDefault"></a>
712
+
713
+ ### keyboardEventService.preventDefault() ⇒ <code>null</code>
714
+ Cancels the event (if it is cancelable).
715
+
716
+ **Kind**: instance method of [<code>KeyboardEventService</code>](#KeyboardEventService)
717
+ **Overrides**: [<code>preventDefault</code>](#EventService+preventDefault)
718
+ <a name="EventService+stopImmediatePropagation"></a>
719
+
720
+ ### keyboardEventService.stopImmediatePropagation() ⇒ <code>null</code>
721
+ For this particular event, no other listener will be called.
722
+ Neither those attached on the same element, nor those attached on elements which will be traversed later (in
723
+ capture phase, for instance)
724
+
725
+ **Kind**: instance method of [<code>KeyboardEventService</code>](#KeyboardEventService)
726
+ **Overrides**: [<code>stopImmediatePropagation</code>](#EventService+stopImmediatePropagation)
727
+ <a name="EventService+stopPropagation"></a>
728
+
729
+ ### keyboardEventService.stopPropagation() ⇒ <code>null</code>
730
+ Stops the propagation of events further along in the Dom.
731
+
732
+ **Kind**: instance method of [<code>KeyboardEventService</code>](#KeyboardEventService)
733
+ **Overrides**: [<code>stopPropagation</code>](#EventService+stopPropagation)
734
+ <a name="InputEventService"></a>
735
+
736
+ ## InputEventService ⇐ [<code>UIEventService</code>](#UIEventService)
737
+ Simulate the behaviour of the InputEvent Class when there is no DOM available.
738
+
739
+ **Kind**: global class
740
+ **Extends**: [<code>UIEventService</code>](#UIEventService)
741
+ **Author**: Joshua Heagle <joshuaheagle@gmail.com>
742
+ **Properties**
743
+
744
+ | Name | Type |
745
+ | --- | --- |
746
+ | data | <code>string</code> \| <code>null</code> |
747
+ | inputType | <code>string</code> |
748
+ | isComposing | <code>boolean</code> |
749
+
750
+
751
+ * [InputEventService](#InputEventService) ⇐ [<code>UIEventService</code>](#UIEventService)
752
+ * [new InputEventService([typeArg], [init])](#new_InputEventService_new)
753
+ * [.inner](#EventService+inner) ⇒ <code>EventInner</code>
754
+ * [.composedPath()](#EventService+composedPath) ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
755
+ * [.preventDefault()](#EventService+preventDefault) ⇒ <code>null</code>
756
+ * [.stopImmediatePropagation()](#EventService+stopImmediatePropagation) ⇒ <code>null</code>
757
+ * [.stopPropagation()](#EventService+stopPropagation) ⇒ <code>null</code>
758
+
759
+ <a name="new_InputEventService_new"></a>
760
+
761
+ ### new InputEventService([typeArg], [init])
762
+
763
+ | Param | Type | Default | Description |
764
+ | --- | --- | --- | --- |
765
+ | [typeArg] | <code>string</code> | <code>&quot;&#x27;&#x27;&quot;</code> | The type of the event |
766
+ | [init] | <code>InputEventInit</code> | <code>{}</code> | The options for the event |
767
+
768
+ <a name="EventService+inner"></a>
769
+
770
+ ### inputEventService.inner ⇒ <code>EventInner</code>
771
+ Scope several accessors inside the inner object. These are only intended for usage by other DOM classes.
772
+
773
+ **Kind**: instance property of [<code>InputEventService</code>](#InputEventService)
774
+ **Overrides**: [<code>inner</code>](#EventService+inner)
775
+ <a name="EventService+composedPath"></a>
776
+
777
+ ### inputEventService.composedPath() ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
778
+ Return an array of targets that will have the event executed open them. The order is based on the eventPhase
779
+
780
+ **Kind**: instance method of [<code>InputEventService</code>](#InputEventService)
781
+ **Overrides**: [<code>composedPath</code>](#EventService+composedPath)
782
+ <a name="EventService+preventDefault"></a>
783
+
784
+ ### inputEventService.preventDefault() ⇒ <code>null</code>
785
+ Cancels the event (if it is cancelable).
786
+
787
+ **Kind**: instance method of [<code>InputEventService</code>](#InputEventService)
788
+ **Overrides**: [<code>preventDefault</code>](#EventService+preventDefault)
789
+ <a name="EventService+stopImmediatePropagation"></a>
790
+
791
+ ### inputEventService.stopImmediatePropagation() ⇒ <code>null</code>
792
+ For this particular event, no other listener will be called.
793
+ Neither those attached on the same element, nor those attached on elements which will be traversed later (in
794
+ capture phase, for instance)
795
+
796
+ **Kind**: instance method of [<code>InputEventService</code>](#InputEventService)
797
+ **Overrides**: [<code>stopImmediatePropagation</code>](#EventService+stopImmediatePropagation)
798
+ <a name="EventService+stopPropagation"></a>
799
+
800
+ ### inputEventService.stopPropagation() ⇒ <code>null</code>
801
+ Stops the propagation of events further along in the Dom.
802
+
803
+ **Kind**: instance method of [<code>InputEventService</code>](#InputEventService)
804
+ **Overrides**: [<code>stopPropagation</code>](#EventService+stopPropagation)
277
805
  <a name="HTMLElementService"></a>
278
806
 
279
807
  ## HTMLElementService ⇐ <code>PseudoElement</code>
@@ -295,6 +823,14 @@ Simulate the behaviour of the HTMLElement Class when there is no DOM available.
295
823
  | style | <code>Object</code> | A container to define all applied inline-styles |
296
824
  | title | <code>string</code> | The title attribute which affects the text visible on hover |
297
825
 
826
+
827
+ * [HTMLElementService](#HTMLElementService) ⇐ <code>PseudoElement</code>
828
+ * [new HTMLElementService([elementOptions])](#new_HTMLElementService_new)
829
+ * [.canFocus](#HTMLElementService+canFocus) ⇒ <code>boolean</code>
830
+ * [.click()](#HTMLElementService+click)
831
+ * [.focus()](#HTMLElementService+focus)
832
+ * [.blur()](#HTMLElementService+blur)
833
+
298
834
  <a name="new_HTMLElementService_new"></a>
299
835
 
300
836
  ### new HTMLElementService([elementOptions])
@@ -308,10 +844,109 @@ Simulate the HTMLElement object when the Dom is not available
308
844
  | [elementOptions.parent] | <code>PseudoNode</code> \| <code>Object</code> | <code>{}</code> |
309
845
  | [elementOptions.children] | <code>Array</code> | <code>[]</code> |
310
846
 
847
+ <a name="HTMLElementService+canFocus"></a>
848
+
849
+ ### htmlElementService.canFocus ⇒ <code>boolean</code>
850
+ Whether this element can have the focus: form controls and links which are not disabled, and anything with a tabindex.
851
+
852
+ **Kind**: instance property of [<code>HTMLElementService</code>](#HTMLElementService)
853
+ <a name="HTMLElementService+click"></a>
854
+
855
+ ### htmlElementService.click()
856
+ Click the element: a click event is sent to it, which bubbles and can be cancelled, like one from a user but a
857
+ script made it (so it is not trusted). A disabled element does nothing.
858
+
859
+ **Kind**: instance method of [<code>HTMLElementService</code>](#HTMLElementService)
860
+ <a name="HTMLElementService+focus"></a>
861
+
862
+ ### htmlElementService.focus()
863
+ Give the element the focus. The element which had it gets blur then focusout, and this one gets focus then
864
+ focusin (blur and focus do not bubble, focusin and focusout do). Nothing happens when the element cannot have the
865
+ focus or already has it.
866
+
867
+ **Kind**: instance method of [<code>HTMLElementService</code>](#HTMLElementService)
868
+ <a name="HTMLElementService+blur"></a>
869
+
870
+ ### htmlElementService.blur()
871
+ Take the focus away from the element, when it has it: it gets blur then focusout.
872
+
873
+ **Kind**: instance method of [<code>HTMLElementService</code>](#HTMLElementService)
874
+ <a name="FocusEventService"></a>
875
+
876
+ ## FocusEventService ⇐ [<code>UIEventService</code>](#UIEventService)
877
+ Simulate the behaviour of the FocusEvent Class when there is no DOM available.
878
+
879
+ **Kind**: global class
880
+ **Extends**: [<code>UIEventService</code>](#UIEventService)
881
+ **Author**: Joshua Heagle <joshuaheagle@gmail.com>
882
+ **Properties**
883
+
884
+ | Name | Type |
885
+ | --- | --- |
886
+ | relatedTarget | <code>PseudoEventTarget</code> \| <code>null</code> |
887
+
888
+
889
+ * [FocusEventService](#FocusEventService) ⇐ [<code>UIEventService</code>](#UIEventService)
890
+ * [new FocusEventService([typeArg], [init])](#new_FocusEventService_new)
891
+ * [.inner](#EventService+inner) ⇒ <code>EventInner</code>
892
+ * [.composedPath()](#EventService+composedPath) ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
893
+ * [.preventDefault()](#EventService+preventDefault) ⇒ <code>null</code>
894
+ * [.stopImmediatePropagation()](#EventService+stopImmediatePropagation) ⇒ <code>null</code>
895
+ * [.stopPropagation()](#EventService+stopPropagation) ⇒ <code>null</code>
896
+
897
+ <a name="new_FocusEventService_new"></a>
898
+
899
+ ### new FocusEventService([typeArg], [init])
900
+
901
+ | Param | Type | Default | Description |
902
+ | --- | --- | --- | --- |
903
+ | [typeArg] | <code>string</code> | <code>&quot;&#x27;&#x27;&quot;</code> | The type of the event |
904
+ | [init] | <code>FocusEventInit</code> | <code>{}</code> | The options for the event |
905
+
906
+ <a name="EventService+inner"></a>
907
+
908
+ ### focusEventService.inner ⇒ <code>EventInner</code>
909
+ Scope several accessors inside the inner object. These are only intended for usage by other DOM classes.
910
+
911
+ **Kind**: instance property of [<code>FocusEventService</code>](#FocusEventService)
912
+ **Overrides**: [<code>inner</code>](#EventService+inner)
913
+ <a name="EventService+composedPath"></a>
914
+
915
+ ### focusEventService.composedPath() ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
916
+ Return an array of targets that will have the event executed open them. The order is based on the eventPhase
917
+
918
+ **Kind**: instance method of [<code>FocusEventService</code>](#FocusEventService)
919
+ **Overrides**: [<code>composedPath</code>](#EventService+composedPath)
920
+ <a name="EventService+preventDefault"></a>
921
+
922
+ ### focusEventService.preventDefault() ⇒ <code>null</code>
923
+ Cancels the event (if it is cancelable).
924
+
925
+ **Kind**: instance method of [<code>FocusEventService</code>](#FocusEventService)
926
+ **Overrides**: [<code>preventDefault</code>](#EventService+preventDefault)
927
+ <a name="EventService+stopImmediatePropagation"></a>
928
+
929
+ ### focusEventService.stopImmediatePropagation() ⇒ <code>null</code>
930
+ For this particular event, no other listener will be called.
931
+ Neither those attached on the same element, nor those attached on elements which will be traversed later (in
932
+ capture phase, for instance)
933
+
934
+ **Kind**: instance method of [<code>FocusEventService</code>](#FocusEventService)
935
+ **Overrides**: [<code>stopImmediatePropagation</code>](#EventService+stopImmediatePropagation)
936
+ <a name="EventService+stopPropagation"></a>
937
+
938
+ ### focusEventService.stopPropagation() ⇒ <code>null</code>
939
+ Stops the propagation of events further along in the Dom.
940
+
941
+ **Kind**: instance method of [<code>FocusEventService</code>](#FocusEventService)
942
+ **Overrides**: [<code>stopPropagation</code>](#EventService+stopPropagation)
311
943
  <a name="EventTargetService"></a>
312
944
 
313
945
  ## EventTargetService
314
946
  Simulate the behaviour of the EventTarget Class when there is no DOM available.
947
+ Dispatching an event sends it through the tree the way the DOM does: down from the root to the target (capture
948
+ listeners), to the target itself, then back up to the root (the listeners which are not capture listeners, when the
949
+ event bubbles).
315
950
 
316
951
  **Kind**: global class
317
952
  **Author**: Joshua Heagle <joshuaheagle@gmail.com>
@@ -327,8 +962,12 @@ Simulate the behaviour of the EventTarget Class when there is no DOM available.
327
962
 
328
963
  * [EventTargetService](#EventTargetService)
329
964
  * [.listenersFor(type)](#EventTargetService+listenersFor) ⇒ <code>LinkedList</code>
330
- * [.runEvents(event)](#EventTargetService+runEvents) ⇒ <code>\*</code>
965
+ * [.runEvents(event)](#EventTargetService+runEvents) ⇒ <code>Array.&lt;\*&gt;</code>
966
+ * [.removeListener(type, listener)](#EventTargetService+removeListener)
331
967
  * [.setDefaultEvent(type, callback)](#EventTargetService+setDefaultEvent)
968
+ * [.addEventListener(type, callback, [useCapture])](#EventTargetService+addEventListener)
969
+ * [.removeEventListener(type, callback, [options])](#EventTargetService+removeEventListener)
970
+ * [.dispatchEvent(event)](#EventTargetService+dispatchEvent) ⇒ <code>boolean</code>
332
971
 
333
972
  <a name="EventTargetService+listenersFor"></a>
334
973
 
@@ -343,17 +982,30 @@ The listeners registered for a type of event, creating the (empty) list of them
343
982
 
344
983
  <a name="EventTargetService+runEvents"></a>
345
984
 
346
- ### eventTargetService.runEvents(event) ⇒ <code>\*</code>
347
- Run each of the listeners registered on this target for the type of the event.
348
- Listeners which do not apply to the event's phase are skipped, running stops once immediate propagation is stopped,
349
- and listeners added or removed while running do not change which ones run for this event.
985
+ ### eventTargetService.runEvents(event) ⇒ <code>Array.&lt;\*&gt;</code>
986
+ Run the listeners registered on this target for the type of the event which apply to the phase the event is in
987
+ (at the target, the capture listeners run before the others). Listeners which are added while this runs do not run
988
+ for this event, and listeners which are removed while it runs no longer do. Running stops as soon as immediate
989
+ propagation is stopped. A listener which throws does not stop the others.
990
+
991
+ **Kind**: instance method of [<code>EventTargetService</code>](#EventTargetService)
992
+ **Returns**: <code>Array.&lt;\*&gt;</code> - The errors which the listeners threw
993
+
994
+ | Param | Type | Description |
995
+ | --- | --- | --- |
996
+ | event | [<code>EventService</code>](#EventService) | The event, which is at a phase and has a current target |
997
+
998
+ <a name="EventTargetService+removeListener"></a>
999
+
1000
+ ### eventTargetService.removeListener(type, listener)
1001
+ Take a listener out of the registered listeners, so that it does not run again.
350
1002
 
351
1003
  **Kind**: instance method of [<code>EventTargetService</code>](#EventTargetService)
352
- **Returns**: <code>\*</code> - true when there was nothing registered, otherwise the last value returned from a handler (null when none ran)
353
1004
 
354
1005
  | Param | Type |
355
1006
  | --- | --- |
356
- | event | [<code>EventService</code>](#EventService) |
1007
+ | type | <code>string</code> |
1008
+ | listener | [<code>PseudoEventListener</code>](#PseudoEventListener) |
357
1009
 
358
1010
  <a name="EventTargetService+setDefaultEvent"></a>
359
1011
 
@@ -367,6 +1019,54 @@ Register the function to run when nothing else has prevented the default for thi
367
1019
  | type | <code>string</code> |
368
1020
  | callback | <code>function</code> |
369
1021
 
1022
+ <a name="EventTargetService+addEventListener"></a>
1023
+
1024
+ ### eventTargetService.addEventListener(type, callback, [useCapture])
1025
+ Registers an event handler of a specific event type. Adding the same handler again for the same type and phase does
1026
+ nothing, like the DOM.
1027
+
1028
+ **Kind**: instance method of [<code>EventTargetService</code>](#EventTargetService)
1029
+
1030
+ | Param | Type | Default | Description |
1031
+ | --- | --- | --- | --- |
1032
+ | type | <code>string</code> | | The type of event to listen for |
1033
+ | callback | <code>function</code> \| <code>Object</code> | | The function to call (or an object with a handleEvent function) |
1034
+ | [useCapture] | <code>Object</code> \| <code>boolean</code> | <code>false</code> | Listen while the event travels down to the target (true), or an object with capture, once and passive |
1035
+
1036
+ <a name="EventTargetService+removeEventListener"></a>
1037
+
1038
+ ### eventTargetService.removeEventListener(type, callback, [options])
1039
+ Removes an event listener, the one which was added with the same type, handler and phase.
1040
+
1041
+ **Kind**: instance method of [<code>EventTargetService</code>](#EventTargetService)
1042
+
1043
+ | Param | Type | Default | Description |
1044
+ | --- | --- | --- | --- |
1045
+ | type | <code>string</code> | | The type of event |
1046
+ | callback | <code>function</code> \| <code>Object</code> | | The handler which was added |
1047
+ | [options] | <code>Object</code> \| <code>boolean</code> | <code>false</code> | Whether the listener was a capture listener (true), or an object with capture |
1048
+
1049
+ <a name="EventTargetService+dispatchEvent"></a>
1050
+
1051
+ ### eventTargetService.dispatchEvent(event) ⇒ <code>boolean</code>
1052
+ Dispatches an event to this target and through the tree: capture listeners of the ancestors from the root down,
1053
+ then the listeners of this target, then (when the event bubbles) the other listeners of the ancestors from the
1054
+ parent up to the root. stopPropagation() stops it reaching further targets, stopImmediatePropagation() also stops
1055
+ the remaining listeners of the current target. Afterwards, unless the default was prevented, the default action
1056
+ of this target (see setDefaultEvent) runs. The event can be dispatched again afterwards.
1057
+
1058
+ **Kind**: instance method of [<code>EventTargetService</code>](#EventTargetService)
1059
+ **Returns**: <code>boolean</code> - False when the event was cancelable and a listener prevented the default, otherwise true
1060
+ **Throws**:
1061
+
1062
+ - <code>Error</code> When the event is already being dispatched, or (after the whole dispatch has finished) the error
1063
+ which a listener threw (an error with all of them in its errors property when several did)
1064
+
1065
+
1066
+ | Param | Type | Description |
1067
+ | --- | --- | --- |
1068
+ | event | [<code>EventService</code>](#EventService) | The event to dispatch |
1069
+
370
1070
  <a name="EventService"></a>
371
1071
 
372
1072
  ## EventService
@@ -412,9 +1112,9 @@ Simulate the behaviour of the Event Class when there is no DOM available.
412
1112
  | --- | --- | --- |
413
1113
  | typeArg | <code>string</code> | |
414
1114
  | [eventOptions] | <code>Object</code> | <code>{}</code> |
415
- | [eventOptions.bubbles] | <code>boolean</code> | <code>true</code> |
416
- | [eventOptions.cancelable] | <code>boolean</code> | <code>true</code> |
417
- | [eventOptions.composed] | <code>boolean</code> | <code>true</code> |
1115
+ | [eventOptions.bubbles] | <code>boolean</code> | <code>false</code> |
1116
+ | [eventOptions.cancelable] | <code>boolean</code> | <code>false</code> |
1117
+ | [eventOptions.composed] | <code>boolean</code> | <code>false</code> |
418
1118
 
419
1119
  <a name="EventService+inner"></a>
420
1120
 
@@ -844,6 +1544,75 @@ Simulate the behaviour of the DOMTokenList Class when there is no DOM available.
844
1544
  | [value] | <code>string</code> | <code>&quot;&#x27;&#x27;&quot;</code> | The space separated tokens to start with |
845
1545
  | [onChange] | <code>function</code> | | Called with the new value whenever the tokens change |
846
1546
 
1547
+ <a name="CustomEventService"></a>
1548
+
1549
+ ## CustomEventService ⇐ [<code>EventService</code>](#EventService)
1550
+ Simulate the behaviour of the CustomEvent Class when there is no DOM available: an event which carries data.
1551
+
1552
+ **Kind**: global class
1553
+ **Extends**: [<code>EventService</code>](#EventService)
1554
+ **Author**: Joshua Heagle <joshuaheagle@gmail.com>
1555
+ **Properties**
1556
+
1557
+ | Name | Type |
1558
+ | --- | --- |
1559
+ | detail | <code>\*</code> |
1560
+
1561
+
1562
+ * [CustomEventService](#CustomEventService) ⇐ [<code>EventService</code>](#EventService)
1563
+ * [new CustomEventService([typeArg], [init])](#new_CustomEventService_new)
1564
+ * [.inner](#EventService+inner) ⇒ <code>EventInner</code>
1565
+ * [.composedPath()](#EventService+composedPath) ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
1566
+ * [.preventDefault()](#EventService+preventDefault) ⇒ <code>null</code>
1567
+ * [.stopImmediatePropagation()](#EventService+stopImmediatePropagation) ⇒ <code>null</code>
1568
+ * [.stopPropagation()](#EventService+stopPropagation) ⇒ <code>null</code>
1569
+
1570
+ <a name="new_CustomEventService_new"></a>
1571
+
1572
+ ### new CustomEventService([typeArg], [init])
1573
+
1574
+ | Param | Type | Default | Description |
1575
+ | --- | --- | --- | --- |
1576
+ | [typeArg] | <code>string</code> | <code>&quot;&#x27;&#x27;&quot;</code> | The type of the event |
1577
+ | [init] | <code>CustomEventInit</code> | <code>{}</code> | The options for the event |
1578
+
1579
+ <a name="EventService+inner"></a>
1580
+
1581
+ ### customEventService.inner ⇒ <code>EventInner</code>
1582
+ Scope several accessors inside the inner object. These are only intended for usage by other DOM classes.
1583
+
1584
+ **Kind**: instance property of [<code>CustomEventService</code>](#CustomEventService)
1585
+ **Overrides**: [<code>inner</code>](#EventService+inner)
1586
+ <a name="EventService+composedPath"></a>
1587
+
1588
+ ### customEventService.composedPath() ⇒ <code>Array.&lt;PseudoEventTarget&gt;</code>
1589
+ Return an array of targets that will have the event executed open them. The order is based on the eventPhase
1590
+
1591
+ **Kind**: instance method of [<code>CustomEventService</code>](#CustomEventService)
1592
+ **Overrides**: [<code>composedPath</code>](#EventService+composedPath)
1593
+ <a name="EventService+preventDefault"></a>
1594
+
1595
+ ### customEventService.preventDefault() ⇒ <code>null</code>
1596
+ Cancels the event (if it is cancelable).
1597
+
1598
+ **Kind**: instance method of [<code>CustomEventService</code>](#CustomEventService)
1599
+ **Overrides**: [<code>preventDefault</code>](#EventService+preventDefault)
1600
+ <a name="EventService+stopImmediatePropagation"></a>
1601
+
1602
+ ### customEventService.stopImmediatePropagation() ⇒ <code>null</code>
1603
+ For this particular event, no other listener will be called.
1604
+ Neither those attached on the same element, nor those attached on elements which will be traversed later (in
1605
+ capture phase, for instance)
1606
+
1607
+ **Kind**: instance method of [<code>CustomEventService</code>](#CustomEventService)
1608
+ **Overrides**: [<code>stopImmediatePropagation</code>](#EventService+stopImmediatePropagation)
1609
+ <a name="EventService+stopPropagation"></a>
1610
+
1611
+ ### customEventService.stopPropagation() ⇒ <code>null</code>
1612
+ Stops the propagation of events further along in the Dom.
1613
+
1614
+ **Kind**: instance method of [<code>CustomEventService</code>](#CustomEventService)
1615
+ **Overrides**: [<code>stopPropagation</code>](#EventService+stopPropagation)
847
1616
  <a name="AttrService"></a>
848
1617
 
849
1618
  ## AttrService ⇐ [<code>NodeService</code>](#NodeService)
@@ -1258,22 +2027,52 @@ Handle events as they are stored and implemented.
1258
2027
 
1259
2028
 
1260
2029
  * [PseudoEventListener](#PseudoEventListener)
2030
+ * [new PseudoEventListener(eventType, [options], handleEvent, [originalCallback])](#new_PseudoEventListener_new)
1261
2031
  * [.callback](#PseudoEventListener+callback)
2032
+ * [.capture](#PseudoEventListener+capture)
2033
+ * [.passive](#PseudoEventListener+passive)
2034
+ * [.removed](#PseudoEventListener+removed)
1262
2035
  * [.handleEvent(event)](#PseudoEventListener+handleEvent) ⇒ <code>\*</code>
1263
2036
  * [.doCapturePhase(event)](#PseudoEventListener+doCapturePhase) ⇒ <code>boolean</code>
1264
2037
  * [.doTargetPhase(event)](#PseudoEventListener+doTargetPhase) ⇒ <code>boolean</code>
1265
- * [.doBubblePhase(event)](#PseudoEventListener+doBubblePhase) ⇒ <code>boolean</code> \| <code>\*</code>
2038
+ * [.doBubblePhase(event)](#PseudoEventListener+doBubblePhase) ⇒ <code>boolean</code>
1266
2039
  * [.skipPhase(event)](#PseudoEventListener+skipPhase) ⇒ <code>boolean</code>
1267
- * [.skipDefault(event)](#PseudoEventListener+skipDefault) ⇒ <code>boolean</code> \| <code>\*</code>
1268
- * [.stopPropagation(event)](#PseudoEventListener+stopPropagation) ⇒ <code>boolean</code>
1269
- * [.nonPassiveHalt(event)](#PseudoEventListener+nonPassiveHalt) ⇒ <code>boolean</code> \| <code>\*</code>
1270
- * [.rejectEvent(event)](#PseudoEventListener+rejectEvent) ⇒ <code>\*</code> \| <code>boolean</code>
2040
+ * [.rejectEvent(event)](#PseudoEventListener+rejectEvent) ⇒ <code>boolean</code>
2041
+
2042
+ <a name="new_PseudoEventListener_new"></a>
2043
+
2044
+ ### new PseudoEventListener(eventType, [options], handleEvent, [originalCallback])
2045
+
2046
+ | Param | Type | Default | Description |
2047
+ | --- | --- | --- | --- |
2048
+ | eventType | <code>string</code> | | The type of event this listens for |
2049
+ | [options] | <code>Object</code> | | The capture, once and passive options |
2050
+ | handleEvent | <code>function</code> | | The function which is called with the event, already bound to what it should run as |
2051
+ | [originalCallback] | <code>function</code> | <code>handleEvent</code> | The function (or object) which was given when registering, used to find this listener again |
1271
2052
 
1272
2053
  <a name="PseudoEventListener+callback"></a>
1273
2054
 
1274
2055
  ### pseudoEventListener.callback
1275
2056
  The function (or object with handleEvent) which was originally given when registering, used to find this listener again for removal.
1276
2057
 
2058
+ **Kind**: instance property of [<code>PseudoEventListener</code>](#PseudoEventListener)
2059
+ <a name="PseudoEventListener+capture"></a>
2060
+
2061
+ ### pseudoEventListener.capture
2062
+ Whether this listener listens in the capture phase (and at the target) rather than in the bubble phase.
2063
+
2064
+ **Kind**: instance property of [<code>PseudoEventListener</code>](#PseudoEventListener)
2065
+ <a name="PseudoEventListener+passive"></a>
2066
+
2067
+ ### pseudoEventListener.passive
2068
+ Whether the listener promises not to prevent the default (preventDefault does nothing while it runs).
2069
+
2070
+ **Kind**: instance property of [<code>PseudoEventListener</code>](#PseudoEventListener)
2071
+ <a name="PseudoEventListener+removed"></a>
2072
+
2073
+ ### pseudoEventListener.removed
2074
+ Whether this listener has been removed, a removed listener does not run even if the event already started.
2075
+
1277
2076
  **Kind**: instance property of [<code>PseudoEventListener</code>](#PseudoEventListener)
1278
2077
  <a name="PseudoEventListener+handleEvent"></a>
1279
2078
 
@@ -1287,6 +2086,8 @@ The function (or object with handleEvent) which was originally given when regist
1287
2086
  <a name="PseudoEventListener+doCapturePhase"></a>
1288
2087
 
1289
2088
  ### pseudoEventListener.doCapturePhase(event) ⇒ <code>boolean</code>
2089
+ A capture listener runs while the event travels down to the target.
2090
+
1290
2091
  **Kind**: instance method of [<code>PseudoEventListener</code>](#PseudoEventListener)
1291
2092
 
1292
2093
  | Param | Type |
@@ -1296,6 +2097,8 @@ The function (or object with handleEvent) which was originally given when regist
1296
2097
  <a name="PseudoEventListener+doTargetPhase"></a>
1297
2098
 
1298
2099
  ### pseudoEventListener.doTargetPhase(event) ⇒ <code>boolean</code>
2100
+ Every listener of the target itself runs, capture listeners first.
2101
+
1299
2102
  **Kind**: instance method of [<code>PseudoEventListener</code>](#PseudoEventListener)
1300
2103
 
1301
2104
  | Param | Type |
@@ -1304,7 +2107,9 @@ The function (or object with handleEvent) which was originally given when regist
1304
2107
 
1305
2108
  <a name="PseudoEventListener+doBubblePhase"></a>
1306
2109
 
1307
- ### pseudoEventListener.doBubblePhase(event) ⇒ <code>boolean</code> \| <code>\*</code>
2110
+ ### pseudoEventListener.doBubblePhase(event) ⇒ <code>boolean</code>
2111
+ A listener which is not a capture listener runs while the event travels back up (when it bubbles).
2112
+
1308
2113
  **Kind**: instance method of [<code>PseudoEventListener</code>](#PseudoEventListener)
1309
2114
 
1310
2115
  | Param | Type |
@@ -1320,46 +2125,61 @@ The function (or object with handleEvent) which was originally given when regist
1320
2125
  | --- | --- |
1321
2126
  | event | <code>PseudoEvent</code> |
1322
2127
 
1323
- <a name="PseudoEventListener+skipDefault"></a>
2128
+ <a name="PseudoEventListener+rejectEvent"></a>
2129
+
2130
+ ### pseudoEventListener.rejectEvent(event) ⇒ <code>boolean</code>
2131
+ Whether this listener should not run for the event as it is now (it was removed, or it is for another phase).
2132
+ Stopping propagation is handled by the dispatching, since it stops other targets and not the listeners of the
2133
+ current one.
1324
2134
 
1325
- ### pseudoEventListener.skipDefault(event) ⇒ <code>boolean</code> \| <code>\*</code>
1326
2135
  **Kind**: instance method of [<code>PseudoEventListener</code>](#PseudoEventListener)
1327
2136
 
1328
2137
  | Param | Type |
1329
2138
  | --- | --- |
1330
2139
  | event | <code>PseudoEvent</code> |
1331
2140
 
1332
- <a name="PseudoEventListener+stopPropagation"></a>
2141
+ <a name="eventDefaults"></a>
1333
2142
 
1334
- ### pseudoEventListener.stopPropagation(event) <code>boolean</code>
1335
- **Kind**: instance method of [<code>PseudoEventListener</code>](#PseudoEventListener)
2143
+ ## eventDefaults : <code>Object.&lt;string, EventDefinition&gt;</code>
2144
+ The events which the browser itself creates (for a user action, or for something like element.click()) have these
2145
+ options. A script which creates an event with the constructor gets none of them (everything is false) unless it asks
2146
+ for them, which is why createEvent only uses this table when it is told the browser is creating the event.
2147
+ The values follow the UI Events, HTML, Pointer Events, Clipboard, Drag and Drop, Touch and CSS specifications.
1336
2148
 
1337
- | Param | Type |
1338
- | --- | --- |
1339
- | event | <code>PseudoEvent</code> |
2149
+ **Kind**: global variable
2150
+ <a name="focused"></a>
1340
2151
 
1341
- <a name="PseudoEventListener+nonPassiveHalt"></a>
2152
+ ## focused
2153
+ The element which has the focus, kept for each tree (the root node of the tree it is in), like document.activeElement.
1342
2154
 
1343
- ### pseudoEventListener.nonPassiveHalt(event) ⇒ <code>boolean</code> \| <code>\*</code>
1344
- **Kind**: instance method of [<code>PseudoEventListener</code>](#PseudoEventListener)
2155
+ **Kind**: global constant
2156
+ <a name="HTMLElementService_1"></a>
1345
2157
 
1346
- | Param | Type |
1347
- | --- | --- |
1348
- | event | <code>PseudoEvent</code> |
2158
+ ## HTMLElementService\_1 : <code>PseudoHTMLElement</code>
2159
+ **Kind**: global constant
2160
+ <a name="modifierKeys"></a>
1349
2161
 
1350
- <a name="PseudoEventListener+rejectEvent"></a>
2162
+ ## modifierKeys([init]) ⇒ <code>ModifierKeys</code>
2163
+ Pick the modifier keys out of the init object of an event.
1351
2164
 
1352
- ### pseudoEventListener.rejectEvent(event) ⇒ <code>\*</code> \| <code>boolean</code>
1353
- **Kind**: instance method of [<code>PseudoEventListener</code>](#PseudoEventListener)
2165
+ **Kind**: global function
1354
2166
 
1355
- | Param | Type |
1356
- | --- | --- |
1357
- | event | <code>PseudoEvent</code> |
2167
+ | Param | Type | Default | Description |
2168
+ | --- | --- | --- | --- |
2169
+ | [init] | <code>Object</code> | <code>{}</code> | The init of an event |
1358
2170
 
1359
- <a name="HTMLElementService_1"></a>
2171
+ <a name="modifierState"></a>
2172
+
2173
+ ## modifierState(keys, key) ⇒ <code>boolean</code>
2174
+ Answer getModifierState for a set of held modifier keys.
2175
+
2176
+ **Kind**: global function
2177
+
2178
+ | Param | Type | Description |
2179
+ | --- | --- | --- |
2180
+ | keys | <code>ModifierKeys</code> | The modifier keys which were held down |
2181
+ | key | <code>string</code> | The name of the modifier (Control, Shift, Alt or Meta) |
1360
2182
 
1361
- ## HTMLElementService\_1 : <code>PseudoHTMLElement</code>
1362
- **Kind**: global constant
1363
2183
  <a name="getParentNodesFromAttribute"></a>
1364
2184
 
1365
2185
  ## getParentNodesFromAttribute(attr, value, node) ⇒ <code>Array.&lt;PseudoNode&gt;</code>
@@ -1387,6 +2207,29 @@ order in which an event travels down through them). A node which has no parent h
1387
2207
  | --- | --- | --- |
1388
2208
  | node | <code>PseudoEventTarget</code> \| <code>PseudoNode</code> \| <code>\*</code> | The node to find the ancestors of |
1389
2209
 
2210
+ <a name="getActiveElement"></a>
2211
+
2212
+ ## getActiveElement(root) ⇒ <code>Object</code> \| <code>null</code>
2213
+ Find the element which has the focus in a tree.
2214
+
2215
+ **Kind**: global function
2216
+
2217
+ | Param | Type | Description |
2218
+ | --- | --- | --- |
2219
+ | root | <code>Object</code> | The root node of the tree |
2220
+
2221
+ <a name="setActiveElement"></a>
2222
+
2223
+ ## setActiveElement(root, element)
2224
+ Remember the element which has the focus in a tree.
2225
+
2226
+ **Kind**: global function
2227
+
2228
+ | Param | Type | Description |
2229
+ | --- | --- | --- |
2230
+ | root | <code>Object</code> | The root node of the tree |
2231
+ | element | <code>Object</code> \| <code>null</code> | The element which now has the focus, or null when nothing has it |
2232
+
1390
2233
  <a name="generateNodeList"></a>
1391
2234
 
1392
2235
  ## generateNodeList([innerList]) ⇒ [<code>PseudoNodeList</code>](#PseudoNodeList)
@@ -1451,3 +2294,20 @@ Create an instance of HTMLElement if not available
1451
2294
  Define document when not available
1452
2295
 
1453
2296
  **Kind**: inner constant of [<code>generateDocument</code>](#generateDocument)
2297
+ <a name="createEvent"></a>
2298
+
2299
+ ## createEvent(type, [init], [options]) ⇒ [<code>EventService</code>](#EventService)
2300
+ Create an event of the kind which suits its type (a click is a MouseEvent, a keydown a KeyboardEvent, ...).
2301
+ By default this is like using the constructor of the event in a script: nothing bubbles or can be cancelled unless
2302
+ the init says so, and the event is not trusted. With browser: true the event is created the way the browser creates
2303
+ it, using the standard options for its type (see eventDefaults), and trusted: true makes it look like it came from a
2304
+ real user action (isTrusted).
2305
+
2306
+ **Kind**: global function
2307
+
2308
+ | Param | Type | Default | Description |
2309
+ | --- | --- | --- | --- |
2310
+ | type | <code>string</code> | | The type of the event, such as click |
2311
+ | [init] | <code>Object</code> | <code>{}</code> | The options for the event (bubbles, cancelable, composed and those of its kind of event) |
2312
+ | [options] | <code>CreateEventOptions</code> | <code>{}</code> | Whether the browser is creating the event, and whether it is trusted |
2313
+