pseudo-dom 0.6.0 → 0.8.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 (131) hide show
  1. package/README.md +686 -241
  2. package/browser/pseudo-dom.js +3576 -735
  3. package/browser/pseudo-dom.min.js +1 -1
  4. package/dist/classes/PseudoEventListener.d.ts +96 -96
  5. package/dist/classes/PseudoEventListener.js +151 -151
  6. package/dist/classes/PseudoHTMLDocument.d.ts +17 -43
  7. package/dist/classes/PseudoHTMLDocument.js +24 -94
  8. package/dist/classes/PseudoHTMLDocument.min.js +1 -1
  9. package/dist/classes/PseudoNodeList.d.ts +34 -34
  10. package/dist/classes/PseudoNodeList.js +71 -71
  11. package/dist/factories/createEvent.d.ts +28 -28
  12. package/dist/factories/createEvent.js +56 -56
  13. package/dist/factories/cssSelectAdapter.d.ts +23 -0
  14. package/dist/factories/cssSelectAdapter.js +87 -0
  15. package/dist/factories/cssSelectAdapter.min.js +1 -0
  16. package/dist/factories/eventDefaults.d.ts +31 -31
  17. package/dist/factories/eventDefaults.js +105 -105
  18. package/dist/factories/generateDocument.d.ts +11 -11
  19. package/dist/factories/generateDocument.js +65 -65
  20. package/dist/factories/generateNodeList.d.ts +9 -9
  21. package/dist/factories/generateNodeList.js +13 -13
  22. package/dist/factories/query.d.ts +33 -0
  23. package/dist/factories/query.js +66 -0
  24. package/dist/factories/query.min.js +1 -0
  25. package/dist/functions/activeElement.d.ts +14 -14
  26. package/dist/functions/activeElement.js +33 -33
  27. package/dist/functions/getElementById.d.ts +13 -0
  28. package/dist/functions/getElementById.js +33 -0
  29. package/dist/functions/getElementById.min.js +1 -0
  30. package/dist/functions/getParentNodes.d.ts +11 -11
  31. package/dist/functions/getParentNodes.js +22 -22
  32. package/dist/functions/getParentNodesFromAttribute.d.ts +14 -14
  33. package/dist/functions/getParentNodesFromAttribute.js +29 -29
  34. package/dist/functions/modifierState.d.ts +29 -29
  35. package/dist/functions/modifierState.js +41 -41
  36. package/dist/interfaces/PseudoAnimation.d.ts +3 -3
  37. package/dist/interfaces/PseudoAnimation.js +5 -5
  38. package/dist/interfaces/PseudoAttr.d.ts +11 -11
  39. package/dist/interfaces/PseudoAttr.js +5 -5
  40. package/dist/interfaces/PseudoDOMTokenList.d.ts +16 -16
  41. package/dist/interfaces/PseudoDOMTokenList.js +5 -5
  42. package/dist/interfaces/PseudoDocument.d.ts +32 -0
  43. package/dist/interfaces/PseudoDocument.js +5 -5
  44. package/dist/interfaces/PseudoDocumentFragment.d.ts +7 -0
  45. package/dist/interfaces/PseudoDocumentFragment.js +5 -5
  46. package/dist/interfaces/PseudoElement.d.ts +702 -689
  47. package/dist/interfaces/PseudoElement.js +5 -5
  48. package/dist/interfaces/PseudoEvent.d.ts +79 -79
  49. package/dist/interfaces/PseudoEvent.js +10 -10
  50. package/dist/interfaces/PseudoEventTarget.d.ts +46 -46
  51. package/dist/interfaces/PseudoEventTarget.js +5 -5
  52. package/dist/interfaces/PseudoHTMLCollection.d.ts +23 -23
  53. package/dist/interfaces/PseudoHTMLCollection.js +5 -5
  54. package/dist/interfaces/PseudoHTMLElement.d.ts +22 -22
  55. package/dist/interfaces/PseudoHTMLElement.js +5 -5
  56. package/dist/interfaces/PseudoHTMLSlotElement.d.ts +3 -3
  57. package/dist/interfaces/PseudoHTMLSlotElement.js +5 -5
  58. package/dist/interfaces/PseudoNamedNodeMap.d.ts +11 -11
  59. package/dist/interfaces/PseudoNamedNodeMap.js +5 -5
  60. package/dist/interfaces/PseudoNode.d.ts +179 -179
  61. package/dist/interfaces/PseudoNode.js +5 -5
  62. package/dist/interfaces/PseudoShadowRoot.d.ts +3 -3
  63. package/dist/interfaces/PseudoShadowRoot.js +5 -5
  64. package/dist/main.d.ts +63 -63
  65. package/dist/main.js +155 -155
  66. package/dist/services/AnimationService.d.ts +4 -4
  67. package/dist/services/AnimationService.js +16 -16
  68. package/dist/services/AttrService.d.ts +37 -37
  69. package/dist/services/AttrService.js +81 -81
  70. package/dist/services/CommentService.d.ts +1 -1
  71. package/dist/services/CommentService.js +13 -13
  72. package/dist/services/CustomEventService.d.ts +37 -37
  73. package/dist/services/CustomEventService.js +35 -35
  74. package/dist/services/DOMTokenListService.d.ts +33 -33
  75. package/dist/services/DOMTokenListService.js +117 -117
  76. package/dist/services/DocumentFragmentService.d.ts +8 -0
  77. package/dist/services/DocumentFragmentService.js +18 -0
  78. package/dist/services/DocumentFragmentService.min.js +1 -1
  79. package/dist/services/DocumentService.d.ts +35 -1
  80. package/dist/services/DocumentService.js +72 -0
  81. package/dist/services/DocumentService.min.js +1 -1
  82. package/dist/services/ElementService.d.ts +191 -178
  83. package/dist/services/ElementService.js +426 -406
  84. package/dist/services/ElementService.min.js +1 -1
  85. package/dist/services/EventService.d.ts +120 -120
  86. package/dist/services/EventService.js +250 -250
  87. package/dist/services/EventTargetService.d.ts +84 -84
  88. package/dist/services/EventTargetService.js +232 -232
  89. package/dist/services/FocusEventService.d.ts +32 -32
  90. package/dist/services/FocusEventService.js +35 -35
  91. package/dist/services/HTMLCollectionService.d.ts +54 -49
  92. package/dist/services/HTMLCollectionService.js +92 -75
  93. package/dist/services/HTMLCollectionService.min.js +1 -1
  94. package/dist/services/HTMLElementService.d.ts +57 -57
  95. package/dist/services/HTMLElementService.js +163 -163
  96. package/dist/services/HTMLSlotElementService.d.ts +4 -4
  97. package/dist/services/HTMLSlotElementService.js +9 -9
  98. package/dist/services/InputEventService.d.ts +41 -41
  99. package/dist/services/InputEventService.js +47 -47
  100. package/dist/services/KeyboardEventService.d.ts +70 -70
  101. package/dist/services/KeyboardEventService.js +86 -86
  102. package/dist/services/MouseEventService.d.ts +80 -80
  103. package/dist/services/MouseEventService.js +108 -108
  104. package/dist/services/NamedNodeMapService.d.ts +23 -23
  105. package/dist/services/NamedNodeMapService.js +77 -77
  106. package/dist/services/NodeService.d.ts +297 -271
  107. package/dist/services/NodeService.js +721 -679
  108. package/dist/services/NodeService.min.js +1 -1
  109. package/dist/services/PointerEventService.d.ts +51 -51
  110. package/dist/services/PointerEventService.js +67 -67
  111. package/dist/services/ShadowRootService.d.ts +4 -4
  112. package/dist/services/ShadowRootService.js +9 -9
  113. package/dist/services/TextService.d.ts +1 -1
  114. package/dist/services/TextService.js +13 -13
  115. package/dist/services/UIEventService.d.ts +43 -43
  116. package/dist/services/UIEventService.js +42 -42
  117. package/dist/simulate.d.ts +32 -32
  118. package/dist/simulate.js +115 -115
  119. package/package.json +4 -3
  120. package/dist/classes.d.ts +0 -20
  121. package/dist/classes.js +0 -31
  122. package/dist/classes.min.js +0 -1
  123. package/dist/factories/generateNode.d.ts +0 -32
  124. package/dist/factories/generateNode.js +0 -85
  125. package/dist/factories/generateNode.min.js +0 -1
  126. package/dist/factories.d.ts +0 -11
  127. package/dist/factories.js +0 -27
  128. package/dist/factories.min.js +0 -1
  129. package/dist/functions.d.ts +0 -5
  130. package/dist/functions.js +0 -23
  131. package/dist/functions.min.js +0 -1
@@ -1,96 +1,96 @@
1
- /**
2
- * @file Substitute for the DOM EventEventListener Class.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.0.0
5
- */
6
- import { EventService } from '../services/EventService';
7
- /**
8
- * 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
- */
15
- declare class PseudoEventListener {
16
- private eventOptions;
17
- private eventType;
18
- private handler;
19
- private readonly originalCallback;
20
- private readonly defaultListener;
21
- private isRemoved;
22
- /**
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
28
- */
29
- constructor(eventType: string, { capture, once, passive }: {
30
- capture?: boolean;
31
- once?: boolean;
32
- passive?: boolean;
33
- }, handleEvent: Function, originalCallback?: Function);
34
- /**
35
- * The function (or object with handleEvent) which was originally given when registering, used to find this listener again for removal.
36
- */
37
- get callback(): Function;
38
- /** Whether this listener listens in the capture phase (and at the target) rather than in the bubble phase. */
39
- get capture(): boolean;
40
- get isDefault(): boolean;
41
- get once(): boolean;
42
- /** Whether the listener promises not to prevent the default (preventDefault does nothing while it runs). */
43
- get passive(): boolean;
44
- /** Whether this listener has been removed, a removed listener does not run even if the event already started. */
45
- get removed(): boolean;
46
- set removed(removed: boolean);
47
- /**
48
- * @method
49
- * @name PseudoEventListener#handleEvent
50
- * @param {PseudoEvent} event
51
- * @returns {*}
52
- */
53
- handleEvent(event: EventService): any;
54
- /**
55
- * 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}
60
- */
61
- doCapturePhase(event: EventService): boolean;
62
- /**
63
- * Every listener of the target itself runs, capture listeners first.
64
- * @method
65
- * @name PseudoEventListener#doTargetPhase
66
- * @param {PseudoEvent} event
67
- * @returns {boolean}
68
- */
69
- doTargetPhase(event: EventService): boolean;
70
- /**
71
- * 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}
76
- */
77
- doBubblePhase(event: EventService): boolean;
78
- /**
79
- * @method
80
- * @name PseudoEventListener#skipPhase
81
- * @param {PseudoEvent} event
82
- * @returns {boolean}
83
- */
84
- skipPhase(event: EventService): boolean;
85
- /**
86
- * Whether this listener should not run for the event as it is now (it was removed, or it is for another phase).
87
- * Stopping propagation is handled by the dispatching, since it stops other targets and not the listeners of the
88
- * current one.
89
- * @method
90
- * @name PseudoEventListener#rejectEvent
91
- * @param {PseudoEvent} event
92
- * @returns {boolean}
93
- */
94
- rejectEvent(event: EventService): boolean;
95
- }
96
- export default PseudoEventListener;
1
+ /**
2
+ * @file Substitute for the DOM EventEventListener Class.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.0.0
5
+ */
6
+ import { EventService } from '../services/EventService';
7
+ /**
8
+ * 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
+ */
15
+ declare class PseudoEventListener {
16
+ private eventOptions;
17
+ private eventType;
18
+ private handler;
19
+ private readonly originalCallback;
20
+ private readonly defaultListener;
21
+ private isRemoved;
22
+ /**
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
28
+ */
29
+ constructor(eventType: string, { capture, once, passive }: {
30
+ capture?: boolean;
31
+ once?: boolean;
32
+ passive?: boolean;
33
+ }, handleEvent: Function, originalCallback?: Function);
34
+ /**
35
+ * The function (or object with handleEvent) which was originally given when registering, used to find this listener again for removal.
36
+ */
37
+ get callback(): Function;
38
+ /** Whether this listener listens in the capture phase (and at the target) rather than in the bubble phase. */
39
+ get capture(): boolean;
40
+ get isDefault(): boolean;
41
+ get once(): boolean;
42
+ /** Whether the listener promises not to prevent the default (preventDefault does nothing while it runs). */
43
+ get passive(): boolean;
44
+ /** Whether this listener has been removed, a removed listener does not run even if the event already started. */
45
+ get removed(): boolean;
46
+ set removed(removed: boolean);
47
+ /**
48
+ * @method
49
+ * @name PseudoEventListener#handleEvent
50
+ * @param {PseudoEvent} event
51
+ * @returns {*}
52
+ */
53
+ handleEvent(event: EventService): any;
54
+ /**
55
+ * 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}
60
+ */
61
+ doCapturePhase(event: EventService): boolean;
62
+ /**
63
+ * Every listener of the target itself runs, capture listeners first.
64
+ * @method
65
+ * @name PseudoEventListener#doTargetPhase
66
+ * @param {PseudoEvent} event
67
+ * @returns {boolean}
68
+ */
69
+ doTargetPhase(event: EventService): boolean;
70
+ /**
71
+ * 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}
76
+ */
77
+ doBubblePhase(event: EventService): boolean;
78
+ /**
79
+ * @method
80
+ * @name PseudoEventListener#skipPhase
81
+ * @param {PseudoEvent} event
82
+ * @returns {boolean}
83
+ */
84
+ skipPhase(event: EventService): boolean;
85
+ /**
86
+ * Whether this listener should not run for the event as it is now (it was removed, or it is for another phase).
87
+ * Stopping propagation is handled by the dispatching, since it stops other targets and not the listeners of the
88
+ * current one.
89
+ * @method
90
+ * @name PseudoEventListener#rejectEvent
91
+ * @param {PseudoEvent} event
92
+ * @returns {boolean}
93
+ */
94
+ rejectEvent(event: EventService): boolean;
95
+ }
96
+ export default PseudoEventListener;
@@ -1,151 +1,151 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- /**
7
- * @file Substitute for the DOM EventEventListener Class.
8
- * @author Joshua Heagle <joshuaheagle@gmail.com>
9
- * @version 1.0.0
10
- */
11
- const EventService_1 = require('../services/EventService')
12
- /**
13
- * 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
- */
20
- class PseudoEventListener {
21
- /**
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
27
- */
28
- constructor (eventType, {
29
- capture = false,
30
- once = false,
31
- passive = false
32
- } = {}, handleEvent, originalCallback = handleEvent) {
33
- this.eventOptions = {
34
- capture: false,
35
- once: false,
36
- passive: false
37
- }
38
- this.eventType = ''
39
- this.defaultListener = false
40
- this.isRemoved = false
41
- this.eventOptions = {
42
- capture,
43
- once,
44
- passive
45
- }
46
- this.eventType = eventType
47
- this.handler = handleEvent
48
- this.originalCallback = originalCallback
49
- }
50
-
51
- /**
52
- * The function (or object with handleEvent) which was originally given when registering, used to find this listener again for removal.
53
- */
54
- get callback () {
55
- return this.originalCallback
56
- }
57
-
58
- /** Whether this listener listens in the capture phase (and at the target) rather than in the bubble phase. */
59
- get capture () {
60
- return this.eventOptions.capture
61
- }
62
-
63
- get isDefault () {
64
- return this.defaultListener
65
- }
66
-
67
- get once () {
68
- return this.eventOptions.once
69
- }
70
-
71
- /** Whether the listener promises not to prevent the default (preventDefault does nothing while it runs). */
72
- get passive () {
73
- return this.eventOptions.passive
74
- }
75
-
76
- /** Whether this listener has been removed, a removed listener does not run even if the event already started. */
77
- get removed () {
78
- return this.isRemoved
79
- }
80
-
81
- set removed (removed) {
82
- this.isRemoved = removed
83
- }
84
-
85
- /**
86
- * @method
87
- * @name PseudoEventListener#handleEvent
88
- * @param {PseudoEvent} event
89
- * @returns {*}
90
- */
91
- handleEvent (event) {
92
- return this.handler(event)
93
- }
94
-
95
- /**
96
- * 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}
101
- */
102
- doCapturePhase (event) {
103
- return event.eventPhase === EventService_1.EventService.CAPTURING_PHASE && this.eventOptions.capture
104
- }
105
-
106
- /**
107
- * Every listener of the target itself runs, capture listeners first.
108
- * @method
109
- * @name PseudoEventListener#doTargetPhase
110
- * @param {PseudoEvent} event
111
- * @returns {boolean}
112
- */
113
- doTargetPhase (event) {
114
- return event.eventPhase === EventService_1.EventService.AT_TARGET
115
- }
116
-
117
- /**
118
- * 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}
123
- */
124
- doBubblePhase (event) {
125
- return event.eventPhase === EventService_1.EventService.BUBBLING_PHASE && !this.eventOptions.capture
126
- }
127
-
128
- /**
129
- * @method
130
- * @name PseudoEventListener#skipPhase
131
- * @param {PseudoEvent} event
132
- * @returns {boolean}
133
- */
134
- skipPhase (event) {
135
- return !this.doCapturePhase(event) && !this.doTargetPhase(event) && !this.doBubblePhase(event)
136
- }
137
-
138
- /**
139
- * Whether this listener should not run for the event as it is now (it was removed, or it is for another phase).
140
- * Stopping propagation is handled by the dispatching, since it stops other targets and not the listeners of the
141
- * current one.
142
- * @method
143
- * @name PseudoEventListener#rejectEvent
144
- * @param {PseudoEvent} event
145
- * @returns {boolean}
146
- */
147
- rejectEvent (event) {
148
- return this.isRemoved || this.skipPhase(event)
149
- }
150
- }
151
- exports.default = PseudoEventListener
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ /**
7
+ * @file Substitute for the DOM EventEventListener Class.
8
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
9
+ * @version 1.0.0
10
+ */
11
+ const EventService_1 = require('../services/EventService')
12
+ /**
13
+ * 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
+ */
20
+ class PseudoEventListener {
21
+ /**
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
27
+ */
28
+ constructor (eventType, {
29
+ capture = false,
30
+ once = false,
31
+ passive = false
32
+ } = {}, handleEvent, originalCallback = handleEvent) {
33
+ this.eventOptions = {
34
+ capture: false,
35
+ once: false,
36
+ passive: false
37
+ }
38
+ this.eventType = ''
39
+ this.defaultListener = false
40
+ this.isRemoved = false
41
+ this.eventOptions = {
42
+ capture,
43
+ once,
44
+ passive
45
+ }
46
+ this.eventType = eventType
47
+ this.handler = handleEvent
48
+ this.originalCallback = originalCallback
49
+ }
50
+
51
+ /**
52
+ * The function (or object with handleEvent) which was originally given when registering, used to find this listener again for removal.
53
+ */
54
+ get callback () {
55
+ return this.originalCallback
56
+ }
57
+
58
+ /** Whether this listener listens in the capture phase (and at the target) rather than in the bubble phase. */
59
+ get capture () {
60
+ return this.eventOptions.capture
61
+ }
62
+
63
+ get isDefault () {
64
+ return this.defaultListener
65
+ }
66
+
67
+ get once () {
68
+ return this.eventOptions.once
69
+ }
70
+
71
+ /** Whether the listener promises not to prevent the default (preventDefault does nothing while it runs). */
72
+ get passive () {
73
+ return this.eventOptions.passive
74
+ }
75
+
76
+ /** Whether this listener has been removed, a removed listener does not run even if the event already started. */
77
+ get removed () {
78
+ return this.isRemoved
79
+ }
80
+
81
+ set removed (removed) {
82
+ this.isRemoved = removed
83
+ }
84
+
85
+ /**
86
+ * @method
87
+ * @name PseudoEventListener#handleEvent
88
+ * @param {PseudoEvent} event
89
+ * @returns {*}
90
+ */
91
+ handleEvent (event) {
92
+ return this.handler(event)
93
+ }
94
+
95
+ /**
96
+ * 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}
101
+ */
102
+ doCapturePhase (event) {
103
+ return event.eventPhase === EventService_1.EventService.CAPTURING_PHASE && this.eventOptions.capture
104
+ }
105
+
106
+ /**
107
+ * Every listener of the target itself runs, capture listeners first.
108
+ * @method
109
+ * @name PseudoEventListener#doTargetPhase
110
+ * @param {PseudoEvent} event
111
+ * @returns {boolean}
112
+ */
113
+ doTargetPhase (event) {
114
+ return event.eventPhase === EventService_1.EventService.AT_TARGET
115
+ }
116
+
117
+ /**
118
+ * 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}
123
+ */
124
+ doBubblePhase (event) {
125
+ return event.eventPhase === EventService_1.EventService.BUBBLING_PHASE && !this.eventOptions.capture
126
+ }
127
+
128
+ /**
129
+ * @method
130
+ * @name PseudoEventListener#skipPhase
131
+ * @param {PseudoEvent} event
132
+ * @returns {boolean}
133
+ */
134
+ skipPhase (event) {
135
+ return !this.doCapturePhase(event) && !this.doTargetPhase(event) && !this.doBubblePhase(event)
136
+ }
137
+
138
+ /**
139
+ * Whether this listener should not run for the event as it is now (it was removed, or it is for another phase).
140
+ * Stopping propagation is handled by the dispatching, since it stops other targets and not the listeners of the
141
+ * current one.
142
+ * @method
143
+ * @name PseudoEventListener#rejectEvent
144
+ * @param {PseudoEvent} event
145
+ * @returns {boolean}
146
+ */
147
+ rejectEvent (event) {
148
+ return this.isRemoved || this.skipPhase(event)
149
+ }
150
+ }
151
+ exports.default = PseudoEventListener
@@ -3,65 +3,39 @@
3
3
  * @author Joshua Heagle <joshuaheagle@gmail.com>
