-
Notifications
You must be signed in to change notification settings - Fork 0
/
RunTests.hx
46 lines (38 loc) · 995 Bytes
/
RunTests.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package ;
import js.Browser.*;
import vdom.VDom.*;
import coconut.Ui.hxx;
import coconut.router.Router;
class RunTests {
static function main() {
var data = new RouteData({
provider: new MyProvider(),
});
window.addEventListener('popstate', function() data.url = window.location.href);
document.body.appendChild(hxx('<BrowserRouter data=${data}/>').toElement());
}
}
class MyProvider extends BrowserProvider {
override function route(url:tink.Url) {
return switch url.path.toString() {
case '/':
hxx('<Home/>');
case '/next':
hxx('<div><a>Hello</a> <a href="/other">World</a></div>');
case v:
hxx('<Other url=${url.toString()}/>');
}
}
}
class Home extends coconut.ui.View<{}> {
function render() '
<div>
This is Home Page. <a href="next?123">Go to next page</a>
</div>
';
}
class Other extends coconut.ui.View<{url:String}> {
function render() '
<a href="google.com">${url}</a>
';
}