File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55Swift framework to interact with JavaScript through WebAssembly.
66
7+ ## Usage
8+
9+ This JavaScript code
10+
11+ ``` javascript
12+ const alert = window .alert
13+ const document = window .document
14+
15+ const divElement = document .createElement (" div" )
16+ divElement .innerText = " Hello, world"
17+ const body = document .body
18+ body .appendChild (divElement)
19+
20+ alert (" JavaScript is running on browser!" )
21+ ```
22+
23+ Can be written in Swift using JavaScriptKit
24+
25+ ``` swift
26+ import JavaScriptKit
27+
28+ let alert = JSObjectRef.global .alert .function !
29+ let document = JSObjectRef.global .document .object !
30+
31+ let divElement = document.createElement ! (" div" ).object !
32+ divElement.innerText = " Hello, world"
33+ let body = document.body .object !
34+ _ = body.appendChild ! (divElement)
35+
36+ alert (" Swift is running on browser!" )
37+ ```
38+
39+
40+ Please see [ Example] ( https://github.com/kateinoigakukun/JavaScriptKit/tree/master/Example ) directory for more information
You can’t perform that action at this time.
0 commit comments