From 7c0223ec09f5635bcfd900b42aab7d1b4835cd51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Yves=20G=C3=A9rardy?= Date: Fri, 5 Aug 2016 01:55:26 +0200 Subject: [PATCH] Migration docs: m.mount and m.route now require components where vdom nodes were once tolerated (#1217) --- docs/v1.x-migration.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/v1.x-migration.md b/docs/v1.x-migration.md index b9f5e8d1..11a6b2c9 100644 --- a/docs/v1.x-migration.md +++ b/docs/v1.x-migration.md @@ -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 (`?!`)