Use RouteOptions type, test other properties

This commit is contained in:
spacejack
2019-02-01 19:15:09 -05:00
parent b4c953da52
commit 8b89df6f8a
2 changed files with 11 additions and 3 deletions
+1 -1
View File
@@ -96,7 +96,7 @@ declare namespace Mithril {
prefix(urlFragment: string): void;
/** This method is meant to be used in conjunction with an <a> Vnode's oncreate/onupdate hooks. */
link(vnode: Vnode<any, any>): (e?: Event) => any;
link(options: {replace: boolean}): (vnode: Vnode<any, any>) => (e?: Event) => any;
link(options: RouteOptions): (vnode: Vnode<any, any>) => (e?: Event) => any;
/** Returns the named parameter value from the current route. */
param(name: string): string;
/** Gets all route parameters. */
+10 -2
View File
@@ -127,8 +127,16 @@ const path: string = route.get();
const fn1: (e?: Event) => any = route.link(h('div', 'test'));
const fn2: (v: Vnode<any, any>) => any = route.link({replace: true});
const fn2: (v: Vnode<any, any>) => any = route.link({
replace: true,
state: {abc: 123},
title: "Title"
});
const ex1 = h('a', {href: '/url', oncreate: route.link});
const ex2 = h('a', {href: '/url', oncreate: route.link({replace: true})});
const ex2 = h('a', {href: '/url', oncreate: route.link({
replace: true,
state: {abc: 123},
title: "Title"
})});