Merge pull request #840 from futurist/master

FIX: document error on master branch according to #839
This commit is contained in:
Leo Horie 2015-11-12 14:04:07 -05:00
commit 6fecdf32c3

View file

@ -217,9 +217,9 @@ Components can be placed anywhere a regular element can. If you have components
```javascript ```javascript
var App = { var App = {
ctrl: function() { controller: function() {
return {data: [1, 2, 3]} return {data: [1, 2, 3]}
} },
view: function(ctrl) { view: function(ctrl) {
return m(".app", [ return m(".app", [
//pressing the button reverses the list //pressing the button reverses the list
@ -280,7 +280,7 @@ var TemperatureConverter = {
return value - 273.15 return value - 273.15
}, },
kelvinToFahrenheit: function(value) { kelvinToFahrenheit: function(value) {
return (value 9 / 5 * (v - 273.15)) + 32 return ( 9 / 5 * (value - 273.15)) + 32
} }
} }
}, },
@ -305,12 +305,12 @@ var ctrl = new TemperatureConverter.controller();
assert(ctrl.kelvinToCelsius(273.15) == 0) assert(ctrl.kelvinToCelsius(273.15) == 0)
//test the template //test the template
var tpl = TemperatureConverter.view(null, {value: 273.15}) var tpl = TemperatureConverter.view(ctrl, {value: 273.15})
assert(tpl.children[1] == 0) assert(tpl.children[1] == 0)
//test with real DOM //test with real DOM
var testRoot = document.createElement("div") var testRoot = document.createElement("div")
m.render(testRoot, TemperatureConverter.view(null, {value: 273.15})) m.render(testRoot, TemperatureConverter.view(ctrl, {value: 273.15}))
assert(testRoot.innerHTML.indexOf("celsius:0") > -1) assert(testRoot.innerHTML.indexOf("celsius:0") > -1)
``` ```
@ -397,14 +397,14 @@ Often, you will want to do some work before the component is unloaded (i.e. clea
var MyComponent = { var MyComponent = {
controller: function() { controller: function() {
return { return {
onunload = function() { onunload : function() {
console.log("unloading my component"); console.log("unloading my component");
} }
} }
}, },
view: function() { view: function() {
return m("div", "test") return m("div", "test")
}; }
}; };
m.mount(document.body, MyComponent); m.mount(document.body, MyComponent);