update docs about config: m.route

This commit is contained in:
Leo Horie 2015-04-22 20:32:39 -04:00
parent 51d073e414
commit f0b20da30a
3 changed files with 11 additions and 3 deletions

View file

@ -389,7 +389,7 @@ See [`m()`](mithril.md) for more information on virtual elements.
[How to read signatures](how-to-read-signatures.md)
```clike
void route(DOMElement element, Boolean isInitialized)
void route(DOMElement element, Boolean isInitialized, Object context, Object vdom)
```
- **DOMElement element**
@ -399,3 +399,11 @@ void route(DOMElement element, Boolean isInitialized)
- **Boolean isInitialized**
the method does not run if this flag is set to true. This is to make the method compatible with virtual DOM elements' `config` attribute (see [`m()`](mithril))
- **Object context**
an object that retains its state across redraws
- **Object vdom**
The virtual DOM data structure to which the config is applied to

2
mithril.d.ts vendored
View file

@ -29,7 +29,7 @@ declare module _mithril {
<T extends MithrilController>(rootElement: HTMLDocument, defaultRoute: string, routes: MithrilRoutes<T>): void;
<T extends MithrilController>(rootElement: Element, defaultRoute: string, routes: MithrilRoutes<T>): void;
(element: Element, isInitialized: boolean): void;
(element: Element, isInitialized: boolean, context: Object, vdom: Object): void;
(path: string, params?: any, shouldReplaceHistory?: boolean): void;
(): string;

View file

@ -700,7 +700,7 @@ var m = (function app(window, undefined) {
var element = arguments[0];
var isInitialized = arguments[1];
var context = arguments[2];
element.href = (m.route.mode !== 'pathname' ? $location.pathname : '') + modes[m.route.mode] + (this.attrs ? this.attrs.href : '');
element.href = (m.route.mode !== 'pathname' ? $location.pathname : '') + modes[m.route.mode] + vdom.attrs.href;
if (element.addEventListener) {
element.removeEventListener("click", routeUnobtrusive);
element.addEventListener("click", routeUnobtrusive)