Add editorconfig, resolve differences
This includes newlines, tabs, among other things.
This commit is contained in:
parent
80d0a69dab
commit
b4fb21475c
90 changed files with 1707 additions and 1701 deletions
|
|
@ -229,7 +229,7 @@ To learn more about components, [see the components page](components.md).
|
|||
|
||||
### Lifecycle methods
|
||||
|
||||
Vnodes and components can have lifecycle methods (also known as *hooks*), which are called at various points during the lifetime of a DOM element. The lifecycle methods supported by Mithril are: `oninit`, `oncreate`, `onupdate`, `onbeforeremove`, `onremove`, and `onbeforeupdate`.
|
||||
Vnodes and components can have lifecycle methods (also known as *hooks*), which are called at various points during the lifetime of a DOM element. The lifecycle methods supported by Mithril are: `oninit`, `oncreate`, `onupdate`, `onbeforeremove`, `onremove`, and `onbeforeupdate`.
|
||||
|
||||
Lifecycle methods are defined in the same way as DOM event handlers, but receive the vnode as an argument, instead of an Event object:
|
||||
|
||||
|
|
@ -309,7 +309,7 @@ m("ul", users.map(function(u) { // <ul>
|
|||
})) // </ul>
|
||||
|
||||
// ES6:
|
||||
// m("ul", users.map(u =>
|
||||
// m("ul", users.map(u =>
|
||||
// m("li", u.name)
|
||||
// ))
|
||||
```
|
||||
|
|
@ -392,7 +392,7 @@ var BadListComponent = {
|
|||
for (var i = 0; i < vnode.attrs.items.length; i++) {
|
||||
list.push(m("li", vnode.attrs.items[i]))
|
||||
}
|
||||
|
||||
|
||||
return m("ul", list)
|
||||
}
|
||||
}
|
||||
|
|
@ -409,4 +409,4 @@ var BetterListComponent = {
|
|||
}))
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
|
|
|||
|
|
@ -150,4 +150,3 @@ var things = [
|
|||
{id: 1, name: "Cup"},
|
||||
]
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -204,4 +204,4 @@ If a design-based solution is not feasible, and you must optimize a UI with a la
|
|||
|
||||
Avoid applying the optimization to other areas of your application "just-in-case". Remember that, generally speaking, more code incurs a higher maintenance cost than less code, and `onbeforeupdate` related bugs can be especially difficult to troubleshoot if you rely on object identity for its conditional checks.
|
||||
|
||||
Again, **the `onbeforeupdate` hook should only be used as a last resort.**
|
||||
Again, **the `onbeforeupdate` hook should only be used as a last resort.**
|
||||
|
|
|
|||
|
|
@ -33,4 +33,3 @@ This method is internally called by [`m.mount()`](mount.md) and [`m.route()`](ro
|
|||
The `m.render` module is similar in scope to view libraries like Knockout, React and Vue. It is less than 500 lines of code (3kb min+gzip) and implements a virtual DOM diffing engine with a modern search space reduction algorithm and DOM recycling, which translate to top-of-class performance, both in terms of initial page load and re-rendering. It has no dependencies on other parts of Mithril and can be used as a standalone library.
|
||||
|
||||
Despite being incredibly small, the render module is fully functional and self-suficient. It supports everything you might expect: SVG, custom elements, and all valid attributes and events - without any weird case-sensitive edge cases or exceptions. Of course, it also fully supports [components](components.md) and [lifecycle methods](lifecycle-methods.md).
|
||||
|
||||
|
|
|
|||
|
|
@ -31,4 +31,4 @@ A splat argument means that if the last argument is an array, you can omit the s
|
|||
|
||||
In the example at the top, this means that `m("div", {id: "foo"}, ["a", "b", "c"])` can also be written as `m("div", {id: "foo"}, "a", "b", "c")`.
|
||||
|
||||
Splats are useful in some compile-to-js languages such as Coffeescript, and also allow helpful shorthands for some common use cases.
|
||||
Splats are useful in some compile-to-js languages such as Coffeescript, and also allow helpful shorthands for some common use cases.
|
||||
|
|
|
|||
|
|
@ -101,10 +101,10 @@ Here's the example snippet for the [Facebook Like button](https://developers.fac
|
|||
}(document, 'script', 'facebook-jssdk'));</script>
|
||||
|
||||
<!-- Your like button code -->
|
||||
<div class="fb-like"
|
||||
data-href="http://www.your-domain.com/your-page.html"
|
||||
data-layout="standard"
|
||||
data-action="like"
|
||||
<div class="fb-like"
|
||||
data-href="http://www.your-domain.com/your-page.html"
|
||||
data-layout="standard"
|
||||
data-action="like"
|
||||
data-show-faces="true">
|
||||
</div>
|
||||
```
|
||||
|
|
@ -149,4 +149,4 @@ Unicode characters for accented characters can be typed using a keyboard layout
|
|||
|
||||
All characters that are representable as HTML entities have unicode counterparts, including non-visible characters such as ` ` and `­`.
|
||||
|
||||
To avoid encoding issues, you should set the file encoding to UTF-8 on the Javascript file, as well as add the `<meta charset="utf-8">` meta tag in the host HTML file.
|
||||
To avoid encoding issues, you should set the file encoding to UTF-8 on the Javascript file, as well as add the `<meta charset="utf-8">` meta tag in the host HTML file.
|
||||
|
|
|
|||
|
|
@ -85,10 +85,10 @@ In `v1.x` there is no more `controller` property in components, use `oninit` ins
|
|||
m.mount(document.body, {
|
||||
controller : function() {
|
||||
var ctrl = this;
|
||||
|
||||
|
||||
ctrl.fooga = 1;
|
||||
},
|
||||
|
||||
|
||||
view : function(ctrl) {
|
||||
return m("p", ctrl.fooga);
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ m.mount(document.body, {
|
|||
oninit : function(vnode) {
|
||||
vnode.state.fooga = 1;
|
||||
},
|
||||
|
||||
|
||||
view : function(vnode) {
|
||||
return m("p", vnode.state.fooga);
|
||||
}
|
||||
|
|
@ -113,13 +113,13 @@ m.mount(document.body, {
|
|||
m.mount(document.body, {
|
||||
oninit : function(vnode) {
|
||||
var ctrl = this; // this is bound to vnode.state by default
|
||||
|
||||
|
||||
ctrl.fooga = 1;
|
||||
},
|
||||
|
||||
|
||||
view : function(vnode) {
|
||||
var ctrl = this; // this is bound to vnode.state by default
|
||||
|
||||
|
||||
return m("p", ctrl.fooga);
|
||||
}
|
||||
});
|
||||
|
|
@ -136,7 +136,7 @@ var component = {
|
|||
controller : function(options) {
|
||||
// options.fooga === 1
|
||||
},
|
||||
|
||||
|
||||
view : function(ctrl, options) {
|
||||
// options.fooga == 1
|
||||
}
|
||||
|
|
@ -152,7 +152,7 @@ var component = {
|
|||
oninit : function(vnode) {
|
||||
// vnode.attrs.fooga === 1
|
||||
},
|
||||
|
||||
|
||||
view : function(vnode) {
|
||||
// vnode.attrs.fooga == 1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,4 +99,4 @@ Only element tag names and components can be the first argument of the `m()` fun
|
|||
|
||||
The `mithril/render/node` module is used by Mithril to generate all vnodes. This ensures modern Javascript engines can optimize virtual dom diffing by always compiling vnodes to the same hidden class.
|
||||
|
||||
When creating libraries that emit vnodes, you should use this module instead of writing naked Javascript objects in order to ensure a high level of rendering performance.
|
||||
When creating libraries that emit vnodes, you should use this module instead of writing naked Javascript objects in order to ensure a high level of rendering performance.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue