style fixes in docs
This commit is contained in:
parent
cd8b8b12e6
commit
e24e4e9a1a
3 changed files with 9 additions and 9 deletions
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
Components are a mechanism to encapsulate parts of a view to make code easier to organize and/or reuse.
|
||||
|
||||
Any Javascript object that has a view method is a Mithril component. Components can be consumed via the [`m`](hyperscript.md) utility:
|
||||
Any Javascript object that has a view method is a Mithril component. Components can be consumed via the [`m()`](hyperscript.md) utility:
|
||||
|
||||
```javascript
|
||||
var Example = {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ Argument | Type | Required | Descripti
|
|||
|
||||
### How it works
|
||||
|
||||
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).
|
||||
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")
|
||||
|
|
@ -45,7 +45,7 @@ m("div", {id: "box"}, "hello")
|
|||
// <div id="box">hello</div>
|
||||
```
|
||||
|
||||
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.
|
||||
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
|
||||
|
|
@ -64,7 +64,7 @@ Calling `m.render()` multiple times does **not** recreate the DOM tree from scra
|
|||
|
||||
### Flexibility
|
||||
|
||||
The `m` function is both *polymorphic* and *variadic*. In other words, it's very flexible in what it expects as input parameters:
|
||||
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
|
||||
|
|
@ -91,7 +91,7 @@ m("ul", // <ul>
|
|||
|
||||
### CSS selectors
|
||||
|
||||
The first argument of `m` can be any CSS selector that can describe an HTML element. It accepts any valid CSS combinations of `#` (id), `.` (class) and `[]` (attribute) syntax.
|
||||
The first argument of `m()` can be any CSS selector that can describe an HTML element. It accepts any valid CSS combinations of `#` (id), `.` (class) and `[]` (attribute) syntax.
|
||||
|
||||
```javascript
|
||||
m("div#hello")
|
||||
|
|
@ -126,7 +126,7 @@ m("a.link[href=/]", {
|
|||
<a href="/" class="link selected">Home</a>
|
||||
```
|
||||
|
||||
If there are class names in both first and second arguments of `m`, they are merged together as you would expect.
|
||||
If there are class names in both first and second arguments of `m()`, they are merged together as you would expect.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ MathML is also fully supported.
|
|||
|
||||
[Components](components.md) allow you to encapsulate logic into a unit and use it as if it was an element. They are the base for making large, scalable applications.
|
||||
|
||||
A component is any Javascript object that contains a `view` method. To consume a component, pass the component as the first argument to `m` instead of passing a CSS selector string. You can pass arguments to the component by defining attributes and children, as shown in the example below.
|
||||
A component is any Javascript object that contains a `view` method. To consume a component, pass the component as the first argument to `m()` instead of passing a CSS selector string. You can pass arguments to the component by defining attributes and children, as shown in the example below.
|
||||
|
||||
```javascript
|
||||
// define a component
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ Virtual DOM goes one step further than HTML by allowing you to write *dynamic* D
|
|||
|
||||
Virtual DOM nodes, or *vnodes*, are javascript objects that represent DOM elements (or parts of the DOM). Mithril's virtual DOM engine consumes a tree of vnodes to produce a DOM tree.
|
||||
|
||||
Vnodes can be created via the [`m`](hyperscript.md) hyperscript utility:
|
||||
Vnodes can be created via the [`m()`](hyperscript.md) hyperscript utility:
|
||||
|
||||
```javascript
|
||||
m("div", {id: "test"}, "hello")
|
||||
|
|
@ -91,7 +91,7 @@ Component | `{tag: ExampleComponent}` | If `tag` is a Javascript object
|
|||
|
||||
Everything in a virtual DOM tree is a vnode, including text. The `m()` utility automatically normalizes its `children` argument and turns strings into text vnodes and nested arrays into fragment vnodes.
|
||||
|
||||
Only element tag names and components can be the first argument of the `m` function. In other words, `[`, `#` and `<` are not valid `selector` arguments for `m()`. Trusted HTML vnodes can be created via [`m.trust()`](trust.md)
|
||||
Only element tag names and components can be the first argument of the `m()` function. In other words, `[`, `#` and `<` are not valid `selector` arguments for `m()`. Trusted HTML vnodes can be created via [`m.trust()`](trust.md)
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue