diff --git a/README.md b/README.md index d1c54163..fb4ef543 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,10 @@ Mithril's `config` method is now replaced by several lifecycle methods to improv ## Robustness -There are over 2500 assertions in the test suite, and tests cover even difficult-to-test things like `location.href`, `element.innerHTML` and `XMLHttpRequest` usage. +There are over 2600 assertions in the test suite, and tests cover even difficult-to-test things like `location.href`, `element.innerHTML` and `XMLHttpRequest` usage. ## Modularity -Despite the huge performance improvements, the new codebase is smaller than v0.2.x, currently clocking at 6.5kb min+gzip +Despite the huge performance improvements, the new codebase is smaller than v0.2.x, currently clocking at 6.7kb min+gzip In addition, Mithril is now completely modular: you can import only the modules that you need and easily integrate 3rd party modules if you wish to use a different library for routing, ajax, and even rendering diff --git a/docs/hyperscript.md b/docs/hyperscript.md index ac323912..d85163ed 100644 --- a/docs/hyperscript.md +++ b/docs/hyperscript.md @@ -1,6 +1,6 @@ # m(selector, attributes, children) -- [Signature](#signature) +- [API](#api) - [How it works](#how-it-works) - [Flexibility](#flexibility) - [CSS selectors](#css-selectors) @@ -13,11 +13,11 @@ - [Keys](#keys) - [SVG and MathML](#svg-and-mathml) - [Making templates dynamic](#making-templates-dynamic) -- [Avoid-anti-patterns](#avoid-anti-patterns) +- [Avoid anti-patterns](#avoid-anti-patterns) --- -### Signature +### API `vnode = m(selector, attributes, children)` @@ -37,8 +37,6 @@ Argument | Type | Required | Descripti Mithril provides a hyperscript function `m()`, which allows expressing any HTML structure using javascript syntax. It accepts a `selector` string (required), an `attributes` object (optional) and a `children` array (optional). ```javascript -var m = require("mithril") - m("div", {id: "box"}, "hello") // equivalent HTML: @@ -48,13 +46,13 @@ m("div", {id: "box"}, "hello") The `m()` function does not actually return a DOM element. Instead it returns a [virtual DOM node](vnodes.md), or *vnode*, which is a javascript object that represents the DOM element to be created. ```javascript -//a vnode -{tag: "div", attrs: {id: "box"}, children: [ /*...*/ ]} +// a vnode +var vnode = {tag: "div", attrs: {id: "box"}, children: [ /*...*/ ]} ``` To transform a vnode into an actual DOM element, use the [`m.render()`](render.md) function: -``` +```javascript m.render(document.body, m("br")) // puts a
in ``` @@ -67,14 +65,14 @@ Calling `m.render()` multiple times does **not** recreate the DOM tree from scra The `m()` function is both *polymorphic* and *variadic*. In other words, it's very flexible in what it expects as input parameters: ```javascript -//simple tag +// simple tag m("div") //
-//attributes and children are optional +// attributes and children are optional m("a", {id: "b"}) // m("span", "hello") // hello -//tag with child nodes +// tag with child nodes m("ul", [ //