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.
- package/README.md +686 -241
- package/browser/pseudo-dom.js +3576 -735
- package/browser/pseudo-dom.min.js +1 -1
- package/dist/classes/PseudoEventListener.d.ts +96 -96
- package/dist/classes/PseudoEventListener.js +151 -151
- package/dist/classes/PseudoHTMLDocument.d.ts +17 -43
- package/dist/classes/PseudoHTMLDocument.js +24 -94
- package/dist/classes/PseudoHTMLDocument.min.js +1 -1
- package/dist/classes/PseudoNodeList.d.ts +34 -34
- package/dist/classes/PseudoNodeList.js +71 -71
- package/dist/factories/createEvent.d.ts +28 -28
- package/dist/factories/createEvent.js +56 -56
- package/dist/factories/cssSelectAdapter.d.ts +23 -0
- package/dist/factories/cssSelectAdapter.js +87 -0
- package/dist/factories/cssSelectAdapter.min.js +1 -0
- package/dist/factories/eventDefaults.d.ts +31 -31
- package/dist/factories/eventDefaults.js +105 -105
- package/dist/factories/generateDocument.d.ts +11 -11
- package/dist/factories/generateDocument.js +65 -65
- package/dist/factories/generateNodeList.d.ts +9 -9
- package/dist/factories/generateNodeList.js +13 -13
- package/dist/factories/query.d.ts +33 -0
- package/dist/factories/query.js +66 -0
- package/dist/factories/query.min.js +1 -0
- package/dist/functions/activeElement.d.ts +14 -14
- package/dist/functions/activeElement.js +33 -33
- package/dist/functions/getElementById.d.ts +13 -0
- package/dist/functions/getElementById.js +33 -0
- package/dist/functions/getElementById.min.js +1 -0
- package/dist/functions/getParentNodes.d.ts +11 -11
- package/dist/functions/getParentNodes.js +22 -22
- package/dist/functions/getParentNodesFromAttribute.d.ts +14 -14
- package/dist/functions/getParentNodesFromAttribute.js +29 -29
- package/dist/functions/modifierState.d.ts +29 -29
- package/dist/functions/modifierState.js +41 -41
- package/dist/interfaces/PseudoAnimation.d.ts +3 -3
- package/dist/interfaces/PseudoAnimation.js +5 -5
- package/dist/interfaces/PseudoAttr.d.ts +11 -11
- package/dist/interfaces/PseudoAttr.js +5 -5
- package/dist/interfaces/PseudoDOMTokenList.d.ts +16 -16
- package/dist/interfaces/PseudoDOMTokenList.js +5 -5
- package/dist/interfaces/PseudoDocument.d.ts +32 -0
- package/dist/interfaces/PseudoDocument.js +5 -5
- package/dist/interfaces/PseudoDocumentFragment.d.ts +7 -0
- package/dist/interfaces/PseudoDocumentFragment.js +5 -5
- package/dist/interfaces/PseudoElement.d.ts +702 -689
- package/dist/interfaces/PseudoElement.js +5 -5
- package/dist/interfaces/PseudoEvent.d.ts +79 -79
- package/dist/interfaces/PseudoEvent.js +10 -10
- package/dist/interfaces/PseudoEventTarget.d.ts +46 -46
- package/dist/interfaces/PseudoEventTarget.js +5 -5
- package/dist/interfaces/PseudoHTMLCollection.d.ts +23 -23
- package/dist/interfaces/PseudoHTMLCollection.js +5 -5
- package/dist/interfaces/PseudoHTMLElement.d.ts +22 -22
- package/dist/interfaces/PseudoHTMLElement.js +5 -5
- package/dist/interfaces/PseudoHTMLSlotElement.d.ts +3 -3
- package/dist/interfaces/PseudoHTMLSlotElement.js +5 -5
- package/dist/interfaces/PseudoNamedNodeMap.d.ts +11 -11
- package/dist/interfaces/PseudoNamedNodeMap.js +5 -5
- package/dist/interfaces/PseudoNode.d.ts +179 -179
- package/dist/interfaces/PseudoNode.js +5 -5
- package/dist/interfaces/PseudoShadowRoot.d.ts +3 -3
- package/dist/interfaces/PseudoShadowRoot.js +5 -5
- package/dist/main.d.ts +63 -63
- package/dist/main.js +155 -155
- package/dist/services/AnimationService.d.ts +4 -4
- package/dist/services/AnimationService.js +16 -16
- package/dist/services/AttrService.d.ts +37 -37
- package/dist/services/AttrService.js +81 -81
- package/dist/services/CommentService.d.ts +1 -1
- package/dist/services/CommentService.js +13 -13
- package/dist/services/CustomEventService.d.ts +37 -37
- package/dist/services/CustomEventService.js +35 -35
- package/dist/services/DOMTokenListService.d.ts +33 -33
- package/dist/services/DOMTokenListService.js +117 -117
- package/dist/services/DocumentFragmentService.d.ts +8 -0
- package/dist/services/DocumentFragmentService.js +18 -0
- package/dist/services/DocumentFragmentService.min.js +1 -1
- package/dist/services/DocumentService.d.ts +35 -1
- package/dist/services/DocumentService.js +72 -0
- package/dist/services/DocumentService.min.js +1 -1
- package/dist/services/ElementService.d.ts +191 -178
- package/dist/services/ElementService.js +426 -406
- package/dist/services/ElementService.min.js +1 -1
- package/dist/services/EventService.d.ts +120 -120
- package/dist/services/EventService.js +250 -250
- package/dist/services/EventTargetService.d.ts +84 -84
- package/dist/services/EventTargetService.js +232 -232
- package/dist/services/FocusEventService.d.ts +32 -32
- package/dist/services/FocusEventService.js +35 -35
- package/dist/services/HTMLCollectionService.d.ts +54 -49
- package/dist/services/HTMLCollectionService.js +92 -75
- package/dist/services/HTMLCollectionService.min.js +1 -1
- package/dist/services/HTMLElementService.d.ts +57 -57
- package/dist/services/HTMLElementService.js +163 -163
- package/dist/services/HTMLSlotElementService.d.ts +4 -4
- package/dist/services/HTMLSlotElementService.js +9 -9
- package/dist/services/InputEventService.d.ts +41 -41
- package/dist/services/InputEventService.js +47 -47
- package/dist/services/KeyboardEventService.d.ts +70 -70
- package/dist/services/KeyboardEventService.js +86 -86
- package/dist/services/MouseEventService.d.ts +80 -80
- package/dist/services/MouseEventService.js +108 -108
- package/dist/services/NamedNodeMapService.d.ts +23 -23
- package/dist/services/NamedNodeMapService.js +77 -77
- package/dist/services/NodeService.d.ts +297 -271
- package/dist/services/NodeService.js +721 -679
- package/dist/services/NodeService.min.js +1 -1
- package/dist/services/PointerEventService.d.ts +51 -51
- package/dist/services/PointerEventService.js +67 -67
- package/dist/services/ShadowRootService.d.ts +4 -4
- package/dist/services/ShadowRootService.js +9 -9
- package/dist/services/TextService.d.ts +1 -1
- package/dist/services/TextService.js +13 -13
- package/dist/services/UIEventService.d.ts +43 -43
- package/dist/services/UIEventService.js +42 -42
- package/dist/simulate.d.ts +32 -32
- package/dist/simulate.js +115 -115
- package/package.json +4 -3
- package/dist/classes.d.ts +0 -20
- package/dist/classes.js +0 -31
- package/dist/classes.min.js +0 -1
- package/dist/factories/generateNode.d.ts +0 -32
- package/dist/factories/generateNode.js +0 -85
- package/dist/factories/generateNode.min.js +0 -1
- package/dist/factories.d.ts +0 -11
- package/dist/factories.js +0 -27
- package/dist/factories.min.js +0 -1
- package/dist/functions.d.ts +0 -5
- package/dist/functions.js +0 -23
- package/dist/functions.min.js +0 -1
|
@@ -2,137 +2,67 @@
|
|
|
2
2
|
|
|
3
3
|
require('core-js/modules/esnext.iterator.constructor.js')
|
|
4
4
|
require('core-js/modules/esnext.iterator.find.js')
|
|
5
|
-
require('core-js/modules/esnext.iterator.for-each.js')
|
|
6
5
|
Object.defineProperty(exports, '__esModule', {
|
|
7
6
|
value: true
|
|
8
7
|
})
|
|
8
|
+
const DocumentService_1 = require('../services/DocumentService')
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @type {PseudoHTMLElement}
|
|
17
|
-
*/
|
|
18
|
-
const HTMLElementService_1 = require('../services/HTMLElementService')
|
|
19
|
-
const NodeService_1 = require('../services/NodeService')
|
|
20
|
-
const DocumentFragmentService_1 = require('../services/DocumentFragmentService')
|
|
21
|
-
/**
|
|
22
|
-
* 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).
|
|
23
13
|
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
24
14
|
* @class
|
|
25
|
-
* @augments
|
|
15
|
+
* @augments DocumentService
|
|
26
16
|
* @property {PseudoHTMLElement} head - A reference to the Head child element
|
|
27
17
|
* @property {PseudoHTMLElement} body - A reference to the Body child element
|
|
28
|
-
* @property {function} createElement - Generate a new PseudoHTMLElement (which is not in the document until it is appended)
|
|
29
18
|
*/
|
|
30
|
-
class PseudoHTMLDocument extends
|
|
19
|
+
class PseudoHTMLDocument extends DocumentService_1.DocumentService {
|
|
31
20
|
/**
|
|
32
21
|
* The root HTML element is acts as the parent to all HTML elements in the document.
|
|
33
22
|
* @constructor
|
|
34
23
|
*/
|
|
35
24
|
constructor () {
|
|
36
25
|
super()
|
|
37
|
-
const html =
|
|
38
|
-
tagName: 'html'
|
|
39
|
-
})
|
|
26
|
+
const html = this.createElement('html')
|
|
40
27
|
this.appendChild(html)
|
|
41
28
|
/**
|
|
42
29
|
* Create document head element
|
|
43
30
|
* @type {PseudoHTMLElement}
|
|
44
31
|
*/
|
|
45
|
-
this.head =
|
|
46
|
-
tagName: 'head'
|
|
47
|
-
})
|
|
32
|
+
this.head = this.createElement('head')
|
|
48
33
|
html.appendChild(this.head)
|
|
49
34
|
/**
|
|
50
35
|
* Create document body element
|
|
51
36
|
* @type {PseudoHTMLElement}
|
|
52
37
|
*/
|
|
53
|
-
this.body =
|
|
54
|
-
tagName: 'body'
|
|
55
|
-
})
|
|
38
|
+
this.body = this.createElement('body')
|
|
56
39
|
html.appendChild(this.body)
|
|
57
40
|
}
|
|
58
41
|
|
|
59
|
-
get nodeName () {
|
|
60
|
-
return '#document'
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
get nodeType () {
|
|
64
|
-
return NodeService_1.NodeService.DOCUMENT_NODE
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// A document has no text of its own, and setting it does nothing
|
|
68
|
-
get textContent () {
|
|
69
|
-
return null
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
set textContent (text) {}
|
|
73
|
-
/**
|
|
74
|
-
* Make an element of the given type which belongs to this document but is not added anywhere until it is appended.
|
|
75
|
-
* @param {string} tagName - Tag Name is a string representing the type of Dom element this represents
|
|
76
|
-
* @returns {PseudoHTMLElement}
|
|
77
|
-
*/
|
|
78
|
-
createElement (tagName = 'div') {
|
|
79
|
-
// Like the DOM, the new element is not added anywhere: it has no parent until it is appended
|
|
80
|
-
const element = new HTMLElementService_1.HTMLElementService({
|
|
81
|
-
tagName
|
|
82
|
-
})
|
|
83
|
-
element.ownerDocumentStore = this
|
|
84
|
-
return element
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Make a text node which belongs to this document.
|
|
89
|
-
* @param {string} [data=''] The text
|
|
90
|
-
* @returns {TextService}
|
|
91
|
-
*/
|
|
92
|
-
createTextNode (data = '') {
|
|
93
|
-
const text = new NodeService_1.TextService(data)
|
|
94
|
-
text.ownerDocumentStore = this
|
|
95
|
-
return text
|
|
96
|
-
}
|
|
97
|
-
|
|
98
42
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* @returns {
|
|
43
|
+
* A copy of this document with none of its html/head/body (cloneNode, from the inherited cloneShallow hook, fills
|
|
44
|
+
* them back in, deep copies own document's, empty otherwise - see cloneNode).
|
|
45
|
+
* @returns {PseudoHTMLDocument}
|
|
102
46
|
*/
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
* then inserted in one go.
|
|
112
|
-
* @returns {DocumentFragmentService}
|
|
113
|
-
*/
|
|
114
|
-
createDocumentFragment () {
|
|
115
|
-
const fragment = new DocumentFragmentService_1.DocumentFragmentService()
|
|
116
|
-
fragment.ownerDocumentStore = this
|
|
117
|
-
return fragment
|
|
47
|
+
cloneShallow () {
|
|
48
|
+
const copy = new this.constructor()
|
|
49
|
+
while (copy.firstChild) {
|
|
50
|
+
copy.removeChild(copy.firstChild)
|
|
51
|
+
}
|
|
52
|
+
copy.head = null
|
|
53
|
+
copy.body = null
|
|
54
|
+
return copy
|
|
118
55
|
}
|
|
119
56
|
|
|
120
57
|
/**
|
|
121
|
-
* Make a copy of this document. The copy has no parent or listeners, and a deep copy has copies of everything in
|
|
122
|
-
* document (a shallow one is an empty document).
|
|
58
|
+
* Make a copy of this document. The copy has no parent or listeners, and a deep copy has copies of everything in
|
|
59
|
+
* the document (a shallow one is an empty document).
|
|
123
60
|
* @param {boolean} [deep=false] Copy everything in the document as well
|
|
124
|
-
* @returns {
|
|
61
|
+
* @returns {PseudoHTMLDocument}
|
|
125
62
|
*/
|
|
126
63
|
cloneNode (deep = false) {
|
|
127
|
-
const copy =
|
|
128
|
-
// The new document starts out with its own html, head and body, a copy has only what was copied from this one
|
|
129
|
-
while (copy.firstChild) {
|
|
130
|
-
copy.removeChild(copy.firstChild)
|
|
131
|
-
}
|
|
132
|
-
copy.head = null
|
|
133
|
-
copy.body = null
|
|
64
|
+
const copy = super.cloneNode(deep)
|
|
134
65
|
if (deep) {
|
|
135
|
-
Array.from(this.childNodes).forEach(child => copy.appendChild(child.cloneNode(true)))
|
|
136
66
|
const html = Array.from(copy.childNodes).find(child => child.tagName === 'html')
|
|
137
67
|
const inHtml = tagName => html ? Array.from(html.childNodes).find(child => child.tagName === tagName) || null : null
|
|
138
68
|
copy.head = inHtml('head')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.find.js"),
|
|
1
|
+
"use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.find.js"),Object.defineProperty(exports,"__esModule",{value:!0});const DocumentService_1=require("../services/DocumentService");class PseudoHTMLDocument extends DocumentService_1.DocumentService{constructor(){super();const e=this.createElement("html");this.appendChild(e),this.head=this.createElement("head"),e.appendChild(this.head),this.body=this.createElement("body"),e.appendChild(this.body)}cloneShallow(){const e=new this.constructor;for(;e.firstChild;)e.removeChild(e.firstChild);return e.head=null,e.body=null,e}cloneNode(e=!1){const t=super.cloneNode(e);if(e){const e=Array.from(t.childNodes).find(e=>"html"===e.tagName),o=t=>e&&Array.from(e.childNodes).find(e=>e.tagName===t)||null;t.head=o("head"),t.body=o("body")}return t}}exports.default=PseudoHTMLDocument;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Substitute for the NodeList interface.
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
5
|
-
*/
|
|
6
|
-
import { LinkedTreeList } from 'collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList';
|
|
7
|
-
/**
|
|
8
|
-
* A NodeList, like the DOM one, iterates over the nodes themselves (the data stored in each TreeLinker), rather than
|
|
9
|
-
* the linkers that hold them.
|
|
10
|
-
* @class
|
|
11
|
-
* @augments LinkedTreeList
|
|
12
|
-
*/
|
|
13
|
-
export declare class PseudoNodeList extends LinkedTreeList {
|
|
14
|
-
/**
|
|
15
|
-
* Iterate over the nodes in this list.
|
|
16
|
-
* @returns {Iterator}
|
|
17
|
-
*/
|
|
18
|
-
[Symbol.iterator](): Iterator<any>;
|
|
19
|
-
/**
|
|
20
|
-
* Iterate over [index, node] pairs.
|
|
21
|
-
* @returns {Iterator}
|
|
22
|
-
*/
|
|
23
|
-
entries(): Iterator<[number, any]>;
|
|
24
|
-
/**
|
|
25
|
-
* Iterate over the indexes.
|
|
26
|
-
* @returns {Iterator}
|
|
27
|
-
*/
|
|
28
|
-
keys(): Iterator<number>;
|
|
29
|
-
/**
|
|
30
|
-
* Iterate over the nodes.
|
|
31
|
-
* @returns {Iterator}
|
|
32
|
-
*/
|
|
33
|
-
values(): Iterator<any>;
|
|
34
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file Substitute for the NodeList interface.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { LinkedTreeList } from 'collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList';
|
|
7
|
+
/**
|
|
8
|
+
* A NodeList, like the DOM one, iterates over the nodes themselves (the data stored in each TreeLinker), rather than
|
|
9
|
+
* the linkers that hold them.
|
|
10
|
+
* @class
|
|
11
|
+
* @augments LinkedTreeList
|
|
12
|
+
*/
|
|
13
|
+
export declare class PseudoNodeList extends LinkedTreeList {
|
|
14
|
+
/**
|
|
15
|
+
* Iterate over the nodes in this list.
|
|
16
|
+
* @returns {Iterator}
|
|
17
|
+
*/
|
|
18
|
+
[Symbol.iterator](): Iterator<any>;
|
|
19
|
+
/**
|
|
20
|
+
* Iterate over [index, node] pairs.
|
|
21
|
+
* @returns {Iterator}
|
|
22
|
+
*/
|
|
23
|
+
entries(): Iterator<[number, any]>;
|
|
24
|
+
/**
|
|
25
|
+
* Iterate over the indexes.
|
|
26
|
+
* @returns {Iterator}
|
|
27
|
+
*/
|
|
28
|
+
keys(): Iterator<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Iterate over the nodes.
|
|
31
|
+
* @returns {Iterator}
|
|
32
|
+
*/
|
|
33
|
+
values(): Iterator<any>;
|
|
34
|
+
}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.iterator.constructor.js')
|
|
4
|
-
require('core-js/modules/esnext.iterator.map.js')
|
|
5
|
-
Object.defineProperty(exports, '__esModule', {
|
|
6
|
-
value: true
|
|
7
|
-
})
|
|
8
|
-
exports.PseudoNodeList = void 0
|
|
9
|
-
/**
|
|
10
|
-
* @file Substitute for the NodeList interface.
|
|
11
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
12
|
-
* @version 1.0.0
|
|
13
|
-
*/
|
|
14
|
-
const LinkedTreeList_1 = require('collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList')
|
|
15
|
-
/**
|
|
16
|
-
* A NodeList, like the DOM one, iterates over the nodes themselves (the data stored in each TreeLinker), rather than
|
|
17
|
-
* the linkers that hold them.
|
|
18
|
-
* @class
|
|
19
|
-
* @augments LinkedTreeList
|
|
20
|
-
*/
|
|
21
|
-
class PseudoNodeList extends LinkedTreeList_1.LinkedTreeList {
|
|
22
|
-
/**
|
|
23
|
-
* Iterate over the nodes in this list.
|
|
24
|
-
* @returns {Iterator}
|
|
25
|
-
*/
|
|
26
|
-
[Symbol.iterator] () {
|
|
27
|
-
// Walk the nodes of this list only (the linkers of a child list have no children of their own)
|
|
28
|
-
let current = this.first
|
|
29
|
-
return {
|
|
30
|
-
next: () => {
|
|
31
|
-
if (current === null) {
|
|
32
|
-
return {
|
|
33
|
-
done: true,
|
|
34
|
-
value: undefined
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const result = {
|
|
38
|
-
done: false,
|
|
39
|
-
value: current.data
|
|
40
|
-
}
|
|
41
|
-
current = current.next
|
|
42
|
-
return result
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Iterate over [index, node] pairs.
|
|
49
|
-
* @returns {Iterator}
|
|
50
|
-
*/
|
|
51
|
-
entries () {
|
|
52
|
-
return Array.from(this).map((node, index) => [index, node])[Symbol.iterator]()
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Iterate over the indexes.
|
|
57
|
-
* @returns {Iterator}
|
|
58
|
-
*/
|
|
59
|
-
keys () {
|
|
60
|
-
return Array.from(this).map((node, index) => index)[Symbol.iterator]()
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Iterate over the nodes.
|
|
65
|
-
* @returns {Iterator}
|
|
66
|
-
*/
|
|
67
|
-
values () {
|
|
68
|
-
return Array.from(this)[Symbol.iterator]()
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.PseudoNodeList = PseudoNodeList
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.iterator.constructor.js')
|
|
4
|
+
require('core-js/modules/esnext.iterator.map.js')
|
|
5
|
+
Object.defineProperty(exports, '__esModule', {
|
|
6
|
+
value: true
|
|
7
|
+
})
|
|
8
|
+
exports.PseudoNodeList = void 0
|
|
9
|
+
/**
|
|
10
|
+
* @file Substitute for the NodeList interface.
|
|
11
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
12
|
+
* @version 1.0.0
|
|
13
|
+
*/
|
|
14
|
+
const LinkedTreeList_1 = require('collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList')
|
|
15
|
+
/**
|
|
16
|
+
* A NodeList, like the DOM one, iterates over the nodes themselves (the data stored in each TreeLinker), rather than
|
|
17
|
+
* the linkers that hold them.
|
|
18
|
+
* @class
|
|
19
|
+
* @augments LinkedTreeList
|
|
20
|
+
*/
|
|
21
|
+
class PseudoNodeList extends LinkedTreeList_1.LinkedTreeList {
|
|
22
|
+
/**
|
|
23
|
+
* Iterate over the nodes in this list.
|
|
24
|
+
* @returns {Iterator}
|
|
25
|
+
*/
|
|
26
|
+
[Symbol.iterator] () {
|
|
27
|
+
// Walk the nodes of this list only (the linkers of a child list have no children of their own)
|
|
28
|
+
let current = this.first
|
|
29
|
+
return {
|
|
30
|
+
next: () => {
|
|
31
|
+
if (current === null) {
|
|
32
|
+
return {
|
|
33
|
+
done: true,
|
|
34
|
+
value: undefined
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const result = {
|
|
38
|
+
done: false,
|
|
39
|
+
value: current.data
|
|
40
|
+
}
|
|
41
|
+
current = current.next
|
|
42
|
+
return result
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Iterate over [index, node] pairs.
|
|
49
|
+
* @returns {Iterator}
|
|
50
|
+
*/
|
|
51
|
+
entries () {
|
|
52
|
+
return Array.from(this).map((node, index) => [index, node])[Symbol.iterator]()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Iterate over the indexes.
|
|
57
|
+
* @returns {Iterator}
|
|
58
|
+
*/
|
|
59
|
+
keys () {
|
|
60
|
+
return Array.from(this).map((node, index) => index)[Symbol.iterator]()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Iterate over the nodes.
|
|
65
|
+
* @returns {Iterator}
|
|
66
|
+
*/
|
|
67
|
+
values () {
|
|
68
|
+
return Array.from(this)[Symbol.iterator]()
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.PseudoNodeList = PseudoNodeList
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { EventService } from '../services/EventService';
|
|
2
|
-
/**
|
|
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
|
-
*/
|
|
9
|
-
export type CreateEventOptions = {
|
|
10
|
-
browser?: boolean;
|
|
11
|
-
trusted?: boolean;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Create an event of the kind which suits its type (a click is a MouseEvent, a keydown a KeyboardEvent, ...).
|
|
15
|
-
* By default this is like using the constructor of the event in a script: nothing bubbles or can be cancelled unless
|
|
16
|
-
* the init says so, and the event is not trusted. With browser: true the event is created the way the browser creates
|
|
17
|
-
* it, using the standard options for its type (see eventDefaults), and trusted: true makes it look like it came from a
|
|
18
|
-
* 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}
|
|
24
|
-
*/
|
|
25
|
-
export declare const createEvent: (type: string, init?: {
|
|
26
|
-
[option: string]: any;
|
|
27
|
-
}, { browser, trusted }?: CreateEventOptions) => EventService;
|
|
28
|
-
export default createEvent;
|
|
1
|
+
import { EventService } from '../services/EventService';
|
|
2
|
+
/**
|
|
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
|
+
*/
|
|
9
|
+
export type CreateEventOptions = {
|
|
10
|
+
browser?: boolean;
|
|
11
|
+
trusted?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Create an event of the kind which suits its type (a click is a MouseEvent, a keydown a KeyboardEvent, ...).
|
|
15
|
+
* By default this is like using the constructor of the event in a script: nothing bubbles or can be cancelled unless
|
|
16
|
+
* the init says so, and the event is not trusted. With browser: true the event is created the way the browser creates
|
|
17
|
+
* it, using the standard options for its type (see eventDefaults), and trusted: true makes it look like it came from a
|
|
18
|
+
* 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}
|
|
24
|
+
*/
|
|
25
|
+
export declare const createEvent: (type: string, init?: {
|
|
26
|
+
[option: string]: any;
|
|
27
|
+
}, { browser, trusted }?: CreateEventOptions) => EventService;
|
|
28
|
+
export default createEvent;
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.createEvent = void 0
|
|
7
|
-
const EventService_1 = require('../services/EventService')
|
|
8
|
-
const UIEventService_1 = require('../services/UIEventService')
|
|
9
|
-
const MouseEventService_1 = require('../services/MouseEventService')
|
|
10
|
-
const PointerEventService_1 = require('../services/PointerEventService')
|
|
11
|
-
const KeyboardEventService_1 = require('../services/KeyboardEventService')
|
|
12
|
-
const FocusEventService_1 = require('../services/FocusEventService')
|
|
13
|
-
const InputEventService_1 = require('../services/InputEventService')
|
|
14
|
-
const CustomEventService_1 = require('../services/CustomEventService')
|
|
15
|
-
const eventDefaults_1 = require('./eventDefaults')
|
|
16
|
-
const eventClasses = {
|
|
17
|
-
Event: EventService_1.EventService,
|
|
18
|
-
UIEvent: UIEventService_1.UIEventService,
|
|
19
|
-
MouseEvent: MouseEventService_1.MouseEventService,
|
|
20
|
-
PointerEvent: PointerEventService_1.PointerEventService,
|
|
21
|
-
KeyboardEvent: KeyboardEventService_1.KeyboardEventService,
|
|
22
|
-
FocusEvent: FocusEventService_1.FocusEventService,
|
|
23
|
-
InputEvent: InputEventService_1.InputEventService,
|
|
24
|
-
CustomEvent: CustomEventService_1.CustomEventService
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Create an event of the kind which suits its type (a click is a MouseEvent, a keydown a KeyboardEvent, ...).
|
|
28
|
-
* By default this is like using the constructor of the event in a script: nothing bubbles or can be cancelled unless
|
|
29
|
-
* the init says so, and the event is not trusted. With browser: true the event is created the way the browser creates
|
|
30
|
-
* it, using the standard options for its type (see eventDefaults), and trusted: true makes it look like it came from a
|
|
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}
|
|
37
|
-
*/
|
|
38
|
-
const createEvent = (type, init = {}, {
|
|
39
|
-
browser = false,
|
|
40
|
-
trusted = false
|
|
41
|
-
} = {}) => {
|
|
42
|
-
const definition = eventDefaults_1.eventDefaults[type]
|
|
43
|
-
const options = browser && definition
|
|
44
|
-
? Object.assign({
|
|
45
|
-
bubbles: definition.bubbles,
|
|
46
|
-
cancelable: definition.cancelable,
|
|
47
|
-
composed: definition.composed
|
|
48
|
-
}, init)
|
|
49
|
-
: init
|
|
50
|
-
const EventClass = eventClasses[definition ? definition.interface : 'Event']
|
|
51
|
-
const event = new EventClass(type, options)
|
|
52
|
-
event.inner.trusted = trusted
|
|
53
|
-
return event
|
|
54
|
-
}
|
|
55
|
-
exports.createEvent = createEvent
|
|
56
|
-
exports.default = exports.createEvent
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.createEvent = void 0
|
|
7
|
+
const EventService_1 = require('../services/EventService')
|
|
8
|
+
const UIEventService_1 = require('../services/UIEventService')
|
|
9
|
+
const MouseEventService_1 = require('../services/MouseEventService')
|
|
10
|
+
const PointerEventService_1 = require('../services/PointerEventService')
|
|
11
|
+
const KeyboardEventService_1 = require('../services/KeyboardEventService')
|
|
12
|
+
const FocusEventService_1 = require('../services/FocusEventService')
|
|
13
|
+
const InputEventService_1 = require('../services/InputEventService')
|
|
14
|
+
const CustomEventService_1 = require('../services/CustomEventService')
|
|
15
|
+
const eventDefaults_1 = require('./eventDefaults')
|
|
16
|
+
const eventClasses = {
|
|
17
|
+
Event: EventService_1.EventService,
|
|
18
|
+
UIEvent: UIEventService_1.UIEventService,
|
|
19
|
+
MouseEvent: MouseEventService_1.MouseEventService,
|
|
20
|
+
PointerEvent: PointerEventService_1.PointerEventService,
|
|
21
|
+
KeyboardEvent: KeyboardEventService_1.KeyboardEventService,
|
|
22
|
+
FocusEvent: FocusEventService_1.FocusEventService,
|
|
23
|
+
InputEvent: InputEventService_1.InputEventService,
|
|
24
|
+
CustomEvent: CustomEventService_1.CustomEventService
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create an event of the kind which suits its type (a click is a MouseEvent, a keydown a KeyboardEvent, ...).
|
|
28
|
+
* By default this is like using the constructor of the event in a script: nothing bubbles or can be cancelled unless
|
|
29
|
+
* the init says so, and the event is not trusted. With browser: true the event is created the way the browser creates
|
|
30
|
+
* it, using the standard options for its type (see eventDefaults), and trusted: true makes it look like it came from a
|
|
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}
|
|
37
|
+
*/
|
|
38
|
+
const createEvent = (type, init = {}, {
|
|
39
|
+
browser = false,
|
|
40
|
+
trusted = false
|
|
41
|
+
} = {}) => {
|
|
42
|
+
const definition = eventDefaults_1.eventDefaults[type]
|
|
43
|
+
const options = browser && definition
|
|
44
|
+
? Object.assign({
|
|
45
|
+
bubbles: definition.bubbles,
|
|
46
|
+
cancelable: definition.cancelable,
|
|
47
|
+
composed: definition.composed
|
|
48
|
+
}, init)
|
|
49
|
+
: init
|
|
50
|
+
const EventClass = eventClasses[definition ? definition.interface : 'Event']
|
|
51
|
+
const event = new EventClass(type, options)
|
|
52
|
+
event.inner.trusted = trusted
|
|
53
|
+
return event
|
|
54
|
+
}
|
|
55
|
+
exports.createEvent = createEvent
|
|
56
|
+
exports.default = exports.createEvent
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps pseudo-dom's own Node / Element API onto the Adapter interface css-select needs to query a tree which is not
|
|
3
|
+
* domutils' own (css-select's own Adapter<Node, ElementNode> type). Every method here is one pseudo-dom already has
|
|
4
|
+
* under a different name; nothing here reimplements DOM behaviour.
|
|
5
|
+
* @memberOf module:factories
|
|
6
|
+
* @type {Object}
|
|
7
|
+
*/
|
|
8
|
+
export declare const cssSelectAdapter: {
|
|
9
|
+
isTag: (node: any) => boolean;
|
|
10
|
+
existsOne: (test: (elem: any) => boolean, elems: Array<any>) => boolean;
|
|
11
|
+
getAttributeValue: (elem: any, name: string) => string | undefined;
|
|
12
|
+
getChildren: (node: any) => Array<any>;
|
|
13
|
+
getName: (elem: any) => string;
|
|
14
|
+
getParent: (node: any) => any | null;
|
|
15
|
+
getSiblings: (node: any) => Array<any>;
|
|
16
|
+
prevElementSibling: (node: any) => any | null;
|
|
17
|
+
getText: (node: any) => string;
|
|
18
|
+
hasAttrib: (elem: any, name: string) => boolean;
|
|
19
|
+
removeSubsets: (nodes: Array<any>) => Array<any>;
|
|
20
|
+
findAll: (test: (elem: any) => boolean, nodes: Array<any>) => Array<any>;
|
|
21
|
+
findOne: (test: (elem: any) => boolean, nodes: Array<any>) => any | null;
|
|
22
|
+
};
|
|
23
|
+
export default cssSelectAdapter;
|