Migration docs: m.mount and m.route now require components where vdom nodes were once tolerated (#1217)

This commit is contained in:
Pierre-Yves Gérardy 2016-08-05 01:55:26 +02:00 committed by Pat Cavit
parent 56fbda9670
commit 7c0223ec09

View file

@ -7,6 +7,7 @@
- [Component `controller` function](#component-controller-function)
- [Component arguments](#component-arguments)
- [Passing components to `m()`](#passing-components-to-m)
- [Passing vnodes to `m.mount()` and `m.route()`](#passing-vnodes-to-mmount-and-mroute)
- [`m.route` mode](#mroute-mode)
- [`m.route` and anchor tags](#mroute-and-anchor-tags)
- [Reading/writing the current route](#readingwriting-the-current-route)
@ -178,6 +179,34 @@ m("div", component);
m("div", m(component));
```
## Passing vnodes to `m.mount()` and `m.route()`
In `v0.2.x`, `m.mount(element, component)` tolerated [vnodes](vnodes.md) as second arguments instead of [components](components.md) (even though it wasn't documented). Likewise, `m.route(element, defaultRoute, routes)` accepted vnodes as values in the `routes` object.
In `v1.x`, components are required instead in both cases.
### `v0.2.x`
```javascript
m.mount(element, m('i', 'hello'));
m.mount(element, m(Component, attrs));
m.route(element, '/', {
'/': m('b', 'bye')
})
```
### `v1.x`
```javascript
m.mount(element, {view: function () {return m('i', 'hello')}});
m.mount(element, {view: function () {return m(Component, attrs)}});
m.route(element, '/', {
'/': {view: function () {return m('b', 'bye')}}
})
```
## `m.route` mode
`m.route.mode` was replaced by `m.route.prefix(prefix)` where `prefix` can be `#`, `?`, `` (for "pathname" mode). The new API also supports hashbang (`#!`), which is the default, and it supports non-root pathnames and arbitrary mode variations such as querybang (`?!`)