File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Example/JavaScriptKitExample/Sources/JavaScriptKitExample Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 1
1
import JavaScriptKit
2
2
3
- let alert = JSObjectRef . global. alert. function!
4
- let document = JSObjectRef . global. document. object!
3
+ let alert = JSObject . global. alert. function!
4
+ let document = JSObject . global. document. object!
5
5
6
6
let divElement = document. createElement!( " div " ) . object!
7
7
divElement. innerText = " Hello, world "
@@ -10,8 +10,9 @@ _ = body.appendChild!(divElement)
10
10
11
11
let buttonElement = document. createElement!( " button " ) . object!
12
12
buttonElement. innerText = " Click me! "
13
- buttonElement . onclick = . function { _ in
13
+ let listener = JSClosure { _ in
14
14
alert ( " Swift is running on browser! " )
15
15
}
16
+ buttonElement. onclick = . function( listener)
16
17
17
18
_ = body. appendChild!( buttonElement)
You can’t perform that action at this time.
0 commit comments