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.
Files changed (97) hide show
  1. package/README.md +63 -5869
  2. package/browser/pseudo-dom.js +14889 -15288
  3. package/dist/classes/PseudoEventListener.d.ts +11 -37
  4. package/dist/classes/PseudoEventListener.js +11 -37
  5. package/dist/classes/PseudoHTMLDocument.d.ts +4 -12
  6. package/dist/classes/PseudoHTMLDocument.js +1 -11
  7. package/dist/classes/PseudoNodeList.d.ts +1 -9
  8. package/dist/classes/PseudoNodeList.js +1 -9
  9. package/dist/factories/createDataset.d.ts +1 -3
  10. package/dist/factories/createDataset.js +3 -8
  11. package/dist/factories/createEvent.d.ts +5 -9
  12. package/dist/factories/createEvent.js +3 -5
  13. package/dist/factories/createStyleDeclaration.d.ts +4 -10
  14. package/dist/factories/createStyleDeclaration.js +4 -10
  15. package/dist/factories/cssSelectAdapter.d.ts +0 -2
  16. package/dist/factories/cssSelectAdapter.js +3 -8
  17. package/dist/factories/eventDefaults.d.ts +5 -9
  18. package/dist/factories/eventDefaults.js +1 -4
  19. package/dist/factories/generateDocument.d.ts +2 -4
  20. package/dist/factories/generateDocument.js +2 -13
  21. package/dist/factories/generateNodeList.d.ts +1 -2
  22. package/dist/factories/generateNodeList.js +1 -2
  23. package/dist/factories/installGlobal.d.ts +2 -3
  24. package/dist/factories/installGlobal.js +3 -6
  25. package/dist/factories/logElement.d.ts +2 -4
  26. package/dist/factories/logElement.js +3 -7
  27. package/dist/factories/parseHTML.d.ts +3 -5
  28. package/dist/factories/parseHTML.js +4 -8
  29. package/dist/factories/query.d.ts +8 -16
  30. package/dist/factories/query.js +9 -19
  31. package/dist/factories/serializeHTML.d.ts +4 -10
  32. package/dist/factories/serializeHTML.js +12 -25
  33. package/dist/functions/activeElement.d.ts +3 -6
  34. package/dist/functions/activeElement.js +3 -6
  35. package/dist/functions/getElementById.d.ts +2 -4
  36. package/dist/functions/getElementById.js +2 -4
  37. package/dist/functions/getParentNodes.d.ts +1 -3
  38. package/dist/functions/getParentNodes.js +1 -3
  39. package/dist/functions/getParentNodesFromAttribute.d.ts +3 -5
  40. package/dist/functions/getParentNodesFromAttribute.js +3 -5
  41. package/dist/functions/modifierState.d.ts +3 -12
  42. package/dist/functions/modifierState.js +3 -7
  43. package/dist/interfaces/PseudoCSSStyleDeclaration.d.ts +1 -1
  44. package/dist/interfaces/PseudoDocument.d.ts +4 -9
  45. package/dist/interfaces/PseudoDocumentFragment.d.ts +1 -2
  46. package/dist/interfaces/PseudoElement.d.ts +39 -78
  47. package/dist/interfaces/PseudoEvent.d.ts +11 -43
  48. package/dist/interfaces/PseudoEvent.js +1 -3
  49. package/dist/interfaces/PseudoEventTarget.d.ts +7 -16
  50. package/dist/interfaces/PseudoHTMLCollection.d.ts +2 -4
  51. package/dist/interfaces/PseudoHTMLElement.d.ts +8 -13
  52. package/dist/interfaces/PseudoNode.d.ts +3 -13
  53. package/dist/main.d.ts +1 -6
  54. package/dist/main.js +1 -6
  55. package/dist/services/AttrService.d.ts +5 -9
  56. package/dist/services/AttrService.js +5 -9
  57. package/dist/services/CSSStyleDeclarationService.d.ts +10 -23
  58. package/dist/services/CSSStyleDeclarationService.js +10 -23
  59. package/dist/services/CustomEventService.d.ts +4 -15
  60. package/dist/services/CustomEventService.js +3 -10
  61. package/dist/services/DOMTokenListService.d.ts +2 -5
  62. package/dist/services/DOMTokenListService.js +2 -5
  63. package/dist/services/DocumentFragmentService.d.ts +1 -5
  64. package/dist/services/DocumentFragmentService.js +1 -5
  65. package/dist/services/DocumentService.d.ts +4 -12
  66. package/dist/services/DocumentService.js +4 -12
  67. package/dist/services/ElementService.d.ts +62 -120
  68. package/dist/services/ElementService.js +61 -117
  69. package/dist/services/EventService.d.ts +6 -44
  70. package/dist/services/EventService.js +18 -44
  71. package/dist/services/EventTargetService.d.ts +16 -28
  72. package/dist/services/EventTargetService.js +16 -28
  73. package/dist/services/FocusEventService.d.ts +4 -12
  74. package/dist/services/FocusEventService.js +3 -10
  75. package/dist/services/HTMLCollectionService.d.ts +6 -16
  76. package/dist/services/HTMLCollectionService.js +6 -16
  77. package/dist/services/HTMLElementService.d.ts +132 -154
  78. package/dist/services/HTMLElementService.js +333 -353
  79. package/dist/services/InputEventService.d.ts +5 -16
  80. package/dist/services/InputEventService.js +3 -12
  81. package/dist/services/KeyboardEventService.d.ts +8 -26
  82. package/dist/services/KeyboardEventService.js +4 -16
  83. package/dist/services/MouseEventService.d.ts +7 -30
  84. package/dist/services/MouseEventService.js +4 -18
  85. package/dist/services/NamedNodeMapService.d.ts +1 -4
  86. package/dist/services/NamedNodeMapService.js +1 -4
  87. package/dist/services/NodeService.d.ts +38 -69
  88. package/dist/services/NodeService.js +39 -72
  89. package/dist/services/PointerEventService.d.ts +4 -22
  90. package/dist/services/PointerEventService.js +3 -15
  91. package/dist/services/ShadowRootService.d.ts +0 -3
  92. package/dist/services/ShadowRootService.js +0 -3
  93. package/dist/services/UIEventService.d.ts +5 -17
  94. package/dist/services/UIEventService.js +3 -11
  95. package/dist/simulate.d.ts +7 -9
  96. package/dist/simulate.js +9 -15
  97. package/package.json +8 -7
