Merge branch 'next' of https://github.com/isiahmeadows/mithril.js into prop-fix

This commit is contained in:
impinball 2015-12-10 19:14:32 -05:00
commit 2a47a8e77d
20 changed files with 941 additions and 111 deletions

View file

@ -44,8 +44,10 @@ void (function (global, factory) { // eslint-disable-line
}
function forOwn(obj, f) {
for (var prop in obj) if (hasOwn.call(obj, prop)) {
if (f(obj[prop], prop)) break
for (var prop in obj) {
if (hasOwn.call(obj, prop)) {
if (f(obj[prop], prop)) break
}
}
}
@ -729,15 +731,19 @@ void (function (global, factory) { // eslint-disable-line
var unloaders = []
function updateLists(views, controllers, view, controller) {
if (controller.onunload != null) {
unloaders.push({
controller: controller,
handler: controller.onunload
})
}
views.push(view)
controllers.push(controller)
var idx = controllers.push(controller) - 1
unloaders[idx] = {
controller: controller,
handler: function () {
controllers.splice(controllers.indexOf(controller), 1)
views.splice(views.indexOf(view), 1)
var unload = controller && controller.onunload
if (type.call(unload) === "[object Function]") {
controller.onunload()
}
}
}
}
var forcing = false
@ -960,8 +966,10 @@ void (function (global, factory) { // eslint-disable-line
}
})
for (var rule in cachedAttr) if (hasOwn.call(cachedAttr, rule)) {
if (!hasOwn.call(dataAttr, rule)) node.style[rule] = ""
for (var rule in cachedAttr) {
if (hasOwn.call(cachedAttr, rule)) {
if (!hasOwn.call(dataAttr, rule)) node.style[rule] = ""
}
}
} else if (namespace != null) {
// handle SVG
@ -1343,6 +1351,7 @@ void (function (global, factory) { // eslint-disable-line
}
forEach(unloaders, function (unloader) {
if (unloader.controller == null) return
unloader.handler.call(unloader.controller, ev)
unloader.controller.onunload = null
})
@ -2132,7 +2141,7 @@ void (function (global, factory) { // eslint-disable-line
if (!options.dataType || options.dataType.toLowerCase() !== "jsonp") {
serialize = options.serialize || JSON.stringify
deserialize = options.deserialize || JSON.parse
extract = function (xhr) {
extract = options.extract || function (xhr) {
if (xhr.responseText.length === 0 &&
deserialize === JSON.parse) {
return null
@ -2151,7 +2160,7 @@ void (function (global, factory) { // eslint-disable-line
options.onload = options.onerror = function (ev) {
ev = ev || event
var doSuccess = ev.type === "load"
var unwrap, response
var unwrap
if (doSuccess) {
unwrap = options.unwrapSuccess
@ -2160,7 +2169,7 @@ void (function (global, factory) { // eslint-disable-line
}
try {
response = (unwrap || identity)(
var response = (unwrap || identity)(
deserialize(extract(ev.target, options)), ev.target)
if (doSuccess) {
if (isArray(response) && options.type) {
@ -2170,15 +2179,15 @@ void (function (global, factory) { // eslint-disable-line
} else if (options.type) {
response = new options.type(response)
}
deferred.resolve(response)
} else {
deferred.reject(response)
}
} catch (e) {
response = e
doSuccess = false
deferred.reject(e)
} finally {
if (options.background !== true) m.endComputation()
}
deferred[doSuccess ? "resolve" : "reject"](response)
if (options.background !== true) m.endComputation()
}
ajax(options)