Skip to content

Commit 570fb56

Browse files
committed
Extract Node
1 parent b1af4ac commit 570fb56

File tree

6 files changed

+85
-763
lines changed

6 files changed

+85
-763
lines changed

src/DOMAPI/CharacterData.res

Lines changed: 4 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
open DOMAPI
22
open EventAPI
33

4-
external asNode: characterData => node = "%identity"
5-
external asEventTarget: characterData => eventTarget = "%identity"
4+
include Node.Impl({
5+
type t = characterData
6+
})
7+
68
/**
79
Inserts nodes just before node, while replacing strings in nodes with equivalent Text nodes.
810
@@ -64,182 +66,6 @@ Removes node.
6466
@send
6567
external remove: characterData => unit = "remove"
6668

67-
/**
68-
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
69-
70-
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
71-
72-
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
73-
74-
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
75-
76-
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
77-
78-
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
79-
80-
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
81-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
82-
*/
83-
@send
84-
external addEventListener: (
85-
characterData,
86-
~type_: eventType,
87-
~callback: eventListener<'event>,
88-
~options: addEventListenerOptions=?,
89-
) => unit = "addEventListener"
90-
91-
/**
92-
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
93-
94-
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
95-
96-
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
97-
98-
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
99-
100-
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
101-
102-
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
103-
104-
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
105-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
106-
*/
107-
@send
108-
external addEventListener2: (
109-
characterData,
110-
~type_: eventType,
111-
~callback: eventListener<'event>,
112-
~options: bool=?,
113-
) => unit = "addEventListener"
114-
115-
/**
116-
Removes the event listener in target's event listener list with the same type, callback, and options.
117-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
118-
*/
119-
@send
120-
external removeEventListener: (
121-
characterData,
122-
~type_: eventType,
123-
~callback: eventListener<'event>,
124-
~options: eventListenerOptions=?,
125-
) => unit = "removeEventListener"
126-
127-
/**
128-
Removes the event listener in target's event listener list with the same type, callback, and options.
129-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
130-
*/
131-
@send
132-
external removeEventListener2: (
133-
characterData,
134-
~type_: eventType,
135-
~callback: eventListener<'event>,
136-
~options: bool=?,
137-
) => unit = "removeEventListener"
138-
139-
/**
140-
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
141-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
142-
*/
143-
@send
144-
external dispatchEvent: (characterData, event) => bool = "dispatchEvent"
145-
146-
/**
147-
Returns node's root.
148-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/getRootNode)
149-
*/
150-
@send
151-
external getRootNode: (characterData, ~options: getRootNodeOptions=?) => node = "getRootNode"
152-
153-
/**
154-
Returns whether node has children.
155-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/hasChildNodes)
156-
*/
157-
@send
158-
external hasChildNodes: characterData => bool = "hasChildNodes"
159-
160-
/**
161-
Removes empty exclusive Text nodes and concatenates the data of remaining contiguous exclusive Text nodes into the first of their nodes.
162-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/normalize)
163-
*/
164-
@send
165-
external normalize: characterData => unit = "normalize"
166-
167-
/**
168-
Returns a copy of node. If deep is true, the copy also includes the node's descendants.
169-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/cloneNode)
170-
*/
171-
@send
172-
external cloneNode: (characterData, ~deep: bool=?) => node = "cloneNode"
173-
174-
/**
175-
Returns whether node and otherNode have the same properties.
176-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/isEqualNode)
177-
*/
178-
@send
179-
external isEqualNode: (characterData, node) => bool = "isEqualNode"
180-
181-
/**
182-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/isSameNode)
183-
*/
184-
@send
185-
external isSameNode: (characterData, node) => bool = "isSameNode"
186-
187-
/**
188-
Returns a bitmask indicating the position of other relative to node.
189-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/compareDocumentPosition)
190-
*/
191-
@send
192-
external compareDocumentPosition: (characterData, node) => int = "compareDocumentPosition"
193-
194-
/**
195-
Returns true if other is an inclusive descendant of node, and false otherwise.
196-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/contains)
197-
*/
198-
@send
199-
external contains: (characterData, node) => bool = "contains"
200-
201-
/**
202-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/lookupPrefix)
203-
*/
204-
@send
205-
external lookupPrefix: (characterData, string) => string = "lookupPrefix"
206-
207-
/**
208-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/lookupNamespaceURI)
209-
*/
210-
@send
211-
external lookupNamespaceURI: (characterData, string) => string = "lookupNamespaceURI"
212-
213-
/**
214-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/isDefaultNamespace)
215-
*/
216-
@send
217-
external isDefaultNamespace: (characterData, string) => bool = "isDefaultNamespace"
218-
219-
/**
220-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/insertBefore)
221-
*/
222-
@send
223-
external insertBefore: (characterData, 't, ~child: node) => 't = "insertBefore"
224-
225-
/**
226-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/appendChild)
227-
*/
228-
@send
229-
external appendChild: (characterData, 't) => 't = "appendChild"
230-
231-
/**
232-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/replaceChild)
233-
*/
234-
@send
235-
external replaceChild: (characterData, ~node: node, 't) => 't = "replaceChild"
236-
237-
/**
238-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/removeChild)
239-
*/
240-
@send
241-
external removeChild: (characterData, 't) => 't = "removeChild"
242-
24369
/**
24470
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CharacterData/substringData)
24571
*/

src/DOMAPI/Document.res

Lines changed: 4 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ open ViewTransitionsAPI
88
@new
99
external make: unit => document = "Document"
1010

11-
external asNode: document => node = "%identity"
12-
external asEventTarget: document => eventTarget = "%identity"
11+
include Node.Impl({
12+
type t = document
13+
})
14+
1315
/**
1416
Returns the first element within node's descendants whose ID is elementId.
1517
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/getElementById)
@@ -114,182 +116,6 @@ external evaluate: (
114116
~result: xPathResult=?,
115117
) => xPathResult = "evaluate"
116118

117-
/**
118-
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
119-
120-
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
121-
122-
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
123-
124-
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
125-
126-
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
127-
128-
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
129-
130-
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
131-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
132-
*/
133-
@send
134-
external addEventListener: (
135-
document,
136-
~type_: eventType,
137-
~callback: eventListener<'event>,
138-
~options: addEventListenerOptions=?,
139-
) => unit = "addEventListener"
140-
141-
/**
142-
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
143-
144-
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
145-
146-
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
147-
148-
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
149-
150-
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
151-
152-
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
153-
154-
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
155-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
156-
*/
157-
@send
158-
external addEventListener2: (
159-
document,
160-
~type_: eventType,
161-
~callback: eventListener<'event>,
162-
~options: bool=?,
163-
) => unit = "addEventListener"
164-
165-
/**
166-
Removes the event listener in target's event listener list with the same type, callback, and options.
167-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
168-
*/
169-
@send
170-
external removeEventListener: (
171-
document,
172-
~type_: eventType,
173-
~callback: eventListener<'event>,
174-
~options: eventListenerOptions=?,
175-
) => unit = "removeEventListener"
176-
177-
/**
178-
Removes the event listener in target's event listener list with the same type, callback, and options.
179-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
180-
*/
181-
@send
182-
external removeEventListener2: (
183-
document,
184-
~type_: eventType,
185-
~callback: eventListener<'event>,
186-
~options: bool=?,
187-
) => unit = "removeEventListener"
188-
189-
/**
190-
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
191-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
192-
*/
193-
@send
194-
external dispatchEvent: (document, event) => bool = "dispatchEvent"
195-
196-
/**
197-
Returns node's root.
198-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/getRootNode)
199-
*/
200-
@send
201-
external getRootNode: (document, ~options: getRootNodeOptions=?) => node = "getRootNode"
202-
203-
/**
204-
Returns whether node has children.
205-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/hasChildNodes)
206-
*/
207-
@send
208-
external hasChildNodes: document => bool = "hasChildNodes"
209-
210-
/**
211-
Removes empty exclusive Text nodes and concatenates the data of remaining contiguous exclusive Text nodes into the first of their nodes.
212-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/normalize)
213-
*/
214-
@send
215-
external normalize: document => unit = "normalize"
216-
217-
/**
218-
Returns a copy of node. If deep is true, the copy also includes the node's descendants.
219-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/cloneNode)
220-
*/
221-
@send
222-
external cloneNode: (document, ~deep: bool=?) => node = "cloneNode"
223-
224-
/**
225-
Returns whether node and otherNode have the same properties.
226-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/isEqualNode)
227-
*/
228-
@send
229-
external isEqualNode: (document, node) => bool = "isEqualNode"
230-
231-
/**
232-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/isSameNode)
233-
*/
234-
@send
235-
external isSameNode: (document, node) => bool = "isSameNode"
236-
237-
/**
238-
Returns a bitmask indicating the position of other relative to node.
239-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/compareDocumentPosition)
240-
*/
241-
@send
242-
external compareDocumentPosition: (document, node) => int = "compareDocumentPosition"
243-
244-
/**
245-
Returns true if other is an inclusive descendant of node, and false otherwise.
246-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/contains)
247-
*/
248-
@send
249-
external contains: (document, node) => bool = "contains"
250-
251-
/**
252-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/lookupPrefix)
253-
*/
254-
@send
255-
external lookupPrefix: (document, string) => string = "lookupPrefix"
256-
257-
/**
258-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/lookupNamespaceURI)
259-
*/
260-
@send
261-
external lookupNamespaceURI: (document, string) => string = "lookupNamespaceURI"
262-
263-
/**
264-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/isDefaultNamespace)
265-
*/
266-
@send
267-
external isDefaultNamespace: (document, string) => bool = "isDefaultNamespace"
268-
269-
/**
270-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/insertBefore)
271-
*/
272-
@send
273-
external insertBefore: (document, 't, ~child: node) => 't = "insertBefore"
274-
275-
/**
276-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/appendChild)
277-
*/
278-
@send
279-
external appendChild: (document, 't) => 't = "appendChild"
280-
281-
/**
282-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/replaceChild)
283-
*/
284-
@send
285-
external replaceChild: (document, ~node: node, 't) => 't = "replaceChild"
286-
287-
/**
288-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/removeChild)
289-
*/
290-
@send
291-
external removeChild: (document, 't) => 't = "removeChild"
292-
293119
/**
294120
Retrieves a collection of objects based on the specified element name.
295121
@param name Specifies the name of an element.

0 commit comments

Comments
 (0)