pseudo-dom 0.17.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -5869
- package/browser/pseudo-dom.js +14889 -15288
- package/dist/classes/PseudoEventListener.d.ts +11 -37
- package/dist/classes/PseudoEventListener.js +11 -37
- package/dist/classes/PseudoHTMLDocument.d.ts +4 -12
- package/dist/classes/PseudoHTMLDocument.js +1 -11
- package/dist/classes/PseudoNodeList.d.ts +1 -9
- package/dist/classes/PseudoNodeList.js +1 -9
- package/dist/factories/createDataset.d.ts +1 -3
- package/dist/factories/createDataset.js +3 -8
- package/dist/factories/createEvent.d.ts +5 -9
- package/dist/factories/createEvent.js +3 -5
- package/dist/factories/createStyleDeclaration.d.ts +4 -10
- package/dist/factories/createStyleDeclaration.js +4 -10
- package/dist/factories/cssSelectAdapter.d.ts +0 -2
- package/dist/factories/cssSelectAdapter.js +3 -8
- package/dist/factories/eventDefaults.d.ts +5 -9
- package/dist/factories/eventDefaults.js +1 -4
- package/dist/factories/generateDocument.d.ts +2 -4
- package/dist/factories/generateDocument.js +2 -13
- package/dist/factories/generateNodeList.d.ts +1 -2
- package/dist/factories/generateNodeList.js +1 -2
- package/dist/factories/installGlobal.d.ts +2 -3
- package/dist/factories/installGlobal.js +3 -6
- package/dist/factories/logElement.d.ts +2 -4
- package/dist/factories/logElement.js +3 -7
- package/dist/factories/parseHTML.d.ts +3 -5
- package/dist/factories/parseHTML.js +4 -8
- package/dist/factories/query.d.ts +8 -16
- package/dist/factories/query.js +9 -19
- package/dist/factories/serializeHTML.d.ts +4 -10
- package/dist/factories/serializeHTML.js +12 -25
- package/dist/functions/activeElement.d.ts +3 -6
- package/dist/functions/activeElement.js +3 -6
- package/dist/functions/getElementById.d.ts +2 -4
- package/dist/functions/getElementById.js +2 -4
- package/dist/functions/getParentNodes.d.ts +1 -3
- package/dist/functions/getParentNodes.js +1 -3
- package/dist/functions/getParentNodesFromAttribute.d.ts +3 -5
- package/dist/functions/getParentNodesFromAttribute.js +3 -5
- package/dist/functions/modifierState.d.ts +3 -12
- package/dist/functions/modifierState.js +3 -7
- package/dist/interfaces/PseudoCSSStyleDeclaration.d.ts +1 -1
- package/dist/interfaces/PseudoDocument.d.ts +4 -9
- package/dist/interfaces/PseudoDocumentFragment.d.ts +1 -2
- package/dist/interfaces/PseudoElement.d.ts +39 -78
- package/dist/interfaces/PseudoEvent.d.ts +11 -43
- package/dist/interfaces/PseudoEvent.js +1 -3
- package/dist/interfaces/PseudoEventTarget.d.ts +7 -16
- package/dist/interfaces/PseudoHTMLCollection.d.ts +2 -4
- package/dist/interfaces/PseudoHTMLElement.d.ts +8 -13
- package/dist/interfaces/PseudoNode.d.ts +3 -13
- package/dist/main.d.ts +1 -6
- package/dist/main.js +1 -6
- package/dist/services/AttrService.d.ts +5 -9
- package/dist/services/AttrService.js +5 -9
- package/dist/services/CSSStyleDeclarationService.d.ts +10 -23
- package/dist/services/CSSStyleDeclarationService.js +10 -23
- package/dist/services/CustomEventService.d.ts +4 -15
- package/dist/services/CustomEventService.js +3 -10
- package/dist/services/DOMTokenListService.d.ts +2 -5
- package/dist/services/DOMTokenListService.js +2 -5
- package/dist/services/DocumentFragmentService.d.ts +1 -5
- package/dist/services/DocumentFragmentService.js +1 -5
- package/dist/services/DocumentService.d.ts +4 -12
- package/dist/services/DocumentService.js +4 -12
- package/dist/services/ElementService.d.ts +62 -120
- package/dist/services/ElementService.js +61 -117
- package/dist/services/EventService.d.ts +6 -44
- package/dist/services/EventService.js +18 -44
- package/dist/services/EventTargetService.d.ts +16 -28
- package/dist/services/EventTargetService.js +16 -28
- package/dist/services/FocusEventService.d.ts +4 -12
- package/dist/services/FocusEventService.js +3 -10
- package/dist/services/HTMLCollectionService.d.ts +6 -16
- package/dist/services/HTMLCollectionService.js +6 -16
- package/dist/services/HTMLElementService.d.ts +132 -154
- package/dist/services/HTMLElementService.js +333 -353
- package/dist/services/InputEventService.d.ts +5 -16
- package/dist/services/InputEventService.js +3 -12
- package/dist/services/KeyboardEventService.d.ts +8 -26
- package/dist/services/KeyboardEventService.js +4 -16
- package/dist/services/MouseEventService.d.ts +7 -30
- package/dist/services/MouseEventService.js +4 -18
- package/dist/services/NamedNodeMapService.d.ts +1 -4
- package/dist/services/NamedNodeMapService.js +1 -4
- package/dist/services/NodeService.d.ts +38 -69
- package/dist/services/NodeService.js +39 -72
- package/dist/services/PointerEventService.d.ts +4 -22
- package/dist/services/PointerEventService.js +3 -15
- package/dist/services/ShadowRootService.d.ts +0 -3
- package/dist/services/ShadowRootService.js +0 -3
- package/dist/services/UIEventService.d.ts +5 -17
- package/dist/services/UIEventService.js +3 -11
- package/dist/simulate.d.ts +7 -9
- package/dist/simulate.js +9 -15
- package/package.json +8 -7
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
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
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
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
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
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
|
-
* @
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
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
|
|
21
|
-
* @param
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
6
|
-
* @param
|
|
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;
|