4
4
  * @version 1.0.0
5
5
  */
6
- /**
7
- *
8
- * @type {PseudoHTMLElement}
9
- */
10
6
  import { HTMLElementService as PseudoHTMLElement } from '../services/HTMLElementService';
11
- import { TextService, CommentService } from '../services/NodeService';
12
- import { DocumentFragmentService } from '../services/DocumentFragmentService';
13
- import { PseudoNode } from '../interfaces/PseudoNode';
7
+ import { DocumentService } from '../services/DocumentService';
8
+ import { NodeService } from '../services/NodeService';
14
9
  /**
15
- * Simulate the behaviour of the HTMLDocument Class when there is no DOM available.
10
+ * Simulate the behaviour of the HTMLDocument Class when there is no DOM available. Like the real HTMLDocument, this
11
+ * only adds the html/head/body structure on top of what Document already gives (createElement, createTextNode,
12
+ * createComment, createDocumentFragment, getElementById, textContent always null).
16
13
  * @author Joshua Heagle <joshuaheagle@gmail.com>
17
14
  * @class
18
- * @augments PseudoHTMLElement
15
+ * @augments DocumentService
19
16
  * @property {PseudoHTMLElement} head - A reference to the Head child element
20
17
  * @property {PseudoHTMLElement} body - A reference to the Body child element
21
- * @property {function} createElement - Generate a new PseudoHTMLElement (which is not in the document until it is appended)
22
18
  */
23
- declare class PseudoHTMLDocument extends PseudoHTMLElement {
24
- private head;
25
- private body;
19
+ declare class PseudoHTMLDocument extends DocumentService {
20
+ head: PseudoHTMLElement | null;
21
+ body: PseudoHTMLElement | null;
26
22
  /**
27
23
  * The root HTML element is acts as the parent to all HTML elements in the document.
28
24
  * @constructor
29
25
  */
30
26
  constructor();
31
- get nodeName(): string;
32
- get nodeType(): number;
33
- get textContent(): string | null;
34
- set textContent(text: string | null);
35
- /**
36
- * Make an element of the given type which belongs to this document but is not added anywhere until it is appended.
37
- * @param {string} tagName - Tag Name is a string representing the type of Dom element this represents
38
- * @returns {PseudoHTMLElement}
39
- */
40
- createElement(tagName?: string): PseudoHTMLElement;
41
- /**
42
- * Make a text node which belongs to this document.
43
- * @param {string} [data=''] The text
44
- * @returns {TextService}
45
- */
46
- createTextNode(data?: string): TextService;
47
- /**
48
- * Make a comment which belongs to this document.
49
- * @param {string} [data=''] The comment
50
- * @returns {CommentService}
51
- */
52
- createComment(data?: string): CommentService;
53
27
  /**
54
- * Make an empty document fragment which belongs to this document, a container for nodes which can be built up and
55
- * then inserted in one go.
56
- * @returns {DocumentFragmentService}
28
+ * A copy of this document with none of its html/head/body (cloneNode, from the inherited cloneShallow hook, fills
29
+ * them back in, deep copies own document's, empty otherwise - see cloneNode).
30
+ * @returns {PseudoHTMLDocument}
57
31
  */
58
- createDocumentFragment(): DocumentFragmentService;
32
+ protected cloneShallow(): NodeService;
59
33
  /**
60
- * Make a copy of this document. The copy has no parent or listeners, and a deep copy has copies of everything in the
61
- * document (a shallow one is an empty document).
34
+ * Make a copy of this document. The copy has no parent or listeners, and a deep copy has copies of everything in
35
+ * the document (a shallow one is an empty document).
62
36
  * @param {boolean} [deep=false] Copy everything in the document as well
63
- * @returns {PseudoNode}
37
+ * @returns {PseudoHTMLDocument}
64
38
  */
65
- cloneNode(deep?: boolean): PseudoNode;
39
+ cloneNode(deep?: boolean): PseudoHTMLDocument;
66
40
  }
67
41
  export default PseudoHTMLDocument;