@@ -1,16 +1,9 @@
1
1
  /**
2
- * @file Substitute for the DOM EventEventListener Class.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.0.0
2
+ * Substitute for the DOM EventEventListener Class.
5
3
  */
6
4
  import { EventService } from '../services/EventService';
7
5
  /**
8
6
  * Handle events as they are stored and implemented.
9
- * @author Joshua Heagle <joshuaheagle@gmail.com>
10
- * @class
11
- * @property {string} eventType
12
- * @property {Object} eventOptions
13
- * @property {boolean} isDefault
14
7
  */
15
8
  declare class PseudoEventListener {
16
9
  private eventOptions;
@@ -20,11 +13,10 @@ declare class PseudoEventListener {
20
13
  private readonly defaultListener;
21
14
  private isRemoved;
22
15
  /**
23
- * @param {string} eventType The type of event this listens for
24
- * @param {Object} [options] The capture, once and passive options
25
- * @param {Function} handleEvent The function which is called with the event, already bound to what it should run as
26
- * @param {Function} [originalCallback=handleEvent] The function (or object) which was given when registering, used to find this listener again
27
- * @constructor
16
+ * @param eventType The type of event this listens for
17
+ * @param options The capture, once and passive options
18
+ * @param handleEvent The function which is called with the event, already bound to what it should run as
19
+ * @param originalCallback The function (or object) which was given when registering, used to find this listener again
28
20
  */
29
21
  constructor(eventType: string, { capture, once, passive }: {
30
22
  capture?: boolean;
@@ -45,51 +37,33 @@ declare class PseudoEventListener {
45
37
  get removed(): boolean;
46
38
  set removed(removed: boolean);
47
39
  /**
48
- * @method
49
- * @name PseudoEventListener#handleEvent
50
- * @param {PseudoEvent} event
51
- * @returns {*}
40
+ * @param event
52
41
  */
53
42
  handleEvent(event: EventService): any;
54
43
  /**
55
44
  * A capture listener runs while the event travels down to the target.
56
- * @method
57
- * @name PseudoEventListener#doCapturePhase
58
- * @param {PseudoEvent} event
59
- * @returns {boolean}
45
+ * @param event
60
46
  */
61
47
  doCapturePhase(event: EventService): boolean;
62
48
  /**
63
49
  * Every listener of the target itself runs, capture listeners first.
64
- * @method
65
- * @name PseudoEventListener#doTargetPhase
66
- * @param {PseudoEvent} event
67
- * @returns {boolean}
50
+ * @param event
68
51
  */
69
52
  doTargetPhase(event: EventService): boolean;
70
53
  /**
71
54
  * A listener which is not a capture listener runs while the event travels back up (when it bubbles).
72
- * @method
73
- * @name PseudoEventListener#doBubblePhase
74
- * @param {PseudoEvent} event
75
- * @returns {boolean}
55
+ * @param event
76
56
  */
77
57
  doBubblePhase(event: EventService): boolean;
78
58
  /**
79
- * @method
80
- * @name PseudoEventListener#skipPhase
81
- * @param {PseudoEvent} event
82
- * @returns {boolean}
59
+ * @param event
83
60
  */
84
61
  skipPhase(event: EventService): boolean;
85
62
  /**
86
63
  * Whether this listener should not run for the event as it is now (it was removed, or it is for another phase).
87
64
  * Stopping propagation is handled by the dispatching, since it stops other targets and not the listeners of the
88
65
  * current one.
89
- * @method
90
- * @name PseudoEventListener#rejectEvent
91
- * @param {PseudoEvent} event
92
- * @returns {boolean}
66
+ * @param event
93
67
  */
94
68
  rejectEvent(event: EventService): boolean;
95
69
  }
@@ -4,26 +4,18 @@ Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  })
6
6
  /**
7
- * @file Substitute for the DOM EventEventListener Class.
8
- * @author Joshua Heagle <joshuaheagle@gmail.com>
9
- * @version 1.0.0
7
+ * Substitute for the DOM EventEventListener Class.
10
8
  */
11
9
  const EventService_1 = require('../services/EventService')
12
10
  /**
13
11
  * Handle events as they are stored and implemented.
14
- * @author Joshua Heagle <joshuaheagle@gmail.com>
15
- * @class
16
- * @property {string} eventType
17
- * @property {Object} eventOptions
18
- * @property {boolean} isDefault
19
12
  */
20
13
  class PseudoEventListener {
21
14
  /**
22
- * @param {string} eventType The type of event this listens for
23
- * @param {Object} [options] The capture, once and passive options
24
- * @param {Function} handleEvent The function which is called with the event, already bound to what it should run as
25
- * @param {Function} [originalCallback=handleEvent] The function (or object) which was given when registering, used to find this listener again
26
- * @constructor
15
+ * @param eventType The type of event this listens for
16
+ * @param options The capture, once and passive options
17
+ * @param handleEvent The function which is called with the event, already bound to what it should run as
18
+ * @param originalCallback The function (or object) which was given when registering, used to find this listener again
27
19
  */
28
20
  constructor (eventType, {
29
21
  capture = false,
@@ -83,10 +75,7 @@ class PseudoEventListener {
83
75
  }
84
76
 
85
77
  /**
86
- * @method
87
- * @name PseudoEventListener#handleEvent
88
- * @param {PseudoEvent} event
89
- * @returns {*}
78
+ * @param event
90
79
  */
91
80
  handleEvent (event) {
92
81
  return this.handler(event)
@@ -94,10 +83,7 @@ class PseudoEventListener {
94
83
 
95
84
  /**
96
85
  * A capture listener runs while the event travels down to the target.
97
- * @method
98
- * @name PseudoEventListener#doCapturePhase
99
- * @param {PseudoEvent} event
100
- * @returns {boolean}
86
+ * @param event
101
87
  */
102
88
  doCapturePhase (event) {
103
89
  return event.eventPhase === EventService_1.EventService.CAPTURING_PHASE && this.eventOptions.capture
@@ -105,10 +91,7 @@ class PseudoEventListener {
105
91
 
106
92
  /**
107
93
  * Every listener of the target itself runs, capture listeners first.
108
- * @method
109
- * @name PseudoEventListener#doTargetPhase
110
- * @param {PseudoEvent} event
111
- * @returns {boolean}
94
+ * @param event
112
95
  */
113
96
  doTargetPhase (event) {
114
97
  return event.eventPhase === EventService_1.EventService.AT_TARGET
@@ -116,20 +99,14 @@ class PseudoEventListener {
116
99
 
117
100
  /**
118
101
  * A listener which is not a capture listener runs while the event travels back up (when it bubbles).
119
- * @method
120
- * @name PseudoEventListener#doBubblePhase
121
- * @param {PseudoEvent} event
122
- * @returns {boolean}
102
+ * @param event
123
103
  */
124
104
  doBubblePhase (event) {
125
105
  return event.eventPhase === EventService_1.EventService.BUBBLING_PHASE && !this.eventOptions.capture
126
106
  }
127
107
 
128
108
  /**
129
- * @method
130
- * @name PseudoEventListener#skipPhase
131
- * @param {PseudoEvent} event
132
- * @returns {boolean}
109
+ * @param event
133
110
  */
134
111
  skipPhase (event) {
135
112
  return !this.doCapturePhase(event) && !this.doTargetPhase(event) && !this.doBubblePhase(event)
@@ -139,10 +116,7 @@ class PseudoEventListener {
139
116
  * Whether this listener should not run for the event as it is now (it was removed, or it is for another phase).
140
117
  * Stopping propagation is handled by the dispatching, since it stops other targets and not the listeners of the
141
118
  * current one.
142
- * @method
143
- * @name PseudoEventListener#rejectEvent
144
- * @param {PseudoEvent} event
145
- * @returns {boolean}
119
+ * @param event
146
120
  */
147
121
  rejectEvent (event) {
148
122
  return this.isRemoved || this.skipPhase(event)
@@ -1,7 +1,5 @@
1
1
  /**
2
- * @file Substitute for the DOM HTMLDocument Class.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.0.0
2
+ * Substitute for the DOM HTMLDocument Class.
5
3
  */
6
4
  import { HTMLElementService as PseudoHTMLElement } from '../services/HTMLElementService';
7
5
  import { DocumentService } from '../services/DocumentService';
@@ -10,31 +8,25 @@ import { NodeService } from '../services/NodeService';
10
8
  * Simulate the behaviour of the HTMLDocument Class when there is no DOM available. Like the real HTMLDocument, this
11
9
  * only adds the html/head/body structure on top of what Document already gives (createElement, createTextNode,
12
10
  * createComment, createDocumentFragment, getElementById, textContent always null).
13
- * @author Joshua Heagle <joshuaheagle@gmail.com>
14
- * @class
15
- * @augments DocumentService
16
- * @property {PseudoHTMLElement} head - A reference to the Head child element
17
- * @property {PseudoHTMLElement} body - A reference to the Body child element
18
11
  */
19
12
  declare class PseudoHTMLDocument extends DocumentService {
13
+ /** A reference to the Head child element */
20
14
  head: PseudoHTMLElement | null;
15
+ /** A reference to the Body child element */
21
16
  body: PseudoHTMLElement | null;
22
17
  /**
23
18
  * The root HTML element is acts as the parent to all HTML elements in the document.
24
- * @constructor
25
19
  */
26
20
  constructor();
27
21
  /**
28
22
  * A copy of this document with none of its html/head/body (cloneNode, from the inherited cloneShallow hook, fills
29
23
  * them back in, deep copies own document's, empty otherwise - see cloneNode).
30
- * @returns {PseudoHTMLDocument}
31
24
  */
32
25
  protected cloneShallow(): NodeService;
33
26
  /**
34
27
  * Make a copy of this document. The copy has no parent or listeners, and a deep copy has copies of everything in
35
28
  * the document (a shallow one is an empty document).
36
- * @param {boolean} [deep=false] Copy everything in the document as well
37
- * @returns {PseudoHTMLDocument}
29
+ * @param deep Copy everything in the document as well
38
30
  */
39
31
  cloneNode(deep?: boolean): PseudoHTMLDocument;
40
32
  }
@@ -10,16 +10,10 @@ const DocumentService_1 = require('../services/DocumentService')
10
10
  * Simulate the behaviour of the HTMLDocument Class when there is no DOM available. Like the real HTMLDocument, this
11
11
  * only adds the html/head/body structure on top of what Document already gives (createElement, createTextNode,
12
12
  * createComment, createDocumentFragment, getElementById, textContent always null).
13
- * @author Joshua Heagle <joshuaheagle@gmail.com>
14
- * @class
15
- * @augments DocumentService
16
- * @property {PseudoHTMLElement} head - A reference to the Head child element
17
- * @property {PseudoHTMLElement} body - A reference to the Body child element
18
13
  */
19
14
  class PseudoHTMLDocument extends DocumentService_1.DocumentService {
20
15
  /**
21
16
  * The root HTML element is acts as the parent to all HTML elements in the document.
22
- * @constructor
23
17
  */
24
18
  constructor () {
25
19
  super()
@@ -27,13 +21,11 @@ class PseudoHTMLDocument extends DocumentService_1.DocumentService {
27
21
  this.appendChild(html)
28
22
  /**
29
23
  * Create document head element
30
- * @type {PseudoHTMLElement}
31
24
  */
32
25
  this.head = this.createElement('head')
33
26
  html.appendChild(this.head)
34
27
  /**
35
28
  * Create document body element
36
- * @type {PseudoHTMLElement}
37
29
  */
38
30
  this.body = this.createElement('body')
39
31
  html.appendChild(this.body)
@@ -42,7 +34,6 @@ class PseudoHTMLDocument extends DocumentService_1.DocumentService {
42
34
  /**
43
35
  * A copy of this document with none of its html/head/body (cloneNode, from the inherited cloneShallow hook, fills
44
36
  * them back in, deep copies own document's, empty otherwise - see cloneNode).
45
- * @returns {PseudoHTMLDocument}
46
37
  */
47
38
  cloneShallow () {
48
39
  const copy = new this.constructor()
@@ -57,8 +48,7 @@ class PseudoHTMLDocument extends DocumentService_1.DocumentService {
57
48
  /**
58
49
  * Make a copy of this document. The copy has no parent or listeners, and a deep copy has copies of everything in
59
50
  * the document (a shallow one is an empty document).
60
- * @param {boolean} [deep=false] Copy everything in the document as well
61
- * @returns {PseudoHTMLDocument}
51
+ * @param deep Copy everything in the document as well
62
52
  */
63
53
  cloneNode (deep = false) {
64
54
  const copy = super.cloneNode(deep)
@@ -1,34 +1,26 @@
1
1
  /**
2
- * @file Substitute for the NodeList interface.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.0.0
2
+ * Substitute for the NodeList interface.
5
3
  */
6
4
  import { LinkedTreeList } from 'collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList';
7
5
  /**
8
6
  * A NodeList, like the DOM one, iterates over the nodes themselves (the data stored in each TreeLinker), rather than
9
7
  * the linkers that hold them.
10
- * @class
11
- * @augments LinkedTreeList
12
8
  */
13
9
  export declare class PseudoNodeList extends LinkedTreeList {
14
10
  /**
15
11
  * Iterate over the nodes in this list.
16
- * @returns {Iterator}
17
12
  */
18
13
  [Symbol.iterator](): Iterator<any>;
19
14
  /**
20
15
  * Iterate over [index, node] pairs.
21
- * @returns {Iterator}
22
16
  */
23
17
  entries(): Iterator<[number, any]>;
24
18
  /**
25
19
  * Iterate over the indexes.
26
- * @returns {Iterator}
27
20
  */
28
21
  keys(): Iterator<number>;
29
22
  /**
30
23
  * Iterate over the nodes.
31
- * @returns {Iterator}
32
24
  */
33
25
  values(): Iterator<any>;
34
26
  }
@@ -7,21 +7,16 @@ Object.defineProperty(exports, '__esModule', {
7
7
  })
8
8
  exports.PseudoNodeList = void 0
9
9
  /**
10
- * @file Substitute for the NodeList interface.
11
- * @author Joshua Heagle <joshuaheagle@gmail.com>
12
- * @version 1.0.0
10
+ * Substitute for the NodeList interface.
13
11
  */
14
12
  const LinkedTreeList_1 = require('collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList')
15
13
  /**
16
14
  * A NodeList, like the DOM one, iterates over the nodes themselves (the data stored in each TreeLinker), rather than
17
15
  * the linkers that hold them.
18
- * @class
19
- * @augments LinkedTreeList
20
16
  */
21
17
  class PseudoNodeList extends LinkedTreeList_1.LinkedTreeList {
22
18
  /**
23
19
  * Iterate over the nodes in this list.
24
- * @returns {Iterator}
25
20
  */
26
21
  [Symbol.iterator] () {
27
22
  // Walk the nodes of this list only (the linkers of a child list have no children of their own)
@@ -46,7 +41,6 @@ class PseudoNodeList extends LinkedTreeList_1.LinkedTreeList {
46
41
 
47
42
  /**
48
43
  * Iterate over [index, node] pairs.
49
- * @returns {Iterator}
50
44
  */
51
45
  entries () {
52
46
  return Array.from(this).map((node, index) => [index, node])[Symbol.iterator]()
@@ -54,7 +48,6 @@ class PseudoNodeList extends LinkedTreeList_1.LinkedTreeList {
54
48
 
55
49
  /**
56
50
  * Iterate over the indexes.
57
- * @returns {Iterator}
58
51
  */
59
52
  keys () {
60
53
  return Array.from(this).map((node, index) => index)[Symbol.iterator]()
@@ -62,7 +55,6 @@ class PseudoNodeList extends LinkedTreeList_1.LinkedTreeList {
62
55
 
63
56
  /**
64
57
  * Iterate over the nodes.
65
- * @returns {Iterator}
66
58
  */
67
59
  values () {
68
60
  return Array.from(this)[Symbol.iterator]()
@@ -1,8 +1,6 @@
1
1
  /**
2
2
  * A live DOMStringMap-like object for an element's data-* attributes.
3
- * @memberOf module:factories
4
- * @param {*} element The element whose data-* attributes this reflects
5
- * @returns {Object.<string, string>}
3
+ * @param element The element whose data-* attributes this reflects
6
4
  */
7
5
  declare const createDataset: (element: any) => {
8
6
  [key: string]: string;
@@ -6,20 +6,17 @@ Object.defineProperty(exports, '__esModule', {
6
6
  value: true
7
7
  })
8
8
  /**
9
- * @file Wraps an element in a Proxy which behaves like the DOM's DOMStringMap (element.dataset): a live view of its
9
+ * Wraps an element in a Proxy which behaves like the DOM's DOMStringMap (element.dataset): a live view of its
10
10
  * data-* attributes, under their camelCase names, backed by the element's own getAttribute / setAttribute /
11
11
  * hasAttribute / removeAttribute (nothing is stored separately, so it can never fall out of sync with the
12
12
  * attributes).
13
- * @author Joshua Heagle <joshuaheagle@gmail.com>
14
- * @version 1.0.0
15
13
  */
16
14
  const createStyleDeclaration_1 = require('./createStyleDeclaration')
17
15
  const DATA_PREFIX = 'data-'
18
16
  const attributeName = property => `${DATA_PREFIX}${(0, createStyleDeclaration_1.camelToKebab)(property)}`
19
17
  /**
20
18
  * Every data-* attribute name currently on the element, as [attributeName, camelCaseName] pairs.
21
- * @param {*} element
22
- * @returns {Array<Array<string>>}
19
+ * @param element
23
20
  */
24
21
  const dataAttributes = element => {
25
22
  const names = []
@@ -33,9 +30,7 @@ const dataAttributes = element => {
33
30
  }
34
31
  /**
35
32
  * A live DOMStringMap-like object for an element's data-* attributes.
36
- * @memberOf module:factories
37
- * @param {*} element The element whose data-* attributes this reflects
38
- * @returns {Object.<string, string>}
33
+ * @param element The element whose data-* attributes this reflects
39
34
  */
40
35
  const createDataset = element => new Proxy({}, {
41
36
  get (_target, property) {
@@ -1,13 +1,11 @@
1
1
  import { EventService } from '../services/EventService';
2
2
  /**
3
3
  * How the event is being created.
4
- * @typedef {Object} CreateEventOptions
5
- * @property {boolean} [browser=false] The browser is creating the event (for a user action, or for something like
6
- * element.click()), so the standard options for the type of event apply where the init does not give its own
7
- * @property {boolean} [trusted=false] The event comes from a real user action rather than from a script (isTrusted)
8
4
  */
9
5
  export type CreateEventOptions = {
6
+ /** The browser is creating the event (for a user action, or for something like element.click()), so the standard options for the type of event apply where the init does not give its own (default false) */
10
7
  browser?: boolean;
8
+ /** The event comes from a real user action rather than from a script (isTrusted) (default false) */
11
9
  trusted?: boolean;
12
10
  };
13
11
  /**
@@ -16,11 +14,9 @@ export type CreateEventOptions = {
16
14
  * the init says so, and the event is not trusted. With browser: true the event is created the way the browser creates
17
15
  * it, using the standard options for its type (see eventDefaults), and trusted: true makes it look like it came from a
18
16
  * real user action (isTrusted).
19
- * @function createEvent
20
- * @param {string} type The type of the event, such as click
21
- * @param {Object} [init={}] The options for the event (bubbles, cancelable, composed and those of its kind of event)
22
- * @param {CreateEventOptions} [options={}] Whether the browser is creating the event, and whether it is trusted
23
- * @returns {EventService}
17
+ * @param type The type of the event, such as click
18
+ * @param init The options for the event (bubbles, cancelable, composed and those of its kind of event)
19
+ * @param options Whether the browser is creating the event, and whether it is trusted
24
20
  */
25
21
  export declare const createEvent: (type: string, init?: {
26
22
  [option: string]: any;
@@ -29,11 +29,9 @@ const eventClasses = {
29
29
  * the init says so, and the event is not trusted. With browser: true the event is created the way the browser creates
30
30
  * it, using the standard options for its type (see eventDefaults), and trusted: true makes it look like it came from a
31
31
  * real user action (isTrusted).
32
- * @function createEvent
33
- * @param {string} type The type of the event, such as click
34
- * @param {Object} [init={}] The options for the event (bubbles, cancelable, composed and those of its kind of event)
35
- * @param {CreateEventOptions} [options={}] Whether the browser is creating the event, and whether it is trusted
36
- * @returns {EventService}
32
+ * @param type The type of the event, such as click
33
+ * @param init The options for the event (bubbles, cancelable, composed and those of its kind of event)
34
+ * @param options Whether the browser is creating the event, and whether it is trusted
37
35
  */
38
36
  const createEvent = (type, init = {}, {
39
37
  browser = false,
@@ -1,29 +1,23 @@
1
1
  /**
2
- * @file Wraps a CSSStyleDeclarationService in a Proxy so arbitrary camelCase CSS properties (element.style.
2
+ * Wraps a CSSStyleDeclarationService in a Proxy so arbitrary camelCase CSS properties (element.style.
3
3
  * backgroundColor) work like the DOM's, on top of its real methods (getPropertyValue, setProperty, cssText, ...).
4
- * @author Joshua Heagle <joshuaheagle@gmail.com>
5
- * @version 1.0.0
6
4
  */
7
5
  import { CSSStyleDeclarationService } from '../services/CSSStyleDeclarationService';
8
6
  /**
9
7
  * kebab-case -> camelCase ("background-color" -> "backgroundColor").
10
- * @param {string} name
11
- * @returns {string}
8
+ * @param name
12
9
  */
13
10
  declare const kebabToCamel: (name: string) => string;
14
11
  /**
15
12
  * camelCase -> kebab-case ("backgroundColor" -> "background-color").
16
- * @param {string} name
17
- * @returns {string}
13
+ * @param name
18
14
  */
19
15
  declare const camelToKebab: (name: string) => string;
20
16
  /**
21
17
  * A live CSSStyleDeclaration-like object: its real methods (cssText, getPropertyValue, setProperty, ...) work as
22
18
  * declared, and any other property name is treated as a camelCase CSS property (declaration.backgroundColor reads /
23
19
  * writes the "background-color" declaration), matching what a real element.style supports.
24
- * @memberOf module:factories
25
- * @param {string} [cssText=''] Initial declarations
26
- * @returns {CSSStyleDeclarationService}
20
+ * @param cssText Initial declarations
27
21
  */
28
22
  declare const createStyleDeclaration: (cssText?: string) => CSSStyleDeclarationService;
29
23
  export { kebabToCamel, camelToKebab };
@@ -5,24 +5,20 @@ Object.defineProperty(exports, '__esModule', {
5
5
  })
6
6
  exports.camelToKebab = exports.kebabToCamel = void 0
7
7
  /**
8
- * @file Wraps a CSSStyleDeclarationService in a Proxy so arbitrary camelCase CSS properties (element.style.
8
+ * Wraps a CSSStyleDeclarationService in a Proxy so arbitrary camelCase CSS properties (element.style.
9
9
  * backgroundColor) work like the DOM's, on top of its real methods (getPropertyValue, setProperty, cssText, ...).
10
- * @author Joshua Heagle <joshuaheagle@gmail.com>
11
- * @version 1.0.0
12
10
  */
13
11
  const CSSStyleDeclarationService_1 = require('../services/CSSStyleDeclarationService')
14
12
  const isIndex = property => /^\d+$/.test(property)
15
13
  /**
16
14
  * kebab-case -> camelCase ("background-color" -> "backgroundColor").
17
- * @param {string} name
18
- * @returns {string}
15
+ * @param name
19
16
  */
20
17
  const kebabToCamel = name => name.replace(/-([a-z0-9])/gi, (_match, letter) => letter.toUpperCase())
21
18
  exports.kebabToCamel = kebabToCamel
22
19
  /**
23
20
  * camelCase -> kebab-case ("backgroundColor" -> "background-color").
24
- * @param {string} name
25
- * @returns {string}
21
+ * @param name
26
22
  */
27
23
  const camelToKebab = name => name.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`)
28
24
  exports.camelToKebab = camelToKebab
@@ -30,9 +26,7 @@ exports.camelToKebab = camelToKebab
30
26
  * A live CSSStyleDeclaration-like object: its real methods (cssText, getPropertyValue, setProperty, ...) work as
31
27
  * declared, and any other property name is treated as a camelCase CSS property (declaration.backgroundColor reads /
32
28
  * writes the "background-color" declaration), matching what a real element.style supports.
33
- * @memberOf module:factories
34
- * @param {string} [cssText=''] Initial declarations
35
- * @returns {CSSStyleDeclarationService}
29
+ * @param cssText Initial declarations
36
30
  */
37
31
  const createStyleDeclaration = (cssText = '') => {
38
32
  const target = new CSSStyleDeclarationService_1.CSSStyleDeclarationService(cssText)
@@ -2,8 +2,6 @@
2
2
  * Maps pseudo-dom's own Node / Element API onto the Adapter interface css-select needs to query a tree which is not
3
3
  * domutils' own (css-select's own Adapter<Node, ElementNode> type). Every method here is one pseudo-dom already has
4
4
  * under a different name; nothing here reimplements DOM behaviour.
5
- * @memberOf module:factories
6
- * @type {Object}
7
5
  */
8
6
  export declare const cssSelectAdapter: {
9
7
  isTag: (node: any) => boolean;
@@ -9,17 +9,14 @@ Object.defineProperty(exports, '__esModule', {
9
9
  })
10
10
  exports.cssSelectAdapter = void 0
11
11
  /**
12
- * @file The css-select Adapter which lets it query pseudo-dom's own tree, instead of the domutils-based tree it
12
+ * The css-select Adapter which lets it query pseudo-dom's own tree, instead of the domutils-based tree it
13
13
  * defaults to.
14
- * @author Joshua Heagle <joshuaheagle@gmail.com>
15
- * @version 1.0.0
16
14
  */
17
15
  const NodeService_1 = require('../services/NodeService')
18
16
  /**
19
17
  * Walk up from a node (not including it) to find the nearest element, in the given direction.
20
- * @param {*} node The node to start from
21
- * @param {'nextSibling'|'previousSibling'} direction Which sibling reference to follow
22
- * @returns {*|null}
18
+ * @param node The node to start from
19
+ * @param direction Which sibling reference to follow
23
20
  */
24
21
  const nearestElementSibling = (node, direction) => {
25
22
  let current = node ? node[direction] : null
@@ -32,8 +29,6 @@ const nearestElementSibling = (node, direction) => {
32
29
  * Maps pseudo-dom's own Node / Element API onto the Adapter interface css-select needs to query a tree which is not
33
30
  * domutils' own (css-select's own Adapter<Node, ElementNode> type). Every method here is one pseudo-dom already has
34
31
  * under a different name; nothing here reimplements DOM behaviour.
35
- * @memberOf module:factories
36
- * @type {Object}
37
32
  */
38
33
  exports.cssSelectAdapter = {
39
34
  isTag: node => !!node && node.nodeType === NodeService_1.NodeService.ELEMENT_NODE,
@@ -1,21 +1,18 @@
1
1
  /**
2
- * @file The standard event types of the browser, and how the browser creates them.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.0.0
2
+ * The standard event types of the browser, and how the browser creates them.
5
3
  */
6
4
  /**
7
5
  * How the browser creates an event of a standard type: whether it bubbles, whether it can be cancelled, whether it
8
6
  * crosses the boundary of a shadow tree, and which kind of event object it is.
9
- * @typedef {Object} EventDefinition
10
- * @property {boolean} bubbles - After the target, the event goes back up through the ancestors (the capture phase, going down, always happens)
11
- * @property {boolean} cancelable - preventDefault() can stop the default action
12
- * @property {boolean} composed - The event crosses the boundary of a shadow tree
13
- * @property {string} interface - The kind of event object: Event, UIEvent, MouseEvent, PointerEvent, KeyboardEvent, FocusEvent, InputEvent or CustomEvent
14
7
  */
15
8
  export type EventDefinition = {
9
+ /** After the target, the event goes back up through the ancestors (the capture phase, going down, always happens) */
16
10
  bubbles: boolean;
11
+ /** preventDefault() can stop the default action */
17
12
  cancelable: boolean;
13
+ /** The event crosses the boundary of a shadow tree */
18
14
  composed: boolean;
15
+ /** The kind of event object: Event, UIEvent, MouseEvent, PointerEvent, KeyboardEvent, FocusEvent, InputEvent or CustomEvent */
19
16
  interface: 'Event' | 'UIEvent' | 'MouseEvent' | 'PointerEvent' | 'KeyboardEvent' | 'FocusEvent' | 'InputEvent' | 'CustomEvent';
20
17
  };
21
18
  /**
@@ -23,7 +20,6 @@ export type EventDefinition = {
23
20
  * options. A script which creates an event with the constructor gets none of them (everything is false) unless it asks
24
21
  * for them, which is why createEvent only uses this table when it is told the browser is creating the event.
25
22
  * The values follow the UI Events, HTML, Pointer Events, Clipboard, Drag and Drop, Touch and CSS specifications.
26
- * @type {Object.<string, EventDefinition>}
27
23
  */
28
24
  export declare const eventDefaults: {
29
25
  [type: string]: EventDefinition;
@@ -1,9 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  /**
4
- * @file The standard event types of the browser, and how the browser creates them.
5
- * @author Joshua Heagle <joshuaheagle@gmail.com>
6
- * @version 1.0.0
4
+ * The standard event types of the browser, and how the browser creates them.
7
5
  */
8
6
  Object.defineProperty(exports, '__esModule', {
9
7
  value: true
@@ -20,7 +18,6 @@ const define = (bubbles, cancelable, composed, eventInterface = 'Event') => ({
20
18
  * options. A script which creates an event with the constructor gets none of them (everything is false) unless it asks
21
19
  * for them, which is why createEvent only uses this table when it is told the browser is creating the event.
22
20
  * The values follow the UI Events, HTML, Pointer Events, Clipboard, Drag and Drop, Touch and CSS specifications.
23
- * @type {Object.<string, EventDefinition>}
24
21
  */
25
22
  exports.eventDefaults = {
26
23
  // Mouse (UI Events)
@@ -2,10 +2,8 @@ import PseudoEventTarget from '../services/EventTargetService';
2
2
  /**
3
3
  * Construct the Pseudo Dom to provide access to Dom objects which are otherwise not available outside the browser
4
4
  * context.
5
- * @function generateDocument
6
- * @param {Object} root
7
- * @param {Object} context
8
- * @returns {Window|PseudoEventTarget}
5
+ * @param root
6
+ * @param context
9
7
  */
10
8
  declare const generateDocument: (root: Window | any, context?: object) => Window | PseudoEventTarget;
11
9
  export default generateDocument;