diff --git a/docs/v1.x-migration.md b/docs/v1.x-migration.md index eaa17615..3bbe31a7 100644 --- a/docs/v1.x-migration.md +++ b/docs/v1.x-migration.md @@ -7,6 +7,7 @@ - [Cancelling redraw from event handlers](#cancelling-redraw-from-event-handlers) - [Component `controller` function](#component-controller-function) - [Component arguments](#component-arguments) +- [`view()` parameters](#view-parameters) - [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`](#mroutemode) @@ -14,6 +15,7 @@ - [Reading/writing the current route](#readingwriting-the-current-route) - [Accessing route params](#accessing-route-params) - [`m.request`](#mrequest) +- [`xlink` namespace required](#xlink-namespace-required) ## `m.component` removed @@ -181,6 +183,37 @@ var component = { m("div", m(component, { fooga : 1 })); ``` +## `view()` parameters + +In `v0.2.x` view functions are passed a reference to the `controller` instance and (optionally) any options passed to the component. In `v1.x` they are passed **only** the `vnode`, exactly like the `controller` function. + +### `v0.2.x` + +```javascript +m.mount(document.body, { + controller : function() {}, + + view : function(ctrl, options) { + // ... + } +}); +``` + +### `v1.x` + +```javascript +m.mount(document.body, { + oninit : function(vnode) { + // ... + }, + + view : function(vnode) { + // Use vnode.state instead of ctrl + // Use vnode.attrs instead of options + } +}); +``` + ## Passing components to `m()` In `v0.2.x` you could pass components as the second argument of `m()` w/o any wrapping required. To help with consistency in `v1.x` they must always be wrapped with a `m()` invocation. @@ -377,3 +410,25 @@ m.prop.merge([ ``` Additionally, if the `extract` option is passed to `m.request` the return value of the provided function will be passed to the [m.prop stream](prop.md) directly, and any `deserialize` callback is ignored. + +## `xlink` namespace required + +In `v0.2.x` when generating SVGs using `m()` the `xlink` namespace would automatically be added on certain attributes. For consistency in `v1.x` if you want to namespace an attribute you must do it yourself. + +### `v0.2.x` + +```js +m("svg", + // the `href` attribute is namespaced automatically + m("image[href='image.gif']") +) +``` + +### `v1.x` + +```js +m("svg", + // User-specified namespace on the `href` attribute + m("image[xlink:href='image.gif']") +) +```