From fa4ad79d897665685318d9349f01c4734659b217 Mon Sep 17 00:00:00 2001 From: Gandalf-the-Bot Date: Thu, 20 Sep 2018 19:10:27 +0000 Subject: [PATCH] Bundled output for commit 1ecc30a0641d31c9b5f38227270c8f4b9b1cf54d [skip ci] --- README.md | 2 +- mithril.js | 30 +++++++++------- mithril.min.js | 96 +++++++++++++++++++++++++------------------------- 3 files changed, 66 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index eecaf727..5f5e96ac 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ mithril.js [![NPM Version](https://img.shields.io/npm/v/mithril.svg)](https://ww ## What is Mithril? -A modern client-side Javascript framework for building Single Page Applications. It's small (8.93 KB gzipped), fast and provides routing and XHR utilities out of the box. +A modern client-side Javascript framework for building Single Page Applications. It's small (8.90 KB gzipped), fast and provides routing and XHR utilities out of the box. Mithril is used by companies like Vimeo and Nike, and open source platforms like Lichess 👍. diff --git a/mithril.js b/mithril.js index 5e0c9c5e..8137a04b 100644 --- a/mithril.js +++ b/mithril.js @@ -1068,15 +1068,17 @@ var coreRenderer = function($window) { if (key2[0] === "o" && key2[1] === "n") return updateEvent(vnode, key2, value) if (key2.slice(0, 6) === "xlink:") vnode.dom.setAttributeNS("http://www.w3.org/1999/xlink", key2.slice(6), value) else if (key2 === "style") updateStyle(vnode.dom, old, value) - else if (key2 in vnode.dom && !isAttribute(key2) && ns === undefined && !isCustomElement(vnode.tag, vnode.attrs)) { + else if (hasPropertyKey(vnode, key2, ns)) { if (key2 === "value") { - var normalized = "" + value // eslint-disable-line no-implicit-coercion + // Only do the coercion if we're actually going to check the value. + /* eslint-disable no-implicit-coercion */ //setting input[value] to same value by typing on focused element moves cursor to end in Chrome - if ((vnode.tag === "input" || vnode.tag === "textarea") && vnode.dom.value === normalized && vnode.dom === $doc.activeElement) return + if ((vnode.tag === "input" || vnode.tag === "textarea") && vnode.dom.value === "" + value && vnode.dom === $doc.activeElement) return //setting select[value] to same value while having select open blinks select dropdown in Chrome - if (vnode.tag === "select" && old !== null && vnode.dom.value === normalized) return + if (vnode.tag === "select" && old !== null && vnode.dom.value === "" + value) return //setting option[value] to same value while having select open blinks select dropdown in Chrome - if (vnode.tag === "option" && old !== null && vnode.dom.value === normalized) return + if (vnode.tag === "option" && old !== null && vnode.dom.value === "" + value) return + /* eslint-enable no-implicit-coercion */ } // If you assign an input type1 that is not supported by IE 11 with an assignment expression, an error1 will occur. if (vnode.tag === "input" && key2 === "type") vnode.dom.setAttribute(key2, value) @@ -1094,12 +1096,10 @@ var coreRenderer = function($window) { if (key2[0] === "o" && key2[1] === "n" && !isLifecycleMethod(key2)) updateEvent(vnode, key2, undefined) else if (key2 === "style") updateStyle(vnode.dom, old, null) else if ( - key2 in vnode.dom && !isAttribute(key2) + hasPropertyKey(vnode, key2, ns) && key2 !== "className" && !(vnode.tag === "option" && key2 === "value") && !(vnode.tag === "input" && key2 === "type") - && ns === undefined - && !isCustomElement(vnode.tag, vnode.attrs || {}) ) { vnode.dom[key2] = null } else { @@ -1142,11 +1142,15 @@ var coreRenderer = function($window) { function isLifecycleMethod(attr) { return attr === "oninit" || attr === "oncreate" || attr === "onupdate" || attr === "onremove" || attr === "onbeforeremove" || attr === "onbeforeupdate" } - function isAttribute(attr) { - return attr === "href" || attr === "list" || attr === "form" || attr === "width" || attr === "height"// || attr === "type" - } - function isCustomElement(tag, attrs2){ - return attrs2.is || tag.indexOf("-") > -1 + function hasPropertyKey(vnode, key2, ns) { + // Filter out namespaced keys + return ns === undefined && ( + // If it's a custom element, just keep it. + vnode.tag.indexOf("-") > -1 || vnode.attrs != null && vnode.attrs.is || + // If it's a normal element, let's try to avoid a few browser bugs. + key !== "href" && key2 !== "list" && key2 !== "form" && key2 !== "width" && key2 !== "height"// && key2 !== "type" + // Defer the property check until *after* we check everything. + ) && key2 in vnode.dom } //style function updateStyle(element, old, style) { diff --git a/mithril.min.js b/mithril.min.js index 8e0ffe9a..49e68138 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -1,48 +1,48 @@ -(function(){function z(a,d,e,g,q,h){return{tag:a,key:d,attrs:e,children:g,text:q,dom:h,domSize:void 0,state:void 0,events:void 0,instance:void 0}}function Q(a){for(var d in a)if(H.call(a,d))return!1;return!0}function w(a){if(null==a||"string"!==typeof a&&"function"!==typeof a&&"function"!==typeof a.view)throw Error("The selector must be either a string or a component.");var d=arguments[1],e=2;if(null==d)d={};else if("object"!==typeof d||null!=d.tag||Array.isArray(d))d={},e=1;if(arguments.length=== -e+1){var g=arguments[e];Array.isArray(g)||(g=[g])}else for(g=[];ec.indexOf("?")?"?":"&";c+=e+d}return c}function k(c){try{return""!==c?JSON.parse(c):null}catch(x){throw Error("Invalid JSON: "+ -c);}}function n(c){return c.responseText}function m(c,a){if("function"===typeof c)if(Array.isArray(a))for(var d=0;dl.status||304===l.status||Z.test(c.url))d(m(c.type,a));else{var g=Error(l.responseText);g.code=l.status;g.response=a;e(g)}}catch(aa){e(aa)}};g&&null!=c.data?l.send(c.data):l.send()});return!0===c.background?x:E(x)},jsonp:function(c,n){var k=e();c=g(c,n);var x=new d(function(d,e){var g=c.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+l++,n=a.document.createElement("script"); -a[g]=function(e){n.parentNode.removeChild(n);d(m(c.type,e));delete a[g]};n.onerror=function(){n.parentNode.removeChild(n);e(Error("JSONP request failed"));delete a[g]};null==c.data&&(c.data={});c.url=q(c.url,c.data);c.data[c.callbackKey||"callback"]=g;n.src=h(c.url,c.data);a.document.documentElement.appendChild(n)});return!0===c.background?x:k(x)},setCompletionCallback:function(c){C=c}}}(window,p),V=function(a){function d(t,b){if(t.state!==b)throw Error("`vnode.state` must not be modified");}function e(t){var b= -t.state;try{return this.apply(b,arguments)}finally{d(t,b)}}function g(t,b,f,c,a,d,e){for(;f'+ -b.children+"",a=a.firstChild):a.innerHTML=b.children;b.dom=a.firstChild;b.domSize=a.childNodes.length;for(b=D.createDocumentFragment();f=a.firstChild;)b.appendChild(f);C(t,b,c)}function k(t,b,f,c,a,d){if(b!==f&&(null!=b||null!=f))if(null==b||0===b.length)g(t,f,0,f.length,c,a,d);else if(null==f||0===f.length)x(b,0,b.length);else{for(var e=0,k=0,v=null,h=null;k=k&&v>=e;)if(A=b[h],y=f[v],null==A)h--;else if(null==y)v--;else if(A.key===y.key)A!==y&&n(t,A,y,c,a,d),null!=y.dom&&(a=y.dom),h--,v--;else break;for(;h>=k&&v>=e;)if(r=b[k],u=f[e],null==r)k++;else if(null==u)e++;else if(r.key===u.key)k++,e++,r!==u&&n(t,r,u,c,l(b,k,a),d);else break;for(;h>=k&&v>=e;){if(null==r)k++;else if(null==u)e++;else if(null==A)h--;else if(null==y)v--;else if(e===v)break;else{if(r.key!== -y.key||A.key!==u.key)break;B=l(b,k,a);C(t,m(A),B);A!==u&&n(t,A,u,c,B,d);++e<=--v&&C(t,m(r),a);r!==y&&n(t,r,y,c,a,d);null!=y.dom&&(a=y.dom);k++;h--}A=b[h];y=f[v];r=b[k];u=f[e]}for(;h>=k&&v>=e;){if(null==A)h--;else if(null==y)v--;else if(A.key===y.key)A!==y&&n(t,A,y,c,a,d),null!=y.dom&&(a=y.dom),h--,v--;else break;A=b[h];y=f[v]}if(e>v)x(b,k,h+1);else if(k>h)g(t,f,e,v+1,c,a,d);else{u=a;A=v-e+1;r=Array(A);var G=2147483647,z=0;for(B=0;B=e;B--){if(null==p){p=b;A=k;y=h+1;for(var w= -{};A=e;B--)u=f[B],-1===r[B-e]?q(t,u,c,d,a):b[k]===B-e?k--:C(t,m(u),a),null!=u.dom&&(a=f[B].dom)}else for(B=v;B>=e;B--)u=f[B],-1===r[B-e]&&q(t,u,c,d,a),null!=u.dom&&(a=f[B].dom)}}else{v=b.lengthv&&x(b,e,b.length);f.length>v&&g(t,f,e,f.length,c,a,d)}}}function n(a,b,f,d,g,l){var t=b.tag;if(t=== -f.tag){f.state=b.state;f.events=b.events;var v;var x;null!=f.attrs&&"function"===typeof f.attrs.onbeforeupdate&&(v=e.call(f.attrs.onbeforeupdate,f,b));"string"!==typeof f.tag&&"function"===typeof f.state.onbeforeupdate&&(x=e.call(f.state.onbeforeupdate,f,b));void 0===v&&void 0===x||v||x?v=!1:(f.dom=b.dom,f.domSize=b.domSize,f.instance=b.instance,v=!0);if(!v)if("string"===typeof t)switch(null!=f.attrs&&L(f.attrs,f,d),t){case "#":b.children.toString()!==f.children.toString()&&(b.dom.nodeValue=f.children); -f.dom=b.dom;break;case "<":b.children!==f.children?(m(b),h(a,f,l,g)):(f.dom=b.dom,f.domSize=b.domSize);break;case "[":k(a,b.children,f.children,d,g,l);b=0;d=f.children;f.dom=null;if(null!=d){for(var p=0;pc.indexOf("?")?"?":"&";c+=e+d}return c}function h(c){try{return""!==c?JSON.parse(c):null}catch(y){throw Error("Invalid JSON: "+ +c);}}function n(c){return c.responseText}function m(c,a){if("function"===typeof c)if(Array.isArray(a))for(var d=0;dl.status||304===l.status||Z.test(c.url))d(m(c.type,a));else{var g=Error(l.responseText);g.code=l.status;g.response=a;e(g)}}catch(aa){e(aa)}};g&&null!=c.data?l.send(c.data):l.send()});return!0===c.background?y:F(y)},jsonp:function(c,n){var h=e();c=g(c,n);var y=new d(function(d,e){var g=c.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+l++,n=a.document.createElement("script"); +a[g]=function(e){n.parentNode.removeChild(n);d(m(c.type,e));delete a[g]};n.onerror=function(){n.parentNode.removeChild(n);e(Error("JSONP request failed"));delete a[g]};null==c.data&&(c.data={});c.url=q(c.url,c.data);c.data[c.callbackKey||"callback"]=g;n.src=k(c.url,c.data);a.document.documentElement.appendChild(n)});return!0===c.background?y:h(y)},setCompletionCallback:function(c){C=c}}}(window,p),V=function(a){function d(t,b){if(t.state!==b)throw Error("`vnode.state` must not be modified");}function e(t){var b= +t.state;try{return this.apply(b,arguments)}finally{d(t,b)}}function g(t,b,f,c,a,d,e){for(;f'+ +b.children+"",a=a.firstChild):a.innerHTML=b.children;b.dom=a.firstChild;b.domSize=a.childNodes.length;for(b=E.createDocumentFragment();f=a.firstChild;)b.appendChild(f);C(t,b,c)}function h(t,b,f,c,a,d){if(b!==f&&(null!=b||null!=f))if(null==b||0===b.length)g(t,f,0,f.length,c,a,d);else if(null==f||0===f.length)y(b,0,b.length);else{for(var e=0,u=0,h=null,k=null;u=u&&h>=e;)if(A=b[k],z=f[h],null==A)k--;else if(null==z)h--;else if(A.key===z.key)A!==z&&n(t,A,z,c,a,d),null!=z.dom&&(a=z.dom),k--,h--;else break;for(;k>=u&&h>=e;)if(r=b[u],v=f[e],null==r)u++;else if(null==v)e++;else if(r.key===v.key)u++,e++,r!==v&&n(t,r,v,c,l(b,u,a),d);else break;for(;k>=u&&h>=e;){if(null==r)u++;else if(null==v)e++;else if(null==A)k--;else if(null==z)h--;else if(e===h)break;else{if(r.key!== +z.key||A.key!==v.key)break;B=l(b,u,a);C(t,m(A),B);A!==v&&n(t,A,v,c,B,d);++e<=--h&&C(t,m(r),a);r!==z&&n(t,r,z,c,a,d);null!=z.dom&&(a=z.dom);u++;k--}A=b[k];z=f[h];r=b[u];v=f[e]}for(;k>=u&&h>=e;){if(null==A)k--;else if(null==z)h--;else if(A.key===z.key)A!==z&&n(t,A,z,c,a,d),null!=z.dom&&(a=z.dom),k--,h--;else break;A=b[k];z=f[h]}if(e>h)y(b,u,k+1);else if(u>k)g(t,f,e,h+1,c,a,d);else{v=a;A=h-e+1;r=Array(A);var x=2147483647,w=0;for(B=0;B=e;B--){if(null==p){p=b;A=u;z=k+1;for(var D= +{};A=e;B--)v=f[B],-1===r[B-e]?q(t,v,c,d,a):b[u]===B-e?u--:C(t,m(v),a),null!=v.dom&&(a=f[B].dom)}else for(B=h;B>=e;B--)v=f[B],-1===r[B-e]&&q(t,v,c,d,a),null!=v.dom&&(a=f[B].dom)}}else{h=b.lengthh&&y(b,e,b.length);f.length>h&&g(t,f,e,f.length,c,a,d)}}}function n(a,b,f,d,g,l){var t=b.tag;if(t=== +f.tag){f.state=b.state;f.events=b.events;var u;var y;null!=f.attrs&&"function"===typeof f.attrs.onbeforeupdate&&(u=e.call(f.attrs.onbeforeupdate,f,b));"string"!==typeof f.tag&&"function"===typeof f.state.onbeforeupdate&&(y=e.call(f.state.onbeforeupdate,f,b));void 0===u&&void 0===y||u||y?u=!1:(f.dom=b.dom,f.domSize=b.domSize,f.instance=b.instance,u=!0);if(!u)if("string"===typeof t)switch(null!=f.attrs&&L(f.attrs,f,d),t){case "#":b.children.toString()!==f.children.toString()&&(b.dom.nodeValue=f.children); +f.dom=b.dom;break;case "<":b.children!==f.children?(m(b),k(a,f,l,g)):(f.dom=b.dom,f.domSize=b.domSize);break;case "[":h(a,b.children,f.children,d,g,l);b=0;d=f.children;f.dom=null;if(null!=d){for(var p=0;p