Skip to content

Commit 46bd97a

Browse files
committed
Add an example to confirm (String|Node)* is usable as expected
1 parent c85891d commit 46bd97a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

example/src/main/scala/example/Example.scala

+14-7
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,23 @@ object Alert {
1818
object NodeAppendChild {
1919
@JSExport
2020
def main(div: html.Div) = {
21-
val child = dom.document
22-
.createElement("div")
23-
24-
child.textContent =
25-
"Hi from Scala-js-dom"
26-
21+
val child = dom.document.createElement("div")
22+
child.textContent = "Hi from Scala-js-dom"
2723
div.appendChild(child)
2824
}
2925
}
3026

27+
@JSExportTopLevel("ExampleNodeReplaceChildren")
28+
object NodeReplaceChildren {
29+
@JSExport
30+
def main(div: html.Div): Unit = {
31+
dom.document.replaceChildren()
32+
dom.document.replaceChildren("")
33+
dom.document.replaceChildren(div)
34+
dom.document.replaceChildren("", div)
35+
}
36+
}
37+
3138
@JSExportTopLevel("ExampleElementStyle")
3239
object ElementStyle {
3340
@JSExport
@@ -123,7 +130,7 @@ object XMLHttpRequest{
123130
@JSExport
124131
def main(pre: html.Pre) = {
125132
val xhr = new dom.XMLHttpRequest()
126-
xhr.open("GET",
133+
xhr.open("GET",
127134
"https://www.boredapi.com/api/activity"
128135
)
129136
xhr.onload = { (e: dom.Event) =>

0 commit comments

Comments
 (0)