Merge branch 'next' into es6-promise
Conflicts: docs/mithril.deferred.md
This commit is contained in:
commit
fe17009bc9
6 changed files with 21 additions and 5 deletions
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
- gracefully degrade on IE exceptions when setting invalid values
|
- gracefully degrade on IE exceptions when setting invalid values
|
||||||
- fixes for Typescript definition file
|
- fixes for Typescript definition file
|
||||||
|
- fixed bug in keys algorithm when mixing keyed and unkeyed elements [#246](https://github.com/lhorie/mithril.js/issues/246)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ autocompleter.controller = function(data, getter) {
|
||||||
this.change = function(value) {
|
this.change = function(value) {
|
||||||
this.value(value);
|
this.value(value);
|
||||||
|
|
||||||
var list = value === "" ? [] : data.filter(function(item) {
|
var list = value === "" ? [] : data().filter(function(item) {
|
||||||
return this.getter(item).toLowerCase().indexOf(value.toLowerCase()) > -1;
|
return this.getter(item).toLowerCase().indexOf(value.toLowerCase()) > -1;
|
||||||
}, this);
|
}, this);
|
||||||
this.data(list);
|
this.data(list);
|
||||||
|
|
@ -130,7 +130,7 @@ var dashboard = {}
|
||||||
|
|
||||||
dashboard.controller = function() {
|
dashboard.controller = function() {
|
||||||
this.names = m.prop([{id: 1, name: "John"}, {id: 2, name: "Bob"}, {id: 2, name: "Mary"}]);
|
this.names = m.prop([{id: 1, name: "John"}, {id: 2, name: "Bob"}, {id: 2, name: "Mary"}]);
|
||||||
this.autocompleter = new autocompleter.controller(this.names(), function(item) {
|
this.autocompleter = new autocompleter.controller(this.names, function(item) {
|
||||||
return item.name;
|
return item.name;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ var greetAsync = function() {
|
||||||
|
|
||||||
### Differences from Promises/A+
|
### Differences from Promises/A+
|
||||||
|
|
||||||
For the most part, Mithril promises behave as you'd expect a [Promise/A+](http://promises-aplus.github.io/promises-spec/) promise to behave, but they have a few differences.
|
For the most part, Mithril promises behave as you'd expect a [Promise/A+](http://promises-aplus.github.io/promises-spec/) promise to behave, but have one difference: Mithril promises attempt to execute synchronously if possible.
|
||||||
|
|
||||||
#### Synchronous execution
|
#### Synchronous execution
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ Mithril = m = new function app(window, undefined) {
|
||||||
if (!existing[key]) existing[key] = {action: INSERTION, index: i}
|
if (!existing[key]) existing[key] = {action: INSERTION, index: i}
|
||||||
else existing[key] = {action: MOVE, index: i, from: existing[key].index, element: parentElement.childNodes[existing[key].index]}
|
else existing[key] = {action: MOVE, index: i, from: existing[key].index, element: parentElement.childNodes[existing[key].index]}
|
||||||
}
|
}
|
||||||
else unkeyed.push({index: i, element: parentElement.childNodes[i]})
|
else unkeyed.push({index: i, element: parentElement.childNodes[i] || window.document.createElement("div")})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var actions = Object.keys(existing).map(function(key) {return existing[key]})
|
var actions = Object.keys(existing).map(function(key) {return existing[key]})
|
||||||
|
|
|
||||||
|
|
@ -584,6 +584,17 @@ function testMithril(mock) {
|
||||||
var fifthAfter = root.childNodes[1]
|
var fifthAfter = root.childNodes[1]
|
||||||
return firstBefore === firstAfter && secondBefore === secondAfter && thirdBefore === thirdAfter && fourthBefore === fourthAfter && fifthBefore === fifthAfter
|
return firstBefore === firstAfter && secondBefore === secondAfter && thirdBefore === thirdAfter && fourthBefore === fourthAfter && fifthBefore === fifthAfter
|
||||||
})
|
})
|
||||||
|
test(function() {
|
||||||
|
//https://github.com/lhorie/mithril.js/issues/246
|
||||||
|
//insert at beginning with non-keyed in the middle
|
||||||
|
var root = mock.document.createElement("div")
|
||||||
|
m.render(root, [m("a", {key: 1})])
|
||||||
|
var firstBefore = root.childNodes[0]
|
||||||
|
m.render(root, [m("a", {key: 2}), m("br"), m("a", {key: 1})])
|
||||||
|
var firstAfter = root.childNodes[2]
|
||||||
|
console.log(root.childNodes)
|
||||||
|
return firstBefore == firstAfter && root.childNodes[0].key == 2 && root.childNodes.length == 3
|
||||||
|
})
|
||||||
test(function() {
|
test(function() {
|
||||||
//https://github.com/lhorie/mithril.js/issues/134
|
//https://github.com/lhorie/mithril.js/issues/134
|
||||||
var root = mock.document.createElement("div")
|
var root = mock.document.createElement("div")
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,11 @@ mock.window = new function() {
|
||||||
insertBefore: function(node, reference) {
|
insertBefore: function(node, reference) {
|
||||||
node.parentNode = this
|
node.parentNode = this
|
||||||
var referenceIndex = this.childNodes.indexOf(reference)
|
var referenceIndex = this.childNodes.indexOf(reference)
|
||||||
if (referenceIndex < 0) this.childNodes.push(node)
|
if (referenceIndex < 0) {
|
||||||
|
var index = this.childNodes.indexOf(node)
|
||||||
|
if (index > -1) this.childNodes.splice(index, 1)
|
||||||
|
this.childNodes.push(node)
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
var index = this.childNodes.indexOf(node)
|
var index = this.childNodes.indexOf(node)
|
||||||
if (index > -1) this.childNodes.splice(index, 1)
|
if (index > -1) this.childNodes.splice(index, 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue