From f4a248f0a571827fafadc69c2914216ab1039889 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Tue, 29 Apr 2014 22:20:19 -0400 Subject: [PATCH] fix abort so that it works without custom extract option --- archive/v0.1.11/mithril-tests.js | 8 ++++++-- archive/v0.1.11/mithril.js | 8 ++++++-- archive/v0.1.11/mithril.min.js | 2 +- archive/v0.1.11/mithril.min.map | 2 +- archive/v0.1.11/mithril.min.zip | Bin 40454 -> 40693 bytes mithril.js | 8 ++++++-- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/archive/v0.1.11/mithril-tests.js b/archive/v0.1.11/mithril-tests.js index 7c8182da..7cc8ad61 100644 --- a/archive/v0.1.11/mithril-tests.js +++ b/archive/v0.1.11/mithril-tests.js @@ -399,7 +399,9 @@ Mithril = m = new function app(window) { xhr.onload = typeof options.onload == "function" ? options.onload : function() {} xhr.onerror = typeof options.onerror == "function" ? options.onerror : function() {} xhr.onreadystatechange = function() { - if (xhr.readyState === 4 && xhr.status === 0) xhr.onerror({type: "error", target: xhr}) + if (xhr.readyState === 4 && xhr.status === 0) { + xhr.onerror({type: "error", target: xhr}) + } } if (typeof options.config == "function") options.config(xhr, options) xhr.send(options.data) @@ -439,7 +441,9 @@ Mithril = m = new function app(window) { var deferred = m.deferred() var serialize = xhrOptions.serialize || JSON.stringify var deserialize = xhrOptions.deserialize || JSON.parse - var extract = xhrOptions.extract || function(xhr, xhrOptions) {return xhr.responseText} + var extract = xhrOptions.extract || function(xhr, xhrOptions) { + return xhr.responseText.length === 0 && deserialize === JSON.parse ? null : xhr.responseText + } xhrOptions.url = parameterizeUrl(xhrOptions.url, xhrOptions.data) xhrOptions = bindData(xhrOptions, xhrOptions.data, serialize) xhrOptions.onload = xhrOptions.onerror = function(e) { diff --git a/archive/v0.1.11/mithril.js b/archive/v0.1.11/mithril.js index f7faa3fb..2cdd0c47 100644 --- a/archive/v0.1.11/mithril.js +++ b/archive/v0.1.11/mithril.js @@ -399,7 +399,9 @@ Mithril = m = new function app(window) { xhr.onload = typeof options.onload == "function" ? options.onload : function() {} xhr.onerror = typeof options.onerror == "function" ? options.onerror : function() {} xhr.onreadystatechange = function() { - if (xhr.readyState === 4 && xhr.status === 0) xhr.onerror({type: "error", target: xhr}) + if (xhr.readyState === 4 && xhr.status === 0) { + xhr.onerror({type: "error", target: xhr}) + } } if (typeof options.config == "function") options.config(xhr, options) xhr.send(options.data) @@ -439,7 +441,9 @@ Mithril = m = new function app(window) { var deferred = m.deferred() var serialize = xhrOptions.serialize || JSON.stringify var deserialize = xhrOptions.deserialize || JSON.parse - var extract = xhrOptions.extract || function(xhr, xhrOptions) {return xhr.responseText} + var extract = xhrOptions.extract || function(xhr, xhrOptions) { + return xhr.responseText.length === 0 && deserialize === JSON.parse ? null : xhr.responseText + } xhrOptions.url = parameterizeUrl(xhrOptions.url, xhrOptions.data) xhrOptions = bindData(xhrOptions, xhrOptions.data, serialize) xhrOptions.onload = xhrOptions.onerror = function(e) { diff --git a/archive/v0.1.11/mithril.min.js b/archive/v0.1.11/mithril.min.js index 7c792f34..bf20202f 100644 --- a/archive/v0.1.11/mithril.min.js +++ b/archive/v0.1.11/mithril.min.js @@ -4,5 +4,5 @@ http://github.com/lhorie/mithril.js (c) Leo Horie License: MIT */ -Mithril=m=new function(a){function b(){var a=arguments,b="[object Object]"==u.call(a[1]),c=b?a[1]:{},d="class"in c?"class":"className",e=t[a[0]];if(void 0===e){t[a[0]]=e={tag:"div",attrs:{}};for(var f,h=[];f=v.exec(a[0]);)if(""==f[1])e.tag=f[2];else if("#"==f[1])e.attrs.id=f[2];else if("."==f[1])h.push(f[2]);else if("["==f[3][0]){var i=w.exec(f[3]);e.attrs[i[1]]=i[3]||!0}h.length>0&&(e.attrs[d]=h.join(" "))}e=g(e),e.attrs=g(e.attrs),e.children=b?a[2]:a[1];for(var j in c)e.attrs[j]=j==d?(e.attrs[j]||"")+" "+c[j]:c[j];return e}function c(b,g,h,i,j,k,l){if(null===h||void 0===h)return void(i&&e(i.nodes));if("retain"!==h.subtree){var m=u.call(i),n=u.call(h);if(m!=n&&(null!==i&&void 0!==i&&e(i.nodes),i=new h.constructor,i.nodes=[]),"[object Array]"==n){for(var o=[],p=i.length===h.length,q=0,r=0,s=0;r-1?new h.constructor(h):h,i.nodes=[v];else if(i.valueOf()!==h.valueOf()||j===!0){if(h.$trusted){var x=i.nodes[0],o=[x];if(x){for(;x=x.nextSibling;)o.push(x);e(o),v=f(b,k,h)}else b.innerHTML=h}else v=i.nodes[0],"textarea"===g?b.value=h:b.insertBefore(v,b.childNodes[k]||null),v.nodeValue=h;i=new h.constructor(h),i.nodes=[v]}else i.nodes.intact=!0}return i}}function d(b,c,d,e,f){for(var g in d){var i=d[g],j=e[g];if(!(g in e)||j!==i||b===a.document.activeElement){if(e[g]=i,"config"===g)continue;if("function"==typeof i&&0==g.indexOf("on"))b[g]=h(i,b);else if("style"===g)for(var k in i)(void 0===j||j[k]!==i[k])&&(b.style[k]=i[k]);else void 0!==f?"href"===g?b.setAttributeNS("http://www.w3.org/1999/xlink","href",i):"className"===g?b.setAttribute("class",i):b.setAttribute(g,i):"value"===g&&"input"===c?b.value!==i&&(b.value=i):g in b?b[g]=i:b.setAttribute(g,i)}}return e}function e(a){for(var b=0;b16)b.redraw();else{var c=a.cancelAnimationFrame||a.clearTimeout,d=a.requestAnimationFrame||a.setTimeout;c(F),F=d(b.redraw,0)}}function j(a,c,d){L={};for(var e in c){if(e==d)return!void b.module(a,c[e]);var f=new RegExp("^"+e.replace(/:[^\/]+/g,"([^\\/]+)")+"$");if(f.test(d))return!void d.replace(f,function(){for(var d=e.match(/:[^\/]+/g),f=[].slice.call(arguments,1,-2),g=0;g0&&("GET"==a.method?a.url=a.url+(a.url.indexOf("?")<0?"?":"&")+o(b):a.data=c(b)),a}function q(a,b){var c=a.match(/:[a-z]\w+/gi);if(c&&b)for(var d=0;de?y.push(b)-1:e,g=b==a.document||b==a.document.documentElement?x:b;z[f]=c(g,null,d,z[f],!1,0)},b.trust=function(a){return a=new String(a),a.$trusted=!0,a};var A=[],B=[],C=[],D=0,E=0,F=0;b.module=function(a,c){b.startComputation();var d=A.indexOf(a);0>d&&(d=A.length),A[d]=a,B[d]=c,C[d]=new c.controller,b.endComputation()},b.redraw=function(){for(var a=0;a0&&(e.attrs[d]=h.join(" "))}e=g(e),e.attrs=g(e.attrs),e.children=b?a[2]:a[1];for(var j in c)e.attrs[j]=j==d?(e.attrs[j]||"")+" "+c[j]:c[j];return e}function c(b,g,h,i,j,k,l){if(null===h||void 0===h)return void(i&&e(i.nodes));if("retain"!==h.subtree){var m=u.call(i),n=u.call(h);if(m!=n&&(null!==i&&void 0!==i&&e(i.nodes),i=new h.constructor,i.nodes=[]),"[object Array]"==n){for(var o=[],p=i.length===h.length,q=0,r=0,s=0;r-1?new h.constructor(h):h,i.nodes=[v];else if(i.valueOf()!==h.valueOf()||j===!0){if(h.$trusted){var x=i.nodes[0],o=[x];if(x){for(;x=x.nextSibling;)o.push(x);e(o),v=f(b,k,h)}else b.innerHTML=h}else v=i.nodes[0],"textarea"===g?b.value=h:b.insertBefore(v,b.childNodes[k]||null),v.nodeValue=h;i=new h.constructor(h),i.nodes=[v]}else i.nodes.intact=!0}return i}}function d(b,c,d,e,f){for(var g in d){var i=d[g],j=e[g];if(!(g in e)||j!==i||b===a.document.activeElement){if(e[g]=i,"config"===g)continue;if("function"==typeof i&&0==g.indexOf("on"))b[g]=h(i,b);else if("style"===g)for(var k in i)(void 0===j||j[k]!==i[k])&&(b.style[k]=i[k]);else void 0!==f?"href"===g?b.setAttributeNS("http://www.w3.org/1999/xlink","href",i):"className"===g?b.setAttribute("class",i):b.setAttribute(g,i):"value"===g&&"input"===c?b.value!==i&&(b.value=i):g in b?b[g]=i:b.setAttribute(g,i)}}return e}function e(a){for(var b=0;b16)b.redraw();else{var c=a.cancelAnimationFrame||a.clearTimeout,d=a.requestAnimationFrame||a.setTimeout;c(F),F=d(b.redraw,0)}}function j(a,c,d){L={};for(var e in c){if(e==d)return!void b.module(a,c[e]);var f=new RegExp("^"+e.replace(/:[^\/]+/g,"([^\\/]+)")+"$");if(f.test(d))return!void d.replace(f,function(){for(var d=e.match(/:[^\/]+/g),f=[].slice.call(arguments,1,-2),g=0;g0&&("GET"==a.method?a.url=a.url+(a.url.indexOf("?")<0?"?":"&")+o(b):a.data=c(b)),a}function q(a,b){var c=a.match(/:[a-z]\w+/gi);if(c&&b)for(var d=0;de?y.push(b)-1:e,g=b==a.document||b==a.document.documentElement?x:b;z[f]=c(g,null,d,z[f],!1,0)},b.trust=function(a){return a=new String(a),a.$trusted=!0,a};var A=[],B=[],C=[],D=0,E=0,F=0;b.module=function(a,c){b.startComputation();var d=A.indexOf(a);0>d&&(d=A.length),A[d]=a,B[d]=c,C[d]=new c.controller,b.endComputation()},b.redraw=function(){for(var a=0;a+;G$ByNQg1H+1q;zkPk2DY}giF!q;#Rd6!#i=2w z6(xE(sd?!o8ER^&Kq;?ae?Pr~#G>L<`@GVe9IMTq3TaHdAY)Hu*vbx_n4jaohIA6C^NZ-Y)*CIW@a>*Tul<*#XDL=xFNXsN?GB=&9|dlj!J}Xy~gG=;)a4RO+ka z38LLVYP{V+>H|Sce{(m4@=T{Jx6RwaUo!E5+$dEyr=Q1}fq}<)^V%pC3$cofBE9^) zqSVBc%Hop5lGNmk#Ju#>$vIsT;UFonL@-D~0qAuF69qLj1&}yMZD}!B%s>+?lAo7a zRFq$&QC(75kZPr%1m-E}D3l}?rKgryfz;G$@^W!+-$i|ISJ!28POw;zkOaD-_b0ctOHUzkYr>Y|g-N zc=KzeISTB-RjxYzjzN?AobNF?CQr_HQD$~6aoIe@g`1htVDbX@LrnU~n^QdAvvTD7 zSvmog=53DlJI%ppHd#Gt^YQmrQ&h+t|Yj zqMDo-7@C|m3q`9~Y(6l#iVN%vxa%gn&(p6*aTw5X{9s?eh^0VZ