1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
| type Comment := {
| data: String,
| length: Number,
| nodeName: "#comment",
| nodeType: 8,
| nodeValue: String,
| ownerDoucment: null | Document,
|
| toString: (this: Comment) => String
| }
|
| type DOMText := {
| data: String,
| type: "DOMTextNode",
| length: Number,
| nodeType: 3,
|
| toString: (this: DOMText) => String,
| replaceChild: (
| this: DOMText,
| index: Number,
| length: Number,
| value: String
| ) => void
| }
|
| type DOMNode := DOMText | DOMElement | DocumentFragment
| type DOMChild := DOMText | DOMElement
|
| type DOMElement := {
| tagName: String,
| className: String,
| dataset: Object<String, Any>,
| childNodes: Array<DOMChild>,
| parentNode: null | DOMElement,
| style: Object<String, String>,
| type: "DOMElement",
| nodeType: 1,
| ownerDoucment: null | Document,
| namespaceURI: null | String,
|
| appendChild: (this: DOMElement, child: DOMChild) => DOMChild,
| replaceChild:(
| this: DOMElement,
| elem: DOMChild,
| needle: DOMChild
| ) => DOMChild,
| removeChild: (this: DOMElement, child: DOMChild) => DOMChild,
| insertBefore: (
| this: DOMElement,
| elem: DOMChild,
| needle: DOMChild | null | undefined
| ) => DOMChild,
| addEventListener: addEventListener,
| dispatchEvent: dispatchEvent,
| focus: () => void,
| toString: (this: DOMElement) => String,
| getElementsByClassName: (
| this: DOMElement,
| className: String
| ) => Array<DOMElement>,
| getElementsByTagName: (
| this: DOMElement,
| tagName: String
| ) => Array<DOMElement>,
| }
|
| type DocumentFragment := {
| childNodes: Array<DOMChild>,
| parentNode: null | DOMElement,
| type: "DocumentFragment",
| nodeType: 11,
| nodeName: "#document-fragment",
| ownerDoucment: Document | null,
|
| appendChild: (this: DocumentFragment, child: DOMChild),
| replaceChild:
| (this: DocumentFragment, elem: DOMChild, needle: DOMChild),
| removeChild: (this: DocumentFragment, child: DOMChild),
| toString: (this: DocumentFragment) => String
| }
|
| type Document := {
| body: DOMElement,
| childNodes: Array<DOMChild>,
| documentElement: DOMElement,
| nodeType: 9,
|
| createComment: (this: Document, data: String) => Commment,
| createTextNode: (this: Document, value: String) => DOMText,
| createElement: (this: Document, tagName: String) => DOMElement,
| createElementNS: (
| this: Document,
| namespace: String | null,
| tagName: String
| ) => DOMElement,
| createDocumentFragment: (this: Document) => DocumentFragment,
| createEvent: () => Event,
| getElementById: (
| this: Document,
| id: String,
| ) => null | DOMElement,
| getElementsByClassName: (
| this: Document,
| className: String
| ) => Array<DOMElement>,
| getElementsByTagName: (
| this: Document,
| tagName: String
| ) => Array<DOMElement>
| }
|
| type Event := {
| type: String,
| bubbles: Boolean,
| cancelable: Boolean,
|
| initEvent: (
| this: Event,
| type: String,
| bubbles: Boolean,
| cancelable: Boolean
| ) => void
| }
|
| type addEventListener := (
| this: DOMElement,
| type: String,
| listener: Listener
| ) => void
|
| type dispatchEvent := (
| this: DOMElement,
| ev: Event
| )
|
| min-document/event/add-event-listener := addEventListener
|
| min-document/event/dispatch-event := dispatchEvent
|
| min-document/document := () => Document
|
| min-document/dom-element :=
| (tagName: String, owner?: Document, namespace?: String | null) => DOMElement
|
| min-document/dom-fragment :=
| (owner?: Document) => DocumentFragment
|
| min-document/dom-text :=
| (value: String, owner?: Document) => DOMText
|
| min-document/event := () => Event
|
| min-document/serialize := (DOMElement) => String
|
| min-document := Document
|
|