improve docs

This commit is contained in:
Leo Horie 2014-09-14 00:52:11 -04:00
parent 067da7eedc
commit 1dffbf781f
5 changed files with 71 additions and 2 deletions

View file

@ -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:

View file

@ -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")
```

View file

@ -16,6 +16,8 @@ In order to use Mithril, extract it from the zip file and point a script tag to
<script src="mithril.min.js"></script>
```
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)

View file

@ -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 }

View file

@ -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<any> data),]
[XMLHttpRequest? config(XMLHttpRequest xhr, XHROptions options)]
}
JSONPOptions :: Object {
String dataType,
String url,
String callbackKey,
Object<any> 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<any> data** (optional)
Data to be sent. It's automatically placed in the appropriate section of the request with the appropriate serialization based on `method`