Merge branch 'next' into components
This commit is contained in:
commit
c1ea98fd09
4 changed files with 13 additions and 13 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
- fix dom element ownership bug when mixing keyed elements and third party plugin elements [#463](https://github.com/lhorie/mithril.js/issues/463)
|
- fix dom element ownership bug when mixing keyed elements and third party plugin elements [#463](https://github.com/lhorie/mithril.js/issues/463)
|
||||||
- fix edge case in flatten algorithm [#448](https://github.com/lhorie/mithril.js/issues/448)
|
- fix edge case in flatten algorithm [#448](https://github.com/lhorie/mithril.js/issues/448)
|
||||||
- prevent unnecessary DOM move operation when mixing keyed and unkeyed elements [#398](https://github.com/lhorie/mithril.js/issues/398)
|
- prevent unnecessary DOM move operation when mixing keyed and unkeyed elements [#398](https://github.com/lhorie/mithril.js/issues/398)
|
||||||
|
- revert [#382](https://github.com/lhorie/mithril.js/issues/382) due to diff regression [#512](https://github.com/lhorie/mithril.js/issues/512)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,25 +130,23 @@ In the case of our todo application, the view-model needs a few things: it needs
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
//define the view-model
|
//define the view-model
|
||||||
todo.vm = (function() {
|
todo.vm = {
|
||||||
var vm = {}
|
init: function() {
|
||||||
vm.init = function() {
|
|
||||||
//a running list of todos
|
//a running list of todos
|
||||||
vm.list = new todo.TodoList();
|
todo.vm.list = new todo.TodoList();
|
||||||
|
|
||||||
//a slot to store the name of a new todo before it is created
|
//a slot to store the name of a new todo before it is created
|
||||||
vm.description = m.prop("");
|
todo.vm.description = m.prop('');
|
||||||
|
|
||||||
//adds a todo to the list, and clears the description field for user convenience
|
//adds a todo to the list, and clears the description field for user convenience
|
||||||
vm.add = function(description) {
|
todo.vm.add = function(description) {
|
||||||
if (description()) {
|
if (description()) {
|
||||||
vm.list.push(new todo.Todo({description: description()}));
|
todo.vm.list.push(new todo.Todo({description: description()}));
|
||||||
vm.description("");
|
todo.vm.description("");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return vm
|
};
|
||||||
}())
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The code above defines a view-model object called `vm`. It is simply a javascript object that has a `init` function. This function initializes the `vm` object with three members: `list`, which is simply an array, `description`, which is an `m.prop` getter-setter function with an empty string as the initial value, and `add`, which is a method that adds a new Todo instance to `list` if an input description getter-setter is not an empty string.
|
The code above defines a view-model object called `vm`. It is simply a javascript object that has a `init` function. This function initializes the `vm` object with three members: `list`, which is simply an array, `description`, which is an `m.prop` getter-setter function with an empty string as the initial value, and `add`, which is a method that adds a new Todo instance to `list` if an input description getter-setter is not an empty string.
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ var m = (function app(window, undefined) {
|
||||||
|
|
||||||
for (var attrName in attrs) {
|
for (var attrName in attrs) {
|
||||||
if (attrName === classAttrName) {
|
if (attrName === classAttrName) {
|
||||||
if (attrs[attrName] !== "") cell.attrs[attrName] = (cell.attrs[attrName] || "") + " " + attrs[attrName];
|
var className = cell.attrs[attrName]
|
||||||
|
cell.attrs[attrName] = (className && attrs[attrName] ? className + " " : className || "") + attrs[attrName];
|
||||||
}
|
}
|
||||||
else cell.attrs[attrName] = attrs[attrName]
|
else cell.attrs[attrName] = attrs[attrName]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,10 @@ function testMithril(mock) {
|
||||||
test(function() {return m(".foo", {"class": "bar"}).attrs["class"] == "foo bar"})
|
test(function() {return m(".foo", {"class": "bar"}).attrs["class"] == "foo bar"})
|
||||||
test(function() {return m(".foo", {className: "bar"}).attrs.className == "foo bar"})
|
test(function() {return m(".foo", {className: "bar"}).attrs.className == "foo bar"})
|
||||||
test(function() {return m(".foo", {className: ""}).attrs.className == "foo"})
|
test(function() {return m(".foo", {className: ""}).attrs.className == "foo"})
|
||||||
test(function() {return m("div", {className: ""}).attrs.className === undefined}) //https://github.com/lhorie/mithril.js/issues/382
|
test(function() {return m("div", {className: ""}).attrs.className === ""}) //https://github.com/lhorie/mithril.js/issues/382 and 512
|
||||||
test(function() {return m("div", {class: ""}).attrs.className === undefined})
|
test(function() {return m("div", {class: ""}).attrs.className === undefined})
|
||||||
test(function() {return m("div", {className: ""}).attrs.class === undefined})
|
test(function() {return m("div", {className: ""}).attrs.class === undefined})
|
||||||
test(function() {return m("div", {class: ""}).attrs.class === undefined})
|
test(function() {return m("div", {class: ""}).attrs.class === ""})
|
||||||
test(function() {return m("div", [1, 2, 3], 4).children.length === 2})
|
test(function() {return m("div", [1, 2, 3], 4).children.length === 2})
|
||||||
test(function() {return m("div", [1, 2, 3], 4).children[0].length === 3})
|
test(function() {return m("div", [1, 2, 3], 4).children[0].length === 3})
|
||||||
test(function() {return m("div", [1, 2, 3], 4).children[1] === 4})
|
test(function() {return m("div", [1, 2, 3], 4).children[1] === 4})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue