pseudo-dom 0.6.0 → 0.7.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 +432 -13
- package/browser/pseudo-dom.js +3364 -603
- 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 +67 -67
- package/dist/classes/PseudoHTMLDocument.js +144 -144
- package/dist/classes/PseudoNodeList.d.ts +34 -34
- package/dist/classes/PseudoNodeList.js +71 -71
- package/dist/classes.d.ts +20 -20
- package/dist/classes.js +31 -31
- 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/generateNode.d.ts +32 -32
- package/dist/factories/generateNode.js +85 -85
- 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/factories.d.ts +11 -11
- package/dist/factories.js +27 -27
- package/dist/functions/activeElement.d.ts +14 -14
- package/dist/functions/activeElement.js +33 -33
- 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/functions.d.ts +5 -5
- package/dist/functions.js +23 -23
- 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 +7 -0
- package/dist/interfaces/PseudoDocument.js +5 -5
- package/dist/interfaces/PseudoDocumentFragment.d.ts +3 -3
- package/dist/interfaces/PseudoDocumentFragment.js +5 -5
- package/dist/interfaces/PseudoElement.d.ts +20 -7
- 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 +13 -13
- package/dist/services/DocumentFragmentService.js +24 -24
- package/dist/services/DocumentService.d.ts +7 -0
- package/dist/services/DocumentService.js +23 -0
- package/dist/services/DocumentService.min.js +1 -1
- package/dist/services/ElementService.d.ts +13 -0
- package/dist/services/ElementService.js +20 -0
- 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 +11 -6
- package/dist/services/HTMLCollectionService.js +25 -8
- 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 +26 -0
- package/dist/services/NodeService.js +42 -0
- 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 +3 -2
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.MouseEventService = void 0
|
|
7
|
-
/**
|
|
8
|
-
* @file Substitute for the DOM MouseEvent Class.
|
|
9
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
10
|
-
* @version 1.0.0
|
|
11
|
-
*/
|
|
12
|
-
const UIEventService_1 = require('./UIEventService')
|
|
13
|
-
const modifierState_1 = require('../functions/modifierState')
|
|
14
|
-
/**
|
|
15
|
-
* Simulate the behaviour of the MouseEvent Class when there is no DOM available.
|
|
16
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
17
|
-
* @class
|
|
18
|
-
* @augments UIEventService
|
|
19
|
-
* @property {number} screenX
|
|
20
|
-
* @property {number} screenY
|
|
21
|
-
* @property {number} clientX
|
|
22
|
-
* @property {number} clientY
|
|
23
|
-
* @property {number} button
|
|
24
|
-
* @property {number} buttons
|
|
25
|
-
* @property {PseudoEventTarget|null} relatedTarget
|
|
26
|
-
*/
|
|
27
|
-
class MouseEventService extends UIEventService_1.UIEventService {
|
|
28
|
-
/**
|
|
29
|
-
* @param {string} [typeArg=''] The type of the event
|
|
30
|
-
* @param {MouseEventInit} [init={}] The options for the event
|
|
31
|
-
* @constructor
|
|
32
|
-
*/
|
|
33
|
-
constructor (typeArg = '', init = {}) {
|
|
34
|
-
super(typeArg, init)
|
|
35
|
-
this.position = {
|
|
36
|
-
screenX: init.screenX || 0,
|
|
37
|
-
screenY: init.screenY || 0,
|
|
38
|
-
clientX: init.clientX || 0,
|
|
39
|
-
clientY: init.clientY || 0
|
|
40
|
-
}
|
|
41
|
-
this.modifiers = (0, modifierState_1.modifierKeys)(init)
|
|
42
|
-
this.buttonPressed = init.button || 0
|
|
43
|
-
this.buttonsDown = init.buttons || 0
|
|
44
|
-
this.related = init.relatedTarget || null
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
get screenX () {
|
|
48
|
-
return this.position.screenX
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
get screenY () {
|
|
52
|
-
return this.position.screenY
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get clientX () {
|
|
56
|
-
return this.position.clientX
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
get clientY () {
|
|
60
|
-
return this.position.clientY
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
get x () {
|
|
64
|
-
return this.position.clientX
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
get y () {
|
|
68
|
-
return this.position.clientY
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
get ctrlKey () {
|
|
72
|
-
return this.modifiers.ctrlKey
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
get shiftKey () {
|
|
76
|
-
return this.modifiers.shiftKey
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
get altKey () {
|
|
80
|
-
return this.modifiers.altKey
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
get metaKey () {
|
|
84
|
-
return this.modifiers.metaKey
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
get button () {
|
|
88
|
-
return this.buttonPressed
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
get buttons () {
|
|
92
|
-
return this.buttonsDown
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
get relatedTarget () {
|
|
96
|
-
return this.related
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Whether a modifier key was held down when the event happened.
|
|
101
|
-
* @param {string} key Control, Shift, Alt or Meta
|
|
102
|
-
* @returns {boolean}
|
|
103
|
-
*/
|
|
104
|
-
getModifierState (key) {
|
|
105
|
-
return (0, modifierState_1.modifierState)(this.modifiers, key)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
exports.MouseEventService = MouseEventService
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.MouseEventService = void 0
|
|
7
|
+
/**
|
|
8
|
+
* @file Substitute for the DOM MouseEvent Class.
|
|
9
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
10
|
+
* @version 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
const UIEventService_1 = require('./UIEventService')
|
|
13
|
+
const modifierState_1 = require('../functions/modifierState')
|
|
14
|
+
/**
|
|
15
|
+
* Simulate the behaviour of the MouseEvent Class when there is no DOM available.
|
|
16
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
17
|
+
* @class
|
|
18
|
+
* @augments UIEventService
|
|
19
|
+
* @property {number} screenX
|
|
20
|
+
* @property {number} screenY
|
|
21
|
+
* @property {number} clientX
|
|
22
|
+
* @property {number} clientY
|
|
23
|
+
* @property {number} button
|
|
24
|
+
* @property {number} buttons
|
|
25
|
+
* @property {PseudoEventTarget|null} relatedTarget
|
|
26
|
+
*/
|
|
27
|
+
class MouseEventService extends UIEventService_1.UIEventService {
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} [typeArg=''] The type of the event
|
|
30
|
+
* @param {MouseEventInit} [init={}] The options for the event
|
|
31
|
+
* @constructor
|
|
32
|
+
*/
|
|
33
|
+
constructor (typeArg = '', init = {}) {
|
|
34
|
+
super(typeArg, init)
|
|
35
|
+
this.position = {
|
|
36
|
+
screenX: init.screenX || 0,
|
|
37
|
+
screenY: init.screenY || 0,
|
|
38
|
+
clientX: init.clientX || 0,
|
|
39
|
+
clientY: init.clientY || 0
|
|
40
|
+
}
|
|
41
|
+
this.modifiers = (0, modifierState_1.modifierKeys)(init)
|
|
42
|
+
this.buttonPressed = init.button || 0
|
|
43
|
+
this.buttonsDown = init.buttons || 0
|
|
44
|
+
this.related = init.relatedTarget || null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get screenX () {
|
|
48
|
+
return this.position.screenX
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get screenY () {
|
|
52
|
+
return this.position.screenY
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get clientX () {
|
|
56
|
+
return this.position.clientX
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
get clientY () {
|
|
60
|
+
return this.position.clientY
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
get x () {
|
|
64
|
+
return this.position.clientX
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get y () {
|
|
68
|
+
return this.position.clientY
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get ctrlKey () {
|
|
72
|
+
return this.modifiers.ctrlKey
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
get shiftKey () {
|
|
76
|
+
return this.modifiers.shiftKey
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get altKey () {
|
|
80
|
+
return this.modifiers.altKey
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
get metaKey () {
|
|
84
|
+
return this.modifiers.metaKey
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get button () {
|
|
88
|
+
return this.buttonPressed
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
get buttons () {
|
|
92
|
+
return this.buttonsDown
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
get relatedTarget () {
|
|
96
|
+
return this.related
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Whether a modifier key was held down when the event happened.
|
|
101
|
+
* @param {string} key Control, Shift, Alt or Meta
|
|
102
|
+
* @returns {boolean}
|
|
103
|
+
*/
|
|
104
|
+
getModifierState (key) {
|
|
105
|
+
return (0, modifierState_1.modifierState)(this.modifiers, key)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.MouseEventService = MouseEventService
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { PseudoNamedNodeMap } from '../interfaces/PseudoNamedNodeMap';
|
|
2
|
-
import { PseudoAttr } from '../interfaces/PseudoAttr';
|
|
3
|
-
/**
|
|
4
|
-
* Simulate the behaviour of the NamedNodeMap Class when there is no DOM available.
|
|
5
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
6
|
-
* @class
|
|
7
|
-
*/
|
|
8
|
-
export declare class NamedNodeMapService implements PseudoNamedNodeMap {
|
|
9
|
-
private attributes;
|
|
10
|
-
/**
|
|
11
|
-
* @param {Array<PseudoAttr>} [attributes=[]] The attributes to start with
|
|
12
|
-
* @constructor
|
|
13
|
-
*/
|
|
14
|
-
constructor(attributes?: Array<PseudoAttr>);
|
|
15
|
-
get length(): number;
|
|
16
|
-
getNamedItem(name: string): PseudoAttr | null;
|
|
17
|
-
setNamedItem(attr: PseudoAttr): PseudoAttr | null;
|
|
18
|
-
removeNamedItem(attrName: string): PseudoAttr;
|
|
19
|
-
item(index: number): PseudoAttr | null;
|
|
20
|
-
getNamedItemNS(namespace: string, localName: string): PseudoAttr | null;
|
|
21
|
-
setNamedItemNS(attr: PseudoAttr): PseudoAttr | null;
|
|
22
|
-
removeNamedItemNS(namespace: string, localName: string): PseudoAttr;
|
|
23
|
-
}
|
|
1
|
+
import { PseudoNamedNodeMap } from '../interfaces/PseudoNamedNodeMap';
|
|
2
|
+
import { PseudoAttr } from '../interfaces/PseudoAttr';
|
|
3
|
+
/**
|
|
4
|
+
* Simulate the behaviour of the NamedNodeMap Class when there is no DOM available.
|
|
5
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
6
|
+
* @class
|
|
7
|
+
*/
|
|
8
|
+
export declare class NamedNodeMapService implements PseudoNamedNodeMap {
|
|
9
|
+
private attributes;
|
|
10
|
+
/**
|
|
11
|
+
* @param {Array<PseudoAttr>} [attributes=[]] The attributes to start with
|
|
12
|
+
* @constructor
|
|
13
|
+
*/
|
|
14
|
+
constructor(attributes?: Array<PseudoAttr>);
|
|
15
|
+
get length(): number;
|
|
16
|
+
getNamedItem(name: string): PseudoAttr | null;
|
|
17
|
+
setNamedItem(attr: PseudoAttr): PseudoAttr | null;
|
|
18
|
+
removeNamedItem(attrName: string): PseudoAttr;
|
|
19
|
+
item(index: number): PseudoAttr | null;
|
|
20
|
+
getNamedItemNS(namespace: string, localName: string): PseudoAttr | null;
|
|
21
|
+
setNamedItemNS(attr: PseudoAttr): PseudoAttr | null;
|
|
22
|
+
removeNamedItemNS(namespace: string, localName: string): PseudoAttr;
|
|
23
|
+
}
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.iterator.constructor.js')
|
|
4
|
-
require('core-js/modules/esnext.iterator.find.js')
|
|
5
|
-
Object.defineProperty(exports, '__esModule', {
|
|
6
|
-
value: true
|
|
7
|
-
})
|
|
8
|
-
exports.NamedNodeMapService = void 0
|
|
9
|
-
/**
|
|
10
|
-
* Simulate the behaviour of the NamedNodeMap Class when there is no DOM available.
|
|
11
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
12
|
-
* @class
|
|
13
|
-
*/
|
|
14
|
-
class NamedNodeMapService {
|
|
15
|
-
/**
|
|
16
|
-
* @param {Array<PseudoAttr>} [attributes=[]] The attributes to start with
|
|
17
|
-
* @constructor
|
|
18
|
-
*/
|
|
19
|
-
constructor (attributes = []) {
|
|
20
|
-
this.attributes = attributes.slice()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get length () {
|
|
24
|
-
return this.attributes.length
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getNamedItem (name) {
|
|
28
|
-
return this.attributes.find(attr => attr.name === name) || null
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
setNamedItem (attr) {
|
|
32
|
-
const index = this.attributes.findIndex(existing => existing.name === attr.name)
|
|
33
|
-
if (index < 0) {
|
|
34
|
-
this.attributes.push(attr)
|
|
35
|
-
return null
|
|
36
|
-
}
|
|
37
|
-
const replaced = this.attributes[index]
|
|
38
|
-
this.attributes[index] = attr
|
|
39
|
-
return replaced
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
removeNamedItem (attrName) {
|
|
43
|
-
const index = this.attributes.findIndex(attr => attr.name === attrName)
|
|
44
|
-
if (index < 0) {
|
|
45
|
-
throw new Error(`The attribute "${attrName}" was not found.`)
|
|
46
|
-
}
|
|
47
|
-
return this.attributes.splice(index, 1)[0]
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
item (index) {
|
|
51
|
-
return this.attributes[index] || null
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
getNamedItemNS (namespace, localName) {
|
|
55
|
-
return this.attributes.find(attr => attr.namespaceURI === namespace && attr.localName === localName) || null
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
setNamedItemNS (attr) {
|
|
59
|
-
const index = this.attributes.findIndex(existing => existing.namespaceURI === attr.namespaceURI && existing.localName === attr.localName)
|
|
60
|
-
if (index < 0) {
|
|
61
|
-
this.attributes.push(attr)
|
|
62
|
-
return null
|
|
63
|
-
}
|
|
64
|
-
const replaced = this.attributes[index]
|
|
65
|
-
this.attributes[index] = attr
|
|
66
|
-
return replaced
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
removeNamedItemNS (namespace, localName) {
|
|
70
|
-
const index = this.attributes.findIndex(attr => attr.namespaceURI === namespace && attr.localName === localName)
|
|
71
|
-
if (index < 0) {
|
|
72
|
-
throw new Error(`The attribute "${localName}" in the namespace "${namespace}" was not found.`)
|
|
73
|
-
}
|
|
74
|
-
return this.attributes.splice(index, 1)[0]
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.NamedNodeMapService = NamedNodeMapService
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.iterator.constructor.js')
|
|
4
|
+
require('core-js/modules/esnext.iterator.find.js')
|
|
5
|
+
Object.defineProperty(exports, '__esModule', {
|
|
6
|
+
value: true
|
|
7
|
+
})
|
|
8
|
+
exports.NamedNodeMapService = void 0
|
|
9
|
+
/**
|
|
10
|
+
* Simulate the behaviour of the NamedNodeMap Class when there is no DOM available.
|
|
11
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
12
|
+
* @class
|
|
13
|
+
*/
|
|
14
|
+
class NamedNodeMapService {
|
|
15
|
+
/**
|
|
16
|
+
* @param {Array<PseudoAttr>} [attributes=[]] The attributes to start with
|
|
17
|
+
* @constructor
|
|
18
|
+
*/
|
|
19
|
+
constructor (attributes = []) {
|
|
20
|
+
this.attributes = attributes.slice()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get length () {
|
|
24
|
+
return this.attributes.length
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getNamedItem (name) {
|
|
28
|
+
return this.attributes.find(attr => attr.name === name) || null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setNamedItem (attr) {
|
|
32
|
+
const index = this.attributes.findIndex(existing => existing.name === attr.name)
|
|
33
|
+
if (index < 0) {
|
|
34
|
+
this.attributes.push(attr)
|
|
35
|
+
return null
|
|
36
|
+
}
|
|
37
|
+
const replaced = this.attributes[index]
|
|
38
|
+
this.attributes[index] = attr
|
|
39
|
+
return replaced
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
removeNamedItem (attrName) {
|
|
43
|
+
const index = this.attributes.findIndex(attr => attr.name === attrName)
|
|
44
|
+
if (index < 0) {
|
|
45
|
+
throw new Error(`The attribute "${attrName}" was not found.`)
|
|
46
|
+
}
|
|
47
|
+
return this.attributes.splice(index, 1)[0]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
item (index) {
|
|
51
|
+
return this.attributes[index] || null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getNamedItemNS (namespace, localName) {
|
|
55
|
+
return this.attributes.find(attr => attr.namespaceURI === namespace && attr.localName === localName) || null
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setNamedItemNS (attr) {
|
|
59
|
+
const index = this.attributes.findIndex(existing => existing.namespaceURI === attr.namespaceURI && existing.localName === attr.localName)
|
|
60
|
+
if (index < 0) {
|
|
61
|
+
this.attributes.push(attr)
|
|
62
|
+
return null
|
|
63
|
+
}
|
|
64
|
+
const replaced = this.attributes[index]
|
|
65
|
+
this.attributes[index] = attr
|
|
66
|
+
return replaced
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
removeNamedItemNS (namespace, localName) {
|
|
70
|
+
const index = this.attributes.findIndex(attr => attr.namespaceURI === namespace && attr.localName === localName)
|
|
71
|
+
if (index < 0) {
|
|
72
|
+
throw new Error(`The attribute "${localName}" in the namespace "${namespace}" was not found.`)
|
|
73
|
+
}
|
|
74
|
+
return this.attributes.splice(index, 1)[0]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.NamedNodeMapService = NamedNodeMapService
|
|
@@ -6,6 +6,7 @@ import EventTargetService from './EventTargetService';
|
|
|
6
6
|
import { PseudoElement } from '../interfaces/PseudoElement';
|
|
7
7
|
import { PseudoDocument } from '../interfaces/PseudoDocument';
|
|
8
8
|
import { PseudoDocumentFragment } from '../interfaces/PseudoDocumentFragment';
|
|
9
|
+
import { HTMLCollectionService } from './HTMLCollectionService';
|
|
9
10
|
/**
|
|
10
11
|
* Simulate the behaviour of the Node Class when there is no DOM available.
|
|
11
12
|
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
@@ -139,6 +140,31 @@ export declare class NodeService extends EventTargetService implements PseudoNod
|
|
|
139
140
|
* @returns {PseudoNode}
|
|
140
141
|
*/
|
|
141
142
|
private toChildNode;
|
|
143
|
+
/**
|
|
144
|
+
* Every element below this node with the given tag name (or every element when tagName is *), live.
|
|
145
|
+
* @param {string} tagName
|
|
146
|
+
* @returns {PseudoHTMLCollection}
|
|
147
|
+
*/
|
|
148
|
+
getElementsByTagName(tagName: string): HTMLCollectionService;
|
|
149
|
+
/**
|
|
150
|
+
* Every element below this node which has all of the given (space separated) classes, live.
|
|
151
|
+
* @param {string} className
|
|
152
|
+
* @returns {PseudoHTMLCollection}
|
|
153
|
+
*/
|
|
154
|
+
getElementsByClassName(className: string): HTMLCollectionService;
|
|
155
|
+
/**
|
|
156
|
+
* The first element below this node which matches the CSS selector, in tree order, or null when there is none.
|
|
157
|
+
* @param {string} selectors A CSS selector
|
|
158
|
+
* @returns {PseudoElement|null}
|
|
159
|
+
*/
|
|
160
|
+
querySelector(selectors: string): PseudoElement | null;
|
|
161
|
+
/**
|
|
162
|
+
* Every element below this node which matches the CSS selector, in tree order. A plain array (not a live
|
|
163
|
+
* collection): like the DOM's querySelectorAll, it is a snapshot taken when it is called.
|
|
164
|
+
* @param {string} selectors A CSS selector
|
|
165
|
+
* @returns {Array<PseudoElement>}
|
|
166
|
+
*/
|
|
167
|
+
querySelectorAll(selectors: string): Array<PseudoElement>;
|
|
142
168
|
/**
|
|
143
169
|
* Called each time a node has been inserted as a child of this node, so that nodes which need to react to children
|
|
144
170
|
* (for example elements applying default events) can do so.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require('core-js/modules/esnext.iterator.constructor.js')
|
|
4
4
|
require('core-js/modules/esnext.iterator.every.js')
|
|
5
|
+
require('core-js/modules/esnext.iterator.filter.js')
|
|
5
6
|
require('core-js/modules/esnext.iterator.for-each.js')
|
|
6
7
|
const __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
7
8
|
return mod && mod.__esModule
|
|
@@ -22,6 +23,8 @@ exports.CommentService = exports.TextService = exports.NodeService = void 0
|
|
|
22
23
|
const generateNodeList_1 = __importDefault(require('../factories/generateNodeList'))
|
|
23
24
|
const TreeLinker_1 = require('collect-your-stuff/dist/collections/linked-tree-list/TreeLinker')
|
|
24
25
|
const EventTargetService_1 = __importDefault(require('./EventTargetService'))
|
|
26
|
+
const HTMLCollectionService_1 = require('./HTMLCollectionService')
|
|
27
|
+
const query_1 = require('../factories/query')
|
|
25
28
|
/**
|
|
26
29
|
* Simulate the behaviour of the Node Class when there is no DOM available.
|
|
27
30
|
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
@@ -274,6 +277,45 @@ class NodeService extends EventTargetService_1.default {
|
|
|
274
277
|
return text
|
|
275
278
|
}
|
|
276
279
|
|
|
280
|
+
/**
|
|
281
|
+
* Every element below this node with the given tag name (or every element when tagName is *), live.
|
|
282
|
+
* @param {string} tagName
|
|
283
|
+
* @returns {PseudoHTMLCollection}
|
|
284
|
+
*/
|
|
285
|
+
getElementsByTagName (tagName) {
|
|
286
|
+
const matchesTag = tagName === '*' ? () => true : element => element.tagName === tagName
|
|
287
|
+
return new HTMLCollectionService_1.HTMLCollectionService(this, matchesTag, true)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Every element below this node which has all of the given (space separated) classes, live.
|
|
292
|
+
* @param {string} className
|
|
293
|
+
* @returns {PseudoHTMLCollection}
|
|
294
|
+
*/
|
|
295
|
+
getElementsByClassName (className) {
|
|
296
|
+
const names = className.trim().split(/\s+/).filter(Boolean)
|
|
297
|
+
return new HTMLCollectionService_1.HTMLCollectionService(this, element => names.every(name => element.classList.contains(name)), true)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* The first element below this node which matches the CSS selector, in tree order, or null when there is none.
|
|
302
|
+
* @param {string} selectors A CSS selector
|
|
303
|
+
* @returns {PseudoElement|null}
|
|
304
|
+
*/
|
|
305
|
+
querySelector (selectors) {
|
|
306
|
+
return (0, query_1.querySelector)(selectors, this)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Every element below this node which matches the CSS selector, in tree order. A plain array (not a live
|
|
311
|
+
* collection): like the DOM's querySelectorAll, it is a snapshot taken when it is called.
|
|
312
|
+
* @param {string} selectors A CSS selector
|
|
313
|
+
* @returns {Array<PseudoElement>}
|
|
314
|
+
*/
|
|
315
|
+
querySelectorAll (selectors) {
|
|
316
|
+
return (0, query_1.querySelectorAll)(selectors, this)
|
|
317
|
+
}
|
|
318
|
+
|
|
277
319
|
/**
|
|
278
320
|
* Called each time a node has been inserted as a child of this node, so that nodes which need to react to children
|
|
279
321
|
* (for example elements applying default events) can do so.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.every.js"),require("core-js/modules/esnext.iterator.for-each.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CommentService=exports.TextService=exports.NodeService=void 0;const generateNodeList_1=__importDefault(require("../factories/generateNodeList")),TreeLinker_1=require("collect-your-stuff/dist/collections/linked-tree-list/TreeLinker"),EventTargetService_1=__importDefault(require("./EventTargetService"));class NodeService extends EventTargetService_1.default{constructor(){super(),this.nodeValueStore=null,this.ownerDocumentStore=null,this.nodeId=NodeService.nextNodeId++,this.nodeNameValue="",this.childList=(0,generateNodeList_1.default)(),this.parent=null,this.listLinker=null}get baseURI(){return window.location||"/"}get childNodes(){return this.childList}get firstChild(){return this.childList.first?this.childList.first.data:null}get isConnected(){return this.getRootNode().nodeType===NodeService.DOCUMENT_NODE}get lastChild(){return this.childList.last?this.childList.last.data:null}get nextSibling(){return this.listLinker&&this.listLinker.next?this.listLinker.next.data:null}get nodeName(){return this.nodeNameValue||""}get nodeType(){return NodeService.DEFAULT_NODE}get nodeValue(){return this.nodeValueStore}set nodeValue(e){this.nodeValueStore=e}get ownerDocument(){if(this.nodeType===NodeService.DOCUMENT_NODE)return null;const e=this.getRootNode();return e.nodeType===NodeService.DOCUMENT_NODE?e:this.ownerDocumentStore}get parentNode(){return this.parent}get parentElement(){return this.parent&&this.parent.nodeType===NodeService.ELEMENT_NODE?this.parent:null}get previousSibling(){return this.listLinker&&this.listLinker.prev?this.listLinker.prev.data:null}get textContent(){if(this.nodeType===NodeService.DOCUMENT_NODE||this.nodeType===NodeService.DOCUMENT_TYPE_NODE)return null;let e="";return Array.from(this.childNodes).forEach(t=>{t.nodeType===NodeService.TEXT_NODE?e+=t.nodeValue:t.nodeType!==NodeService.COMMENT_NODE&&(e+=t.textContent)}),e}set textContent(e){if(this.nodeType!==NodeService.DOCUMENT_NODE&&this.nodeType!==NodeService.DOCUMENT_TYPE_NODE){for(;this.firstChild;)this.removeChild(this.firstChild);if(null!=e&&""!==String(e)){const t=new TextService(String(e));t.ownerDocumentStore=this.ownerDocument,this.appendChild(t)}}}appendChild(e){return this.insertBefore(e,null)}get acceptsChildren(){return!0}cloneShallow(){const e=new this.constructor;return e.nodeValue=this.nodeValue,e.ownerDocumentStore=this.ownerDocumentStore,e}equalsShallow(e){return this.nodeName===e.nodeName&&this.nodeValue===e.nodeValue}append(...e){e.forEach(e=>this.appendChild(this.toChildNode(e)))}prepend(...e){const t=this.firstChild;e.forEach(e=>this.insertBefore(this.toChildNode(e),t))}replaceChildren(...e){for(;this.firstChild;)this.removeChild(this.firstChild);this.append(...e)}before(...e){const t=this.parentNode;t&&e.forEach(e=>t.insertBefore(this.toChildNode(e),this))}after(...e){const t=this.parentNode;if(!t)return;const r=this.nextSibling;e.forEach(e=>t.insertBefore(this.toChildNode(e),r))}replaceWith(...e){const t=this.parentNode;t&&(e.forEach(e=>t.insertBefore(this.toChildNode(e),this)),t.removeChild(this))}remove(){this.parentNode&&this.parentNode.removeChild(this)}toChildNode(e){if("string"!=typeof e)return e;const t=new TextService(e);return t.ownerDocumentStore=this.ownerDocument,t}childInserted(e){}cloneNode(e=!1){const t=this.cloneShallow();return e&&Array.from(this.childNodes).forEach(e=>t.appendChild(e.cloneNode(!0))),t}compareDocumentPosition(e){if(e===this)return 0;const t=e=>{const t=[];for(let r=e;r;r=r.parentNode)t.unshift(r);return t},r=t(this),i=t(e);if(r[0]!==i[0]){const t=e.nodeId<this.nodeId?NodeService.DOCUMENT_POSITION_PRECEDING:NodeService.DOCUMENT_POSITION_FOLLOWING;return NodeService.DOCUMENT_POSITION_DISCONNECTED|NodeService.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC|t}if(i.length<r.length&&i.every((e,t)=>r[t]===e))return NodeService.DOCUMENT_POSITION_CONTAINS|NodeService.DOCUMENT_POSITION_PRECEDING;if(r.length<i.length&&r.every((e,t)=>i[t]===e))return NodeService.DOCUMENT_POSITION_CONTAINED_BY|NodeService.DOCUMENT_POSITION_FOLLOWING;let n=0;for(;r[n]===i[n];)++n;for(let e=r[n].nextSibling;e;e=e.nextSibling)if(e===i[n])return NodeService.DOCUMENT_POSITION_FOLLOWING;return NodeService.DOCUMENT_POSITION_PRECEDING}contains(e){let t=e;for(;t;){if(t===this)return!0;t=t.parentNode}return!1}getRootNode(e={composed:!1}){return this.parent?this.parent.getRootNode(e):this}hasChildNodes(){return this.childList.length>0}insertBefore(e,t=null){if(!this.acceptsChildren)throw new Error("This kind of node cannot have children.");if(null!==t&&t.parentNode!==this)throw new Error("The node before which the new node is to be inserted is not a child of this node.");if(e===t)return e;if("function"==typeof e.contains&&e.contains(this))throw new Error("The new node cannot be inserted into itself or one of its own descendants.");if(e.nodeType===NodeService.DOCUMENT_FRAGMENT_NODE){for(;e.firstChild;)this.insertBefore(e.firstChild,t);return e}e.parentNode&&e.parentNode.removeChild(e);const r=new TreeLinker_1.TreeLinker({data:e});this.childList.insertBefore(t?t.listLinker:null,r);const i=e;return i.parent=this,i.listLinker=r,this.childInserted(i),e}isDefaultNamespace(e){return null===e}isEqualNode(e){if(!e||e.nodeType!==this.nodeType||!this.equalsShallow(e))return!1;const t=Array.from(this.childNodes),r=Array.from(e.childNodes);return t.length===r.length&&t.every((e,t)=>e.isEqualNode(r[t]))}isSameNode(e){return this===e}lookupPrefix(e){return null}lookupNamespaceURI(e){return null}normalize(){let e=this.firstChild;for(;e;)if(e.nodeType===NodeService.TEXT_NODE){let t=e.nodeValue,r=e.nextSibling;for(;r&&r.nodeType===NodeService.TEXT_NODE;){t+=r.nodeValue;const e=r.nextSibling;this.removeChild(r),r=e}e.nodeValue=t,""===t&&this.removeChild(e),e=r}else e.normalize(),e=e.nextSibling}removeChild(e){if(!e||e.parentNode!==this)throw new Error("The node to be removed is not a child of this node.");const t=e;return this.childList.remove(t.listLinker),t.parent=null,t.listLinker=null,e}replaceChild(e,t){if(!t||t.parentNode!==this)throw new Error("The node to be replaced is not a child of this node.");if(e===t)return t;let r=t.nextSibling;return r===e&&(r=e.nextSibling),this.removeChild(t),this.insertBefore(e,r),t}}exports.NodeService=NodeService,NodeService.DEFAULT_NODE=0,NodeService.ELEMENT_NODE=1,NodeService.ATTRIBUTE_NODE=2,NodeService.TEXT_NODE=3,NodeService.CDATA_SECTION_NODE=4,NodeService.ENTITY_REFERENCE_NODE=5,NodeService.ENTITY_NODE=6,NodeService.PROCESSING_INSTRUCTION_NODE=7,NodeService.COMMENT_NODE=8,NodeService.DOCUMENT_NODE=9,NodeService.DOCUMENT_TYPE_NODE=10,NodeService.DOCUMENT_FRAGMENT_NODE=11,NodeService.NOTATION_NODE=12,NodeService.DOCUMENT_POSITION_DISCONNECTED=1,NodeService.DOCUMENT_POSITION_PRECEDING=2,NodeService.DOCUMENT_POSITION_FOLLOWING=4,NodeService.DOCUMENT_POSITION_CONTAINS=8,NodeService.DOCUMENT_POSITION_CONTAINED_BY=16,NodeService.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32,NodeService.nextNodeId=1;class TextService extends NodeService{constructor(e=""){super(),this.nodeValue=String(e)}get acceptsChildren(){return!1}get nodeName(){return"#text"}get nodeType(){return NodeService.TEXT_NODE}get data(){return this.nodeValue}set data(e){this.nodeValue=String(e)}get length(){return this.data.length}get textContent(){return this.data}set textContent(e){this.data=null===e?"":String(e)}get wholeText(){let e=this;for(;e.previousSibling&&e.previousSibling.nodeType===NodeService.TEXT_NODE;)e=e.previousSibling;let t="";for(let r=e;r&&r.nodeType===NodeService.TEXT_NODE;r=r.nextSibling)t+=r.nodeValue;return t}splitText(e){if(e<0||e>this.length)throw new Error("The offset is beyond the end of the text.");const t=new TextService(this.data.slice(e));return t.ownerDocumentStore=this.ownerDocumentStore,this.data=this.data.slice(0,e),this.parentNode&&this.parentNode.insertBefore(t,this.nextSibling),t}cloneShallow(){const e=new TextService(this.data);return e.ownerDocumentStore=this.ownerDocumentStore,e}}exports.TextService=TextService;class CommentService extends NodeService{constructor(e=""){super(),this.nodeValue=String(e)}get acceptsChildren(){return!1}get nodeName(){return"#comment"}get nodeType(){return NodeService.COMMENT_NODE}get data(){return this.nodeValue}set data(e){this.nodeValue=String(e)}get length(){return this.data.length}get textContent(){return this.data}set textContent(e){this.data=null===e?"":String(e)}cloneShallow(){const e=new CommentService(this.data);return e.ownerDocumentStore=this.ownerDocumentStore,e}}exports.CommentService=CommentService;
|
|
1
|
+
"use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.every.js"),require("core-js/modules/esnext.iterator.filter.js"),require("core-js/modules/esnext.iterator.for-each.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CommentService=exports.TextService=exports.NodeService=void 0;const generateNodeList_1=__importDefault(require("../factories/generateNodeList")),TreeLinker_1=require("collect-your-stuff/dist/collections/linked-tree-list/TreeLinker"),EventTargetService_1=__importDefault(require("./EventTargetService")),HTMLCollectionService_1=require("./HTMLCollectionService"),query_1=require("../factories/query");class NodeService extends EventTargetService_1.default{constructor(){super(),this.nodeValueStore=null,this.ownerDocumentStore=null,this.nodeId=NodeService.nextNodeId++,this.nodeNameValue="",this.childList=(0,generateNodeList_1.default)(),this.parent=null,this.listLinker=null}get baseURI(){return window.location||"/"}get childNodes(){return this.childList}get firstChild(){return this.childList.first?this.childList.first.data:null}get isConnected(){return this.getRootNode().nodeType===NodeService.DOCUMENT_NODE}get lastChild(){return this.childList.last?this.childList.last.data:null}get nextSibling(){return this.listLinker&&this.listLinker.next?this.listLinker.next.data:null}get nodeName(){return this.nodeNameValue||""}get nodeType(){return NodeService.DEFAULT_NODE}get nodeValue(){return this.nodeValueStore}set nodeValue(e){this.nodeValueStore=e}get ownerDocument(){if(this.nodeType===NodeService.DOCUMENT_NODE)return null;const e=this.getRootNode();return e.nodeType===NodeService.DOCUMENT_NODE?e:this.ownerDocumentStore}get parentNode(){return this.parent}get parentElement(){return this.parent&&this.parent.nodeType===NodeService.ELEMENT_NODE?this.parent:null}get previousSibling(){return this.listLinker&&this.listLinker.prev?this.listLinker.prev.data:null}get textContent(){if(this.nodeType===NodeService.DOCUMENT_NODE||this.nodeType===NodeService.DOCUMENT_TYPE_NODE)return null;let e="";return Array.from(this.childNodes).forEach(t=>{t.nodeType===NodeService.TEXT_NODE?e+=t.nodeValue:t.nodeType!==NodeService.COMMENT_NODE&&(e+=t.textContent)}),e}set textContent(e){if(this.nodeType!==NodeService.DOCUMENT_NODE&&this.nodeType!==NodeService.DOCUMENT_TYPE_NODE){for(;this.firstChild;)this.removeChild(this.firstChild);if(null!=e&&""!==String(e)){const t=new TextService(String(e));t.ownerDocumentStore=this.ownerDocument,this.appendChild(t)}}}appendChild(e){return this.insertBefore(e,null)}get acceptsChildren(){return!0}cloneShallow(){const e=new this.constructor;return e.nodeValue=this.nodeValue,e.ownerDocumentStore=this.ownerDocumentStore,e}equalsShallow(e){return this.nodeName===e.nodeName&&this.nodeValue===e.nodeValue}append(...e){e.forEach(e=>this.appendChild(this.toChildNode(e)))}prepend(...e){const t=this.firstChild;e.forEach(e=>this.insertBefore(this.toChildNode(e),t))}replaceChildren(...e){for(;this.firstChild;)this.removeChild(this.firstChild);this.append(...e)}before(...e){const t=this.parentNode;t&&e.forEach(e=>t.insertBefore(this.toChildNode(e),this))}after(...e){const t=this.parentNode;if(!t)return;const r=this.nextSibling;e.forEach(e=>t.insertBefore(this.toChildNode(e),r))}replaceWith(...e){const t=this.parentNode;t&&(e.forEach(e=>t.insertBefore(this.toChildNode(e),this)),t.removeChild(this))}remove(){this.parentNode&&this.parentNode.removeChild(this)}toChildNode(e){if("string"!=typeof e)return e;const t=new TextService(e);return t.ownerDocumentStore=this.ownerDocument,t}getElementsByTagName(e){const t="*"===e?()=>!0:t=>t.tagName===e;return new HTMLCollectionService_1.HTMLCollectionService(this,t,!0)}getElementsByClassName(e){const t=e.trim().split(/\s+/).filter(Boolean);return new HTMLCollectionService_1.HTMLCollectionService(this,e=>t.every(t=>e.classList.contains(t)),!0)}querySelector(e){return(0,query_1.querySelector)(e,this)}querySelectorAll(e){return(0,query_1.querySelectorAll)(e,this)}childInserted(e){}cloneNode(e=!1){const t=this.cloneShallow();return e&&Array.from(this.childNodes).forEach(e=>t.appendChild(e.cloneNode(!0))),t}compareDocumentPosition(e){if(e===this)return 0;const t=e=>{const t=[];for(let r=e;r;r=r.parentNode)t.unshift(r);return t},r=t(this),i=t(e);if(r[0]!==i[0]){const t=e.nodeId<this.nodeId?NodeService.DOCUMENT_POSITION_PRECEDING:NodeService.DOCUMENT_POSITION_FOLLOWING;return NodeService.DOCUMENT_POSITION_DISCONNECTED|NodeService.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC|t}if(i.length<r.length&&i.every((e,t)=>r[t]===e))return NodeService.DOCUMENT_POSITION_CONTAINS|NodeService.DOCUMENT_POSITION_PRECEDING;if(r.length<i.length&&r.every((e,t)=>i[t]===e))return NodeService.DOCUMENT_POSITION_CONTAINED_BY|NodeService.DOCUMENT_POSITION_FOLLOWING;let n=0;for(;r[n]===i[n];)++n;for(let e=r[n].nextSibling;e;e=e.nextSibling)if(e===i[n])return NodeService.DOCUMENT_POSITION_FOLLOWING;return NodeService.DOCUMENT_POSITION_PRECEDING}contains(e){let t=e;for(;t;){if(t===this)return!0;t=t.parentNode}return!1}getRootNode(e={composed:!1}){return this.parent?this.parent.getRootNode(e):this}hasChildNodes(){return this.childList.length>0}insertBefore(e,t=null){if(!this.acceptsChildren)throw new Error("This kind of node cannot have children.");if(null!==t&&t.parentNode!==this)throw new Error("The node before which the new node is to be inserted is not a child of this node.");if(e===t)return e;if("function"==typeof e.contains&&e.contains(this))throw new Error("The new node cannot be inserted into itself or one of its own descendants.");if(e.nodeType===NodeService.DOCUMENT_FRAGMENT_NODE){for(;e.firstChild;)this.insertBefore(e.firstChild,t);return e}e.parentNode&&e.parentNode.removeChild(e);const r=new TreeLinker_1.TreeLinker({data:e});this.childList.insertBefore(t?t.listLinker:null,r);const i=e;return i.parent=this,i.listLinker=r,this.childInserted(i),e}isDefaultNamespace(e){return null===e}isEqualNode(e){if(!e||e.nodeType!==this.nodeType||!this.equalsShallow(e))return!1;const t=Array.from(this.childNodes),r=Array.from(e.childNodes);return t.length===r.length&&t.every((e,t)=>e.isEqualNode(r[t]))}isSameNode(e){return this===e}lookupPrefix(e){return null}lookupNamespaceURI(e){return null}normalize(){let e=this.firstChild;for(;e;)if(e.nodeType===NodeService.TEXT_NODE){let t=e.nodeValue,r=e.nextSibling;for(;r&&r.nodeType===NodeService.TEXT_NODE;){t+=r.nodeValue;const e=r.nextSibling;this.removeChild(r),r=e}e.nodeValue=t,""===t&&this.removeChild(e),e=r}else e.normalize(),e=e.nextSibling}removeChild(e){if(!e||e.parentNode!==this)throw new Error("The node to be removed is not a child of this node.");const t=e;return this.childList.remove(t.listLinker),t.parent=null,t.listLinker=null,e}replaceChild(e,t){if(!t||t.parentNode!==this)throw new Error("The node to be replaced is not a child of this node.");if(e===t)return t;let r=t.nextSibling;return r===e&&(r=e.nextSibling),this.removeChild(t),this.insertBefore(e,r),t}}exports.NodeService=NodeService,NodeService.DEFAULT_NODE=0,NodeService.ELEMENT_NODE=1,NodeService.ATTRIBUTE_NODE=2,NodeService.TEXT_NODE=3,NodeService.CDATA_SECTION_NODE=4,NodeService.ENTITY_REFERENCE_NODE=5,NodeService.ENTITY_NODE=6,NodeService.PROCESSING_INSTRUCTION_NODE=7,NodeService.COMMENT_NODE=8,NodeService.DOCUMENT_NODE=9,NodeService.DOCUMENT_TYPE_NODE=10,NodeService.DOCUMENT_FRAGMENT_NODE=11,NodeService.NOTATION_NODE=12,NodeService.DOCUMENT_POSITION_DISCONNECTED=1,NodeService.DOCUMENT_POSITION_PRECEDING=2,NodeService.DOCUMENT_POSITION_FOLLOWING=4,NodeService.DOCUMENT_POSITION_CONTAINS=8,NodeService.DOCUMENT_POSITION_CONTAINED_BY=16,NodeService.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32,NodeService.nextNodeId=1;class TextService extends NodeService{constructor(e=""){super(),this.nodeValue=String(e)}get acceptsChildren(){return!1}get nodeName(){return"#text"}get nodeType(){return NodeService.TEXT_NODE}get data(){return this.nodeValue}set data(e){this.nodeValue=String(e)}get length(){return this.data.length}get textContent(){return this.data}set textContent(e){this.data=null===e?"":String(e)}get wholeText(){let e=this;for(;e.previousSibling&&e.previousSibling.nodeType===NodeService.TEXT_NODE;)e=e.previousSibling;let t="";for(let r=e;r&&r.nodeType===NodeService.TEXT_NODE;r=r.nextSibling)t+=r.nodeValue;return t}splitText(e){if(e<0||e>this.length)throw new Error("The offset is beyond the end of the text.");const t=new TextService(this.data.slice(e));return t.ownerDocumentStore=this.ownerDocumentStore,this.data=this.data.slice(0,e),this.parentNode&&this.parentNode.insertBefore(t,this.nextSibling),t}cloneShallow(){const e=new TextService(this.data);return e.ownerDocumentStore=this.ownerDocumentStore,e}}exports.TextService=TextService;class CommentService extends NodeService{constructor(e=""){super(),this.nodeValue=String(e)}get acceptsChildren(){return!1}get nodeName(){return"#comment"}get nodeType(){return NodeService.COMMENT_NODE}get data(){return this.nodeValue}set data(e){this.nodeValue=String(e)}get length(){return this.data.length}get textContent(){return this.data}set textContent(e){this.data=null===e?"":String(e)}cloneShallow(){const e=new CommentService(this.data);return e.ownerDocumentStore=this.ownerDocumentStore,e}}exports.CommentService=CommentService;
|