From 1dffbf781f0b49aeefe7b5b3f0d02ce78d8dbc06 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Sun, 14 Sep 2014 00:52:11 -0400 Subject: [PATCH] improve docs --- docs/change-log.md | 15 +++++++++++++++ docs/how-to-read-signatures.md | 21 +++++++++++++++++++++ docs/installation.md | 2 ++ docs/mithril.md | 2 +- docs/mithril.request.md | 33 ++++++++++++++++++++++++++++++++- 5 files changed, 71 insertions(+), 2 deletions(-) diff --git a/docs/change-log.md b/docs/change-log.md index 736afa9f..44290144 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -1,5 +1,20 @@ ## Change Log +[v0.1.22](/mithril/archive/v0.1.22) - maintenance + +### News: + +- docs now have anchor links for easier navigation +- there is more documentation for things that weren't that clear +- json-p support added +- `m()` now supports splat for children (e.g. `m("div", m("a"), m("b"), m("i"))` for nicer Coffeescript syntax + +### Bug Fixes: + +- gracefully degrade on IE exceptions when setting invalid values + +--- + [v0.1.21](/mithril/archive/v0.1.21) - maintenance ### News: diff --git a/docs/how-to-read-signatures.md b/docs/how-to-read-signatures.md index fc794466..84cdc820 100644 --- a/docs/how-to-read-signatures.md +++ b/docs/how-to-read-signatures.md @@ -174,3 +174,24 @@ XMLHttpRequest? config() ``` In the example above, the `config` function is expected to return either an instance of the XMLHttpRequest object or `undefined` + +### Splat + +An ellipsis `...` means that an array argument can instead be a list of arguments + +```clike +VirtualElement m(String selector [, Attributes attributes] [, Children... children]) +``` + +In the example above, we can define children as an array: + +```javascript +m("div", {title: "foo"}, ["child 1", "child 2", "child 3"]) +``` + +And we also define it as a list of arguments (note that lack of square brackets) + +```javascript +m("div", {title: "foo"}, "child 1", "child 2", "child 3") +``` + diff --git a/docs/installation.md b/docs/installation.md index b927c78c..dfd73744 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -16,6 +16,8 @@ In order to use Mithril, extract it from the zip file and point a script tag to ``` +Note that in order to support older versions of IE, you need to include [some shims](tools.md#internet-explorer-compatibility). + --- ### CDNs (Content Delivery Networks) diff --git a/docs/mithril.md b/docs/mithril.md index fcb2eb20..e0254a99 100644 --- a/docs/mithril.md +++ b/docs/mithril.md @@ -326,7 +326,7 @@ m("li", {class: selected ? "active" : ""}) [How to read signatures](how-to-read-signatures.md) ```clike -VirtualElement m(String selector [, Attributes attributes] [, Children children]) +VirtualElement m(String selector [, Attributes attributes] [, Children... children]) where: VirtualElement :: Object { String tag, Attributes attributes, Children children } diff --git a/docs/mithril.request.md b/docs/mithril.request.md index 5106a92b..81bea069 100644 --- a/docs/mithril.request.md +++ b/docs/mithril.request.md @@ -319,11 +319,12 @@ transport().abort(); [How to read signatures](how-to-read-signatures.md) ```clike -Promise request(XHROptions options) +Promise request(Options options) where: Promise :: GetterSetter { Promise then(any successCallback(any value), any errorCallback(any value)) } GetterSetter :: any getterSetter([any value]) + Options :: XHROptions | JSONPOptions XHROptions :: Object { String method, String url, @@ -339,6 +340,12 @@ where: [void type(Object data),] [XMLHttpRequest? config(XMLHttpRequest xhr, XHROptions options)] } + JSONPOptions :: Object { + String dataType, + String url, + String callbackKey, + Object data + } ``` - **XHROptions options** @@ -478,4 +485,28 @@ where: returns a promise that can bind callbacks which get called on completion of the AJAX request. +--- + +- **JSONPOptions options** + + A map of options for JSONP requests + - **String dataType** + + Must be the string "jsonp" + + - **String url** + + The URL to request. If the URL is not in the same domain as the application, the target server must be configured to accept cross-domain requests from the application's domain, i.e. its responses must include the header `Access-Control-Allow-Origin: *`. + + - **String callbackKey** + + The name of the querystring key that defines the name of the callback function to be called by the response. Defaults to "callback" + + This option is useful for web services that use uncommon conventions for defining jsonp callbacks (e.g. foo.com/?jsonpCallback=doSomething) + + - **Object data** (optional) + + Data to be sent. It's automatically placed in the appropriate section of the request with the appropriate serialization based on `method` + +