From 4a53a49b89ff1b7c37af5d5fbfd14ba1e3320009 Mon Sep 17 00:00:00 2001 From: pixelmike Date: Sat, 30 Jan 2016 12:22:01 -0500 Subject: [PATCH 1/2] Added an overload for withAttr. Added parameters to component controller and view functions. --- mithril.d.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mithril.d.ts b/mithril.d.ts index 111a9ebc..c8710226 100644 --- a/mithril.d.ts +++ b/mithril.d.ts @@ -27,7 +27,7 @@ declare module _mithril { MithrilVirtualElement | MithrilComponent> ): MithrilVirtualElement; - + /** * Initializes a component for use with m.render, m.mount, etc. * @@ -127,6 +127,19 @@ declare module _mithril { callbackThis: any ): (e: Event) => any; + /** + * Returns a event handler that can be bound to an element, firing with + * the specified property. + * + * @param attributeName Name of the element's attribute to bind to. + * @param property The property to bind. + * @return A function suitable for listening to an event. + */ + withAttr( + attributeName: string, + property: MithrilBasicProperty + ) : (e: Event) => any; + /** * @deprecated Use m.mount instead */ @@ -561,7 +574,7 @@ declare module _mithril { * @see MithrilControllerConstructor */ interface MithrilControllerFunction { - (): T; + (opts?: any): T; } /** @@ -603,7 +616,7 @@ declare module _mithril { * * @see m.component */ - view(ctrl: T): MithrilVirtualElement; + view(ctrl?: T, opts?: any): MithrilVirtualElement; } /** From 55b29d2beffebfa8b209d0fb406a8b045f6d1de5 Mon Sep 17 00:00:00 2001 From: Scott Kelly Date: Wed, 3 Feb 2016 21:54:49 -0600 Subject: [PATCH 2/2] Fixes typo in component.md --- docs/mithril.component.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mithril.component.md b/docs/mithril.component.md index fa03042f..bd7c1ec3 100644 --- a/docs/mithril.component.md +++ b/docs/mithril.component.md @@ -362,7 +362,7 @@ var MyComponent = { }, view: function(ctrl) { return m("ul", [ - ctrl.things().map(function(name) { + ctrl.things().map(function(thing) { return m("li", thing.name) }) ]);