Merge branch 'next' into components

Conflicts:
	mithril.js
This commit is contained in:
Leo Horie 2015-02-03 21:45:19 -05:00
commit 784973f168
3 changed files with 7 additions and 6 deletions

View file

@ -163,7 +163,7 @@ The other side of the coin is still supported: if a developer needs to signal an
var error = m.prop()
m.request({method: "GET", url: "/user/:id", data: {id: 1}})
.then(function(user) {
if (user.isAdmin) throw new Error("Sorry, you don't have permissions")
if (!user.isAdmin) throw new Error("Sorry, you don't have permissions")
})
.then(null, error) //handle the application error: bind to a getter-setter for diplaying it on the template
```
@ -249,4 +249,4 @@ where:
**void onerror(Error e)**
This method gets called every time an exception is thrown inside a promise callback. By default, it rethrows to the console if an error is a subclass of Error (but not an instance of Error itself). Otherwise it follows the Promises/A+ specifications.
This method gets called every time an exception is thrown inside a promise callback. By default, it rethrows to the console if an error is a subclass of Error (but not an instance of Error itself). Otherwise it follows the Promises/A+ specifications.

View file

@ -568,7 +568,7 @@ var m = (function app(window, undefined) {
for (var i = 0, root; root = roots[i]; i++) {
if (controllers[i]) {
var args = modules[i].controller && modules[i].controller.$$args ? [controllers[i]].concat(modules[i].controller.$$args) : [controllers[i]]
m.render(root, (modules[i].view || blank).apply(modules[i], args), forceRedraw)
m.render(root, modules[i].view ? modules[i].view(controllers[i], args) : blank(), forceRedraw)
}
}
//after rendering within a routed context, we need to scroll back to the top, and fetch the document title for history.pushState
@ -640,6 +640,7 @@ var m = (function app(window, undefined) {
}
//m.route(route, params)
else if (type.call(arguments[0]) === STRING) {
var oldRoute = currentRoute;
currentRoute = arguments[0];
var args = arguments[1] || {}
var queryIndex = currentRoute.indexOf("?")
@ -649,7 +650,7 @@ var m = (function app(window, undefined) {
var currentPath = queryIndex > -1 ? currentRoute.slice(0, queryIndex) : currentRoute
if (querystring) currentRoute = currentPath + (currentPath.indexOf("?") === -1 ? "?" : "&") + querystring;
var shouldReplaceHistoryEntry = (arguments.length === 3 ? arguments[2] : arguments[1]) === true || currentRoute === arguments[0];
var shouldReplaceHistoryEntry = (arguments.length === 3 ? arguments[2] : arguments[1]) === true || oldRoute === arguments[0];
if (window.history.pushState) {
computePostRedrawHook = function() {
@ -718,7 +719,7 @@ var m = (function app(window, undefined) {
var pair = value != null && (valueType === OBJECT) ?
buildQueryString(value, key) :
valueType === ARRAY ?
value.map(function(item) {return encodeURIComponent(key) + "=" + encodeURIComponent(item)}).join("&") :
value.map(function(item) {return encodeURIComponent(key + "[]") + "=" + encodeURIComponent(item)}).join("&") :
encodeURIComponent(key) + "=" + encodeURIComponent(value)
str.push(pair)
}

View file

@ -1799,7 +1799,7 @@ function testMithril(mock) {
test(function() {
var prop = m.request({method: "GET", url: "test", data: {foo: [1, 2]}})
mock.XMLHttpRequest.$instances.pop().onreadystatechange()
return prop().url === "test?foo=1&foo=2"
return prop().url === "test?foo%5B%5D=1&foo%5B%5D=2"
})
// m.request over jsonp