Skip to content

Commit e0bad5c

Browse files
committed
Extract DocumentFragment
1 parent befe659 commit e0bad5c

File tree

4 files changed

+80
-306
lines changed

4 files changed

+80
-306
lines changed

src/DOMAPI/DocumentFragment.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/DOMAPI/DocumentFragment.res

Lines changed: 62 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,86 +2,98 @@ open DOMAPI
22
open EventAPI
33

44
/**
5-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment)
5+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragmentFragment)
66
*/
77
@new
88
external make: unit => documentFragment = "DocumentFragment"
99

10-
include Node.Impl({
11-
type t = documentFragment
12-
})
10+
module Impl = (
11+
T: {
12+
type t
13+
},
14+
) => {
15+
include Node.Impl({
16+
type t = T.t
17+
})
1318

14-
/**
15-
Returns the first element within node's descendants whose ID is elementId.
16-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/getElementById)
19+
external asDocumentFragment: T.t => documentFragment = "%identity"
20+
21+
/**
22+
Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes.
23+
24+
Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
25+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/append)
1726
*/
18-
@send
19-
external getElementById: (documentFragment, string) => element = "getElementById"
27+
@send
28+
external append: (T.t, node) => unit = "append"
2029

21-
/**
22-
Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes.
30+
/**
31+
Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes.
2332
2433
Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
25-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/prepend)
34+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/append)
2635
*/
27-
@send
28-
external prepend: (documentFragment, node) => unit = "prepend"
36+
@send
37+
external append2: (T.t, string) => unit = "append"
2938

30-
/**
39+
/**
40+
Returns the first element within node's descendants whose ID is elementId.
41+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/getElementById)
42+
*/
43+
@send
44+
external getElementById: (T.t, string) => element = "getElementById"
45+
46+
/**
3147
Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes.
3248
3349
Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
34-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/prepend)
50+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/prepend)
3551
*/
36-
@send
37-
external prepend2: (documentFragment, string) => unit = "prepend"
52+
@send
53+
external prepend: (T.t, node) => unit = "prepend"
3854

39-
/**
40-
Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes.
55+
/**
56+
Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes.
4157
4258
Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
43-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/append)
59+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/prepend)
4460
*/
45-
@send
46-
external append: (documentFragment, node) => unit = "append"
61+
@send
62+
external prepend2: (T.t, string) => unit = "prepend"
4763

48-
/**
49-
Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes.
64+
/**
65+
Returns the first element that is a descendant of node that matches selectors.
66+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/querySelector)
67+
*/
68+
@send
69+
external querySelector: (T.t, string) => element = "querySelector"
5070

51-
Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
52-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/append)
71+
/**
72+
Returns all element descendants of node that match selectors.
73+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/querySelectorAll)
5374
*/
54-
@send
55-
external append2: (documentFragment, string) => unit = "append"
75+
@send
76+
external querySelectorAll: (T.t, string) => nodeList = "querySelectorAll"
5677

57-
/**
78+
/**
5879
Replace all children of node with nodes, while replacing strings in nodes with equivalent Text nodes.
5980
6081
Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
61-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/replaceChildren)
82+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/replaceChildren)
6283
*/
63-
@send
64-
external replaceChildren: (documentFragment, node) => unit = "replaceChildren"
84+
@send
85+
external replaceChildren: (T.t, node) => unit = "replaceChildren"
6586

66-
/**
87+
/**
6788
Replace all children of node with nodes, while replacing strings in nodes with equivalent Text nodes.
6889
6990
Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
70-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/replaceChildren)
91+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/replaceChildren)
7192
*/
72-
@send
73-
external replaceChildren2: (documentFragment, string) => unit = "replaceChildren"
93+
@send
94+
external replaceChildren2: (T.t, string) => unit = "replaceChildren"
95+
}
7496

75-
/**
76-
Returns the first element that is a descendant of node that matches selectors.
77-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/querySelector)
78-
*/
79-
@send
80-
external querySelector: (documentFragment, string) => element = "querySelector"
81-
82-
/**
83-
Returns all element descendants of node that match selectors.
84-
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/querySelectorAll)
85-
*/
86-
@send
87-
external querySelectorAll: (documentFragment, string) => nodeList = "querySelectorAll"
97+
include Impl({
98+
type t = documentFragment
99+
})

src/DOMAPI/ShadowRoot.js

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)