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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.closest = exports.matches = exports.querySelector = exports.querySelectorAll = void 0
|
|
7
|
+
/**
|
|
8
|
+
* @file Selector queries (querySelector, querySelectorAll, matches, closest), built on css-select and the
|
|
9
|
+
* cssSelectAdapter which lets it query pseudo-dom's own tree.
|
|
10
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
11
|
+
* @version 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
const css_select_1 = require('css-select')
|
|
14
|
+
const cssSelectAdapter_1 = require('./cssSelectAdapter')
|
|
15
|
+
/**
|
|
16
|
+
* All of the elements below (not including) scope which match the selector, in tree order.
|
|
17
|
+
* @memberOf module:factories
|
|
18
|
+
* @param {string} selector A CSS selector
|
|
19
|
+
* @param {*} scope The node to search below
|
|
20
|
+
* @returns {Array<*>}
|
|
21
|
+
*/
|
|
22
|
+
const querySelectorAll = (selector, scope) => (0, css_select_1.selectAll)(selector, scope, {
|
|
23
|
+
adapter: cssSelectAdapter_1.cssSelectAdapter
|
|
24
|
+
})
|
|
25
|
+
exports.querySelectorAll = querySelectorAll
|
|
26
|
+
/**
|
|
27
|
+
* The first element below (not including) scope which matches the selector, in tree order, or null when there is none.
|
|
28
|
+
* @memberOf module:factories
|
|
29
|
+
* @param {string} selector A CSS selector
|
|
30
|
+
* @param {*} scope The node to search below
|
|
31
|
+
* @returns {*|null}
|
|
32
|
+
*/
|
|
33
|
+
const querySelector = (selector, scope) => (0, css_select_1.selectOne)(selector, scope, {
|
|
34
|
+
adapter: cssSelectAdapter_1.cssSelectAdapter
|
|
35
|
+
})
|
|
36
|
+
exports.querySelector = querySelector
|
|
37
|
+
/**
|
|
38
|
+
* Whether an element itself (not its descendants) matches the selector.
|
|
39
|
+
* @memberOf module:factories
|
|
40
|
+
* @param {*} element The element to test
|
|
41
|
+
* @param {string} selector A CSS selector
|
|
42
|
+
* @returns {boolean}
|
|
43
|
+
*/
|
|
44
|
+
const matches = (element, selector) => (0, css_select_1.is)(element, selector, {
|
|
45
|
+
adapter: cssSelectAdapter_1.cssSelectAdapter
|
|
46
|
+
})
|
|
47
|
+
exports.matches = matches
|
|
48
|
+
/**
|
|
49
|
+
* The nearest ancestor of an element (starting with the element itself) which matches the selector, or null when
|
|
50
|
+
* none of them do.
|
|
51
|
+
* @memberOf module:factories
|
|
52
|
+
* @param {*} element The element to start from
|
|
53
|
+
* @param {string} selector A CSS selector
|
|
54
|
+
* @returns {*|null}
|
|
55
|
+
*/
|
|
56
|
+
const closest = (element, selector) => {
|
|
57
|
+
let current = element
|
|
58
|
+
while (current && cssSelectAdapter_1.cssSelectAdapter.isTag(current)) {
|
|
59
|
+
if ((0, exports.matches)(current, selector)) {
|
|
60
|
+
return current
|
|
61
|
+
}
|
|
62
|
+
current = current.parentNode
|
|
63
|
+
}
|
|
64
|
+
return null
|
|
65
|
+
}
|
|
66
|
+
exports.closest = closest
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.closest=exports.matches=exports.querySelector=exports.querySelectorAll=void 0;const css_select_1=require("css-select"),cssSelectAdapter_1=require("./cssSelectAdapter"),querySelectorAll=(e,s)=>(0,css_select_1.selectAll)(e,s,{adapter:cssSelectAdapter_1.cssSelectAdapter});exports.querySelectorAll=querySelectorAll;const querySelector=(e,s)=>(0,css_select_1.selectOne)(e,s,{adapter:cssSelectAdapter_1.cssSelectAdapter});exports.querySelector=querySelector;const matches=(e,s)=>(0,css_select_1.is)(e,s,{adapter:cssSelectAdapter_1.cssSelectAdapter});exports.matches=matches;const closest=(e,s)=>{let t=e;for(;t&&cssSelectAdapter_1.cssSelectAdapter.isTag(t);){if((0,exports.matches)(t,s))return t;t=t.parentNode}return null};exports.closest=closest;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find the element which has the focus in a tree.
|
|
3
|
-
* @function getActiveElement
|
|
4
|
-
* @param {Object} root The root node of the tree
|
|
5
|
-
* @returns {Object|null}
|
|
6
|
-
*/
|
|
7
|
-
export declare const getActiveElement: (root: object) => any | null;
|
|
8
|
-
/**
|
|
9
|
-
* Remember the element which has the focus in a tree.
|
|
10
|
-
* @function setActiveElement
|
|
11
|
-
* @param {Object} root The root node of the tree
|
|
12
|
-
* @param {Object|null} element The element which now has the focus, or null when nothing has it
|
|
13
|
-
*/
|
|
14
|
-
export declare const setActiveElement: (root: object, element: any | null) => void;
|
|
1
|
+
/**
|
|
2
|
+
* Find the element which has the focus in a tree.
|
|
3
|
+
* @function getActiveElement
|
|
4
|
+
* @param {Object} root The root node of the tree
|
|
5
|
+
* @returns {Object|null}
|
|
6
|
+
*/
|
|
7
|
+
export declare const getActiveElement: (root: object) => any | null;
|
|
8
|
+
/**
|
|
9
|
+
* Remember the element which has the focus in a tree.
|
|
10
|
+
* @function setActiveElement
|
|
11
|
+
* @param {Object} root The root node of the tree
|
|
12
|
+
* @param {Object|null} element The element which now has the focus, or null when nothing has it
|
|
13
|
+
*/
|
|
14
|
+
export declare const setActiveElement: (root: object, element: any | null) => void;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.weak-map.delete-all.js')
|
|
4
|
-
Object.defineProperty(exports, '__esModule', {
|
|
5
|
-
value: true
|
|
6
|
-
})
|
|
7
|
-
exports.setActiveElement = exports.getActiveElement = void 0
|
|
8
|
-
/**
|
|
9
|
-
* The element which has the focus, kept for each tree (the root node of the tree it is in), like document.activeElement.
|
|
10
|
-
*/
|
|
11
|
-
const focused = new WeakMap()
|
|
12
|
-
/**
|
|
13
|
-
* Find the element which has the focus in a tree.
|
|
14
|
-
* @function getActiveElement
|
|
15
|
-
* @param {Object} root The root node of the tree
|
|
16
|
-
* @returns {Object|null}
|
|
17
|
-
*/
|
|
18
|
-
const getActiveElement = root => focused.get(root) || null
|
|
19
|
-
exports.getActiveElement = getActiveElement
|
|
20
|
-
/**
|
|
21
|
-
* Remember the element which has the focus in a tree.
|
|
22
|
-
* @function setActiveElement
|
|
23
|
-
* @param {Object} root The root node of the tree
|
|
24
|
-
* @param {Object|null} element The element which now has the focus, or null when nothing has it
|
|
25
|
-
*/
|
|
26
|
-
const setActiveElement = (root, element) => {
|
|
27
|
-
if (element === null) {
|
|
28
|
-
focused.delete(root)
|
|
29
|
-
} else {
|
|
30
|
-
focused.set(root, element)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.setActiveElement = setActiveElement
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.weak-map.delete-all.js')
|
|
4
|
+
Object.defineProperty(exports, '__esModule', {
|
|
5
|
+
value: true
|
|
6
|
+
})
|
|
7
|
+
exports.setActiveElement = exports.getActiveElement = void 0
|
|
8
|
+
/**
|
|
9
|
+
* The element which has the focus, kept for each tree (the root node of the tree it is in), like document.activeElement.
|
|
10
|
+
*/
|
|
11
|
+
const focused = new WeakMap()
|
|
12
|
+
/**
|
|
13
|
+
* Find the element which has the focus in a tree.
|
|
14
|
+
* @function getActiveElement
|
|
15
|
+
* @param {Object} root The root node of the tree
|
|
16
|
+
* @returns {Object|null}
|
|
17
|
+
*/
|
|
18
|
+
const getActiveElement = root => focused.get(root) || null
|
|
19
|
+
exports.getActiveElement = getActiveElement
|
|
20
|
+
/**
|
|
21
|
+
* Remember the element which has the focus in a tree.
|
|
22
|
+
* @function setActiveElement
|
|
23
|
+
* @param {Object} root The root node of the tree
|
|
24
|
+
* @param {Object|null} element The element which now has the focus, or null when nothing has it
|
|
25
|
+
*/
|
|
26
|
+
const setActiveElement = (root, element) => {
|
|
27
|
+
if (element === null) {
|
|
28
|
+
focused.delete(root)
|
|
29
|
+
} else {
|
|
30
|
+
focused.set(root, element)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.setActiveElement = setActiveElement
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NodeService } from '../services/NodeService';
|
|
2
|
+
import { PseudoElement } from '../interfaces/PseudoElement';
|
|
3
|
+
/**
|
|
4
|
+
* The first element, in tree order, below (not including) the given node whose id matches the given value, or null
|
|
5
|
+
* when there is none. Shared by Document and DocumentFragment, which both implement the DOM's NonElementParentNode
|
|
6
|
+
* mixin (so ShadowRoot, a DocumentFragment, gets it too).
|
|
7
|
+
* @memberOf module:functions
|
|
8
|
+
* @param {NodeService} root The node to search below
|
|
9
|
+
* @param {string} id
|
|
10
|
+
* @returns {PseudoElement|null}
|
|
11
|
+
*/
|
|
12
|
+
declare const getElementById: (root: NodeService, id: string) => PseudoElement | null;
|
|
13
|
+
export default getElementById;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
const NodeService_1 = require('../services/NodeService')
|
|
7
|
+
/**
|
|
8
|
+
* The first element, in tree order, below (not including) the given node whose id matches the given value, or null
|
|
9
|
+
* when there is none. Shared by Document and DocumentFragment, which both implement the DOM's NonElementParentNode
|
|
10
|
+
* mixin (so ShadowRoot, a DocumentFragment, gets it too).
|
|
11
|
+
* @memberOf module:functions
|
|
12
|
+
* @param {NodeService} root The node to search below
|
|
13
|
+
* @param {string} id
|
|
14
|
+
* @returns {PseudoElement|null}
|
|
15
|
+
*/
|
|
16
|
+
const getElementById = (root, id) => {
|
|
17
|
+
const search = node => {
|
|
18
|
+
for (const child of Array.from(node.childNodes)) {
|
|
19
|
+
if (child.nodeType === NodeService_1.NodeService.ELEMENT_NODE) {
|
|
20
|
+
if (child.id === id) {
|
|
21
|
+
return child
|
|
22
|
+
}
|
|
23
|
+
const found = search(child)
|
|
24
|
+
if (found) {
|
|
25
|
+
return found
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
return search(root)
|
|
32
|
+
}
|
|
33
|
+
exports.default = getElementById
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const NodeService_1=require("../services/NodeService"),getElementById=(e,r)=>{const t=e=>{for(const o of Array.from(e.childNodes))if(o.nodeType===NodeService_1.NodeService.ELEMENT_NODE){if(o.id===r)return o;const e=t(o);if(e)return e}return null};return t(e)};exports.default=getElementById;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { PseudoNode } from '../interfaces/PseudoNode';
|
|
2
|
-
import { PseudoEventTarget } from '../interfaces/PseudoEventTarget';
|
|
3
|
-
/**
|
|
4
|
-
* Get all of the ancestors of a node, starting with the root of the tree and ending with the node's own parent (the
|
|
5
|
-
* order in which an event travels down through them). A node which has no parent has no ancestors.
|
|
6
|
-
* @function getParentNodes
|
|
7
|
-
* @param {PseudoEventTarget|PseudoNode|*} node The node to find the ancestors of
|
|
8
|
-
* @returns {Array<PseudoNode>}
|
|
9
|
-
*/
|
|
10
|
-
declare const getParentNodes: (node: PseudoEventTarget | PseudoNode | any) => Array<PseudoNode>;
|
|
11
|
-
export default getParentNodes;
|
|
1
|
+
import { PseudoNode } from '../interfaces/PseudoNode';
|
|
2
|
+
import { PseudoEventTarget } from '../interfaces/PseudoEventTarget';
|
|
3
|
+
/**
|
|
4
|
+
* Get all of the ancestors of a node, starting with the root of the tree and ending with the node's own parent (the
|
|
5
|
+
* order in which an event travels down through them). A node which has no parent has no ancestors.
|
|
6
|
+
* @function getParentNodes
|
|
7
|
+
* @param {PseudoEventTarget|PseudoNode|*} node The node to find the ancestors of
|
|
8
|
+
* @returns {Array<PseudoNode>}
|
|
9
|
+
*/
|
|
10
|
+
declare const getParentNodes: (node: PseudoEventTarget | PseudoNode | any) => Array<PseudoNode>;
|
|
11
|
+
export default getParentNodes;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
/**
|
|
7
|
-
* Get all of the ancestors of a node, starting with the root of the tree and ending with the node's own parent (the
|
|
8
|
-
* order in which an event travels down through them). A node which has no parent has no ancestors.
|
|
9
|
-
* @function getParentNodes
|
|
10
|
-
* @param {PseudoEventTarget|PseudoNode|*} node The node to find the ancestors of
|
|
11
|
-
* @returns {Array<PseudoNode>}
|
|
12
|
-
*/
|
|
13
|
-
const getParentNodes = node => {
|
|
14
|
-
const parents = []
|
|
15
|
-
let current = node && node.parentNode ? node.parentNode : null
|
|
16
|
-
while (current) {
|
|
17
|
-
parents.unshift(current)
|
|
18
|
-
current = current.parentNode
|
|
19
|
-
}
|
|
20
|
-
return parents
|
|
21
|
-
}
|
|
22
|
-
exports.default = getParentNodes
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
/**
|
|
7
|
+
* Get all of the ancestors of a node, starting with the root of the tree and ending with the node's own parent (the
|
|
8
|
+
* order in which an event travels down through them). A node which has no parent has no ancestors.
|
|
9
|
+
* @function getParentNodes
|
|
10
|
+
* @param {PseudoEventTarget|PseudoNode|*} node The node to find the ancestors of
|
|
11
|
+
* @returns {Array<PseudoNode>}
|
|
12
|
+
*/
|
|
13
|
+
const getParentNodes = node => {
|
|
14
|
+
const parents = []
|
|
15
|
+
let current = node && node.parentNode ? node.parentNode : null
|
|
16
|
+
while (current) {
|
|
17
|
+
parents.unshift(current)
|
|
18
|
+
current = current.parentNode
|
|
19
|
+
}
|
|
20
|
+
return parents
|
|
21
|
+
}
|
|
22
|
+
exports.default = getParentNodes
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { PseudoNode } from '../interfaces/PseudoNode';
|
|
2
|
-
import { PseudoEventTarget } from '../interfaces/PseudoEventTarget';
|
|
3
|
-
/**
|
|
4
|
-
* A selector function for retrieving existing parent PseudoNode from the given child item.
|
|
5
|
-
* This function will check all the parents starting from node, and scan the attributes
|
|
6
|
-
* property for matches. The return array contains all matching parent ancestors, starting with the root of the tree.
|
|
7
|
-
* @function getParentNodesFromAttribute
|
|
8
|
-
* @param {string} attr The property to compare on each ancestor (a missing property counts as false)
|
|
9
|
-
* @param {boolean|number|string} value The value the property must have
|
|
10
|
-
* @param {PseudoEventTarget|PseudoNode|*} node The node to find the matching ancestors of
|
|
11
|
-
* @returns {Array.<PseudoNode>}
|
|
12
|
-
*/
|
|
13
|
-
declare const getParentNodesFromAttribute: (attr: string, value: boolean | number | string, node: PseudoEventTarget | PseudoNode | any) => Array<PseudoNode>;
|
|
14
|
-
export default getParentNodesFromAttribute;
|
|
1
|
+
import { PseudoNode } from '../interfaces/PseudoNode';
|
|
2
|
+
import { PseudoEventTarget } from '../interfaces/PseudoEventTarget';
|
|
3
|
+
/**
|
|
4
|
+
* A selector function for retrieving existing parent PseudoNode from the given child item.
|
|
5
|
+
* This function will check all the parents starting from node, and scan the attributes
|
|
6
|
+
* property for matches. The return array contains all matching parent ancestors, starting with the root of the tree.
|
|
7
|
+
* @function getParentNodesFromAttribute
|
|
8
|
+
* @param {string} attr The property to compare on each ancestor (a missing property counts as false)
|
|
9
|
+
* @param {boolean|number|string} value The value the property must have
|
|
10
|
+
* @param {PseudoEventTarget|PseudoNode|*} node The node to find the matching ancestors of
|
|
11
|
+
* @returns {Array.<PseudoNode>}
|
|
12
|
+
*/
|
|
13
|
+
declare const getParentNodesFromAttribute: (attr: string, value: boolean | number | string, node: PseudoEventTarget | PseudoNode | any) => Array<PseudoNode>;
|
|
14
|
+
export default getParentNodesFromAttribute;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.iterator.constructor.js')
|
|
4
|
-
require('core-js/modules/esnext.iterator.filter.js')
|
|
5
|
-
const __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
6
|
-
return mod && mod.__esModule
|
|
7
|
-
? mod
|
|
8
|
-
: {
|
|
9
|
-
default: mod
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
|
13
|
-
value: true
|
|
14
|
-
})
|
|
15
|
-
const getParentNodes_1 = __importDefault(require('./getParentNodes'))
|
|
16
|
-
/**
|
|
17
|
-
* A selector function for retrieving existing parent PseudoNode from the given child item.
|
|
18
|
-
* This function will check all the parents starting from node, and scan the attributes
|
|
19
|
-
* property for matches. The return array contains all matching parent ancestors, starting with the root of the tree.
|
|
20
|
-
* @function getParentNodesFromAttribute
|
|
21
|
-
* @param {string} attr The property to compare on each ancestor (a missing property counts as false)
|
|
22
|
-
* @param {boolean|number|string} value The value the property must have
|
|
23
|
-
* @param {PseudoEventTarget|PseudoNode|*} node The node to find the matching ancestors of
|
|
24
|
-
* @returns {Array.<PseudoNode>}
|
|
25
|
-
*/
|
|
26
|
-
const getParentNodesFromAttribute = (attr, value, node) => {
|
|
27
|
-
return (0, getParentNodes_1.default)(node).filter(parent => (parent[attr] || false) === value)
|
|
28
|
-
}
|
|
29
|
-
exports.default = getParentNodesFromAttribute
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.iterator.constructor.js')
|
|
4
|
+
require('core-js/modules/esnext.iterator.filter.js')
|
|
5
|
+
const __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
6
|
+
return mod && mod.__esModule
|
|
7
|
+
? mod
|
|
8
|
+
: {
|
|
9
|
+
default: mod
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
})
|
|
15
|
+
const getParentNodes_1 = __importDefault(require('./getParentNodes'))
|
|
16
|
+
/**
|
|
17
|
+
* A selector function for retrieving existing parent PseudoNode from the given child item.
|
|
18
|
+
* This function will check all the parents starting from node, and scan the attributes
|
|
19
|
+
* property for matches. The return array contains all matching parent ancestors, starting with the root of the tree.
|
|
20
|
+
* @function getParentNodesFromAttribute
|
|
21
|
+
* @param {string} attr The property to compare on each ancestor (a missing property counts as false)
|
|
22
|
+
* @param {boolean|number|string} value The value the property must have
|
|
23
|
+
* @param {PseudoEventTarget|PseudoNode|*} node The node to find the matching ancestors of
|
|
24
|
+
* @returns {Array.<PseudoNode>}
|
|
25
|
+
*/
|
|
26
|
+
const getParentNodesFromAttribute = (attr, value, node) => {
|
|
27
|
+
return (0, getParentNodes_1.default)(node).filter(parent => (parent[attr] || false) === value)
|
|
28
|
+
}
|
|
29
|
+
exports.default = getParentNodesFromAttribute
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The modifier keys which were held down when a mouse or keyboard event happened.
|
|
3
|
-
* @typedef {Object} ModifierKeys
|
|
4
|
-
* @property {boolean} ctrlKey
|
|
5
|
-
* @property {boolean} shiftKey
|
|
6
|
-
* @property {boolean} altKey
|
|
7
|
-
* @property {boolean} metaKey
|
|
8
|
-
*/
|
|
9
|
-
export type ModifierKeys = {
|
|
10
|
-
ctrlKey: boolean;
|
|
11
|
-
shiftKey: boolean;
|
|
12
|
-
altKey: boolean;
|
|
13
|
-
metaKey: boolean;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Pick the modifier keys out of the init object of an event.
|
|
17
|
-
* @function modifierKeys
|
|
18
|
-
* @param {Object} [init={}] The init of an event
|
|
19
|
-
* @returns {ModifierKeys}
|
|
20
|
-
*/
|
|
21
|
-
export declare const modifierKeys: (init?: any) => ModifierKeys;
|
|
22
|
-
/**
|
|
23
|
-
* Answer getModifierState for a set of held modifier keys.
|
|
24
|
-
* @function modifierState
|
|
25
|
-
* @param {ModifierKeys} keys The modifier keys which were held down
|
|
26
|
-
* @param {string} key The name of the modifier (Control, Shift, Alt or Meta)
|
|
27
|
-
* @returns {boolean}
|
|
28
|
-
*/
|
|
29
|
-
export declare const modifierState: (keys: ModifierKeys, key: string) => boolean;
|
|
1
|
+
/**
|
|
2
|
+
* The modifier keys which were held down when a mouse or keyboard event happened.
|
|
3
|
+
* @typedef {Object} ModifierKeys
|
|
4
|
+
* @property {boolean} ctrlKey
|
|
5
|
+
* @property {boolean} shiftKey
|
|
6
|
+
* @property {boolean} altKey
|
|
7
|
+
* @property {boolean} metaKey
|
|
8
|
+
*/
|
|
9
|
+
export type ModifierKeys = {
|
|
10
|
+
ctrlKey: boolean;
|
|
11
|
+
shiftKey: boolean;
|
|
12
|
+
altKey: boolean;
|
|
13
|
+
metaKey: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Pick the modifier keys out of the init object of an event.
|
|
17
|
+
* @function modifierKeys
|
|
18
|
+
* @param {Object} [init={}] The init of an event
|
|
19
|
+
* @returns {ModifierKeys}
|
|
20
|
+
*/
|
|
21
|
+
export declare const modifierKeys: (init?: any) => ModifierKeys;
|
|
22
|
+
/**
|
|
23
|
+
* Answer getModifierState for a set of held modifier keys.
|
|
24
|
+
* @function modifierState
|
|
25
|
+
* @param {ModifierKeys} keys The modifier keys which were held down
|
|
26
|
+
* @param {string} key The name of the modifier (Control, Shift, Alt or Meta)
|
|
27
|
+
* @returns {boolean}
|
|
28
|
+
*/
|
|
29
|
+
export declare const modifierState: (keys: ModifierKeys, key: string) => boolean;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.modifierState = exports.modifierKeys = void 0
|
|
7
|
-
/**
|
|
8
|
-
* Pick the modifier keys out of the init object of an event.
|
|
9
|
-
* @function modifierKeys
|
|
10
|
-
* @param {Object} [init={}] The init of an event
|
|
11
|
-
* @returns {ModifierKeys}
|
|
12
|
-
*/
|
|
13
|
-
const modifierKeys = (init = {}) => ({
|
|
14
|
-
ctrlKey: !!init.ctrlKey,
|
|
15
|
-
shiftKey: !!init.shiftKey,
|
|
16
|
-
altKey: !!init.altKey,
|
|
17
|
-
metaKey: !!init.metaKey
|
|
18
|
-
})
|
|
19
|
-
exports.modifierKeys = modifierKeys
|
|
20
|
-
/**
|
|
21
|
-
* Answer getModifierState for a set of held modifier keys.
|
|
22
|
-
* @function modifierState
|
|
23
|
-
* @param {ModifierKeys} keys The modifier keys which were held down
|
|
24
|
-
* @param {string} key The name of the modifier (Control, Shift, Alt or Meta)
|
|
25
|
-
* @returns {boolean}
|
|
26
|
-
*/
|
|
27
|
-
const modifierState = (keys, key) => {
|
|
28
|
-
switch (key) {
|
|
29
|
-
case 'Control':
|
|
30
|
-
return keys.ctrlKey
|
|
31
|
-
case 'Shift':
|
|
32
|
-
return keys.shiftKey
|
|
33
|
-
case 'Alt':
|
|
34
|
-
return keys.altKey
|
|
35
|
-
case 'Meta':
|
|
36
|
-
return keys.metaKey
|
|
37
|
-
default:
|
|
38
|
-
return false
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.modifierState = modifierState
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.modifierState = exports.modifierKeys = void 0
|
|
7
|
+
/**
|
|
8
|
+
* Pick the modifier keys out of the init object of an event.
|
|
9
|
+
* @function modifierKeys
|
|
10
|
+
* @param {Object} [init={}] The init of an event
|
|
11
|
+
* @returns {ModifierKeys}
|
|
12
|
+
*/
|
|
13
|
+
const modifierKeys = (init = {}) => ({
|
|
14
|
+
ctrlKey: !!init.ctrlKey,
|
|
15
|
+
shiftKey: !!init.shiftKey,
|
|
16
|
+
altKey: !!init.altKey,
|
|
17
|
+
metaKey: !!init.metaKey
|
|
18
|
+
})
|
|
19
|
+
exports.modifierKeys = modifierKeys
|
|
20
|
+
/**
|
|
21
|
+
* Answer getModifierState for a set of held modifier keys.
|
|
22
|
+
* @function modifierState
|
|
23
|
+
* @param {ModifierKeys} keys The modifier keys which were held down
|
|
24
|
+
* @param {string} key The name of the modifier (Control, Shift, Alt or Meta)
|
|
25
|
+
* @returns {boolean}
|
|
26
|
+
*/
|
|
27
|
+
const modifierState = (keys, key) => {
|
|
28
|
+
switch (key) {
|
|
29
|
+
case 'Control':
|
|
30
|
+
return keys.ctrlKey
|
|
31
|
+
case 'Shift':
|
|
32
|
+
return keys.shiftKey
|
|
33
|
+
case 'Alt':
|
|
34
|
+
return keys.altKey
|
|
35
|
+
case 'Meta':
|
|
36
|
+
return keys.metaKey
|
|
37
|
+
default:
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.modifierState = modifierState
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PseudoEventTarget } from './PseudoEventTarget';
|
|
2
|
-
export interface PseudoAnimation extends PseudoEventTarget {
|
|
3
|
-
}
|
|
1
|
+
import { PseudoEventTarget } from './PseudoEventTarget';
|
|
2
|
+
export interface PseudoAnimation extends PseudoEventTarget {
|
|
3
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { PseudoNode } from './PseudoNode';
|
|
2
|
-
import { PseudoElement } from './PseudoElement';
|
|
3
|
-
export interface PseudoAttr extends PseudoNode {
|
|
4
|
-
get localName(): string;
|
|
5
|
-
get name(): string;
|
|
6
|
-
get namespaceURI(): string;
|
|
7
|
-
get ownerElement(): PseudoElement | null;
|
|
8
|
-
get prefix(): string | null;
|
|
9
|
-
get value(): string;
|
|
10
|
-
set value(value: string);
|
|
11
|
-
}
|
|
1
|
+
import { PseudoNode } from './PseudoNode';
|
|
2
|
+
import { PseudoElement } from './PseudoElement';
|
|
3
|
+
export interface PseudoAttr extends PseudoNode {
|
|
4
|
+
get localName(): string;
|
|
5
|
+
get name(): string;
|
|
6
|
+
get namespaceURI(): string;
|
|
7
|
+
get ownerElement(): PseudoElement | null;
|
|
8
|
+
get prefix(): string | null;
|
|
9
|
+
get value(): string;
|
|
10
|
+
set value(value: string);
|
|
11
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export interface PseudoDOMTokenList {
|
|
2
|
-
get length(): number;
|
|
3
|
-
get value(): string;
|
|
4
|
-
set value(value: string);
|
|
5
|
-
item(index: number): string | null;
|
|
6
|
-
contains(token: string): boolean;
|
|
7
|
-
add(...tokens: string[]): void;
|
|
8
|
-
remove(...tokens: string[]): void;
|
|
9
|
-
replace(oldToken: string, newToken: string): boolean;
|
|
10
|
-
supports(token: string): boolean;
|
|
11
|
-
toggle(token: string, force: boolean): boolean;
|
|
12
|
-
entries(): Iterator<any>;
|
|
13
|
-
forEach(callback: Function, thisArg: any): void;
|
|
14
|
-
keys(): Iterator<any>;
|
|
15
|
-
values(): Iterator<any>;
|
|
16
|
-
}
|
|
1
|
+
export interface PseudoDOMTokenList {
|
|
2
|
+
get length(): number;
|
|
3
|
+
get value(): string;
|
|
4
|
+
set value(value: string);
|
|
5
|
+
item(index: number): string | null;
|
|
6
|
+
contains(token: string): boolean;
|
|
7
|
+
add(...tokens: string[]): void;
|
|
8
|
+
remove(...tokens: string[]): void;
|
|
9
|
+
replace(oldToken: string, newToken: string): boolean;
|
|
10
|
+
supports(token: string): boolean;
|
|
11
|
+
toggle(token: string, force: boolean): boolean;
|
|
12
|
+
entries(): Iterator<any>;
|
|
13
|
+
forEach(callback: Function, thisArg: any): void;
|
|
14
|
+
keys(): Iterator<any>;
|
|
15
|
+
values(): Iterator<any>;
|
|
16
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|