From f0b20da30a805b614d6cd640b272a951134d50d3 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Wed, 22 Apr 2015 20:32:39 -0400 Subject: [PATCH] update docs about config: m.route --- docs/mithril.route.md | 10 +++++++++- mithril.d.ts | 2 +- mithril.js | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/mithril.route.md b/docs/mithril.route.md index 60fbac53..87715abc 100644 --- a/docs/mithril.route.md +++ b/docs/mithril.route.md @@ -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 diff --git a/mithril.d.ts b/mithril.d.ts index 2625b2f3..1a1e1562 100644 --- a/mithril.d.ts +++ b/mithril.d.ts @@ -29,7 +29,7 @@ declare module _mithril { (rootElement: HTMLDocument, defaultRoute: string, routes: MithrilRoutes): void; (rootElement: Element, defaultRoute: string, routes: MithrilRoutes): void; - (element: Element, isInitialized: boolean): void; + (element: Element, isInitialized: boolean, context: Object, vdom: Object): void; (path: string, params?: any, shouldReplaceHistory?: boolean): void; (): string; diff --git a/mithril.js b/mithril.js index e7eb91b0..96e2ff2c 100644 --- a/mithril.js +++ b/mithril.js @@ -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)