Merge remote-tracking branch 'origin/rewrite' into rewrite
# Conflicts: # mithril.min.js
This commit is contained in:
commit
9f6a1086e4
10 changed files with 166 additions and 21 deletions
12
mithril.min.js
vendored
12
mithril.min.js
vendored
|
|
@ -23,12 +23,12 @@ c.tag;if(g===e.tag){e.state=c.state;e.events=c.events;var y;var z;null!=e.attrs&
|
|||
e.tag&&(null==e.attrs&&(e.attrs={}),null!=e.text&&(e.attrs.value=e.text,e.text=void 0));r=c.attrs;w=e.attrs;g=a;if(null!=w)for(p in w)u(e,p,r&&r[p],w[p],g);if(null!=r)for(p in r)null!=w&&p in w||("className"===p&&(p="class"),"o"!==p[0]||"n"!==p[1]||M(p)?"key"!==p&&e.dom.removeAttribute(p):F(e,p,void 0));null!=e.attrs&&null!=e.attrs.contenteditable?C(e):null!=c.text&&null!=e.text&&""!==e.text?c.text.toString()!==e.text.toString()&&(c.dom.firstChild.nodeValue=e.text):(null!=c.text&&(c.children=[n("#",
|
||||
void 0,void 0,c.text,void 0,c.dom.firstChild)]),null!=e.text&&(e.children=[n("#",void 0,void 0,e.text,void 0,void 0)]),f(m,c.children,e.children,h,null,a))}else e.instance=n.normalize(e.tag.view.call(e.state,e)),A(e.tag,e,h,r),null!=e.instance?(null==c.instance?q(a,l(e.instance,h,w),m):k(a,c.instance,e.instance,h,m,r,w),e.dom=e.instance.dom,e.domSize=e.instance.domSize):null!=c.instance?(d(c.instance,null),e.dom=void 0,e.domSize=0):(e.dom=c.dom,e.domSize=c.domSize)}else d(c,null),q(a,l(e,h,w),m)}
|
||||
function v(a){var g=a.domSize;if(null!=g||null==a.dom){var e=B.createDocumentFragment();if(0<g){for(a=a.dom;--g;)e.appendChild(a.nextSibling);e.insertBefore(a,e.firstChild)}return e}return a.dom}function p(a,c,e){for(;c<a.length;c++)if(null!=a[c]&&null!=a[c].dom)return a[c].dom;return e}function q(a,c,e){e&&e.parentNode?a.insertBefore(c,e):a.appendChild(c)}function C(a){var c=a.children;if(null!=c&&1===c.length&&"<"===c[0].tag)c=c[0].children,a.dom.innerHTML!==c&&(a.dom.innerHTML=c);else if(null!=
|
||||
c||null!=a.text)throw Error("Child node of a contenteditable must be trusted");}function r(a,c,e,b){for(;c<e;c++){var g=a[c];null!=g&&(g.skip?g.skip=!1:d(g,b))}}function m(a){var c=!1;return function(){c||(c=!0,a())}}function d(a,c){function g(){if(++d===b&&(w(a),a.dom)){var g=a.domSize||1;if(1<g)for(var e=a.dom;--g;){var f=e.nextSibling,h=f.parentNode;null!=h&&h.removeChild(f)}g=a.dom;e=g.parentNode;null!=e&&e.removeChild(g);if(g=null!=c&&null==a.domSize)g=a.attrs,g=!(null!=g&&(g.oncreate||g.onupdate||
|
||||
g.onbeforeremove||g.onremove));g&&"string"===typeof a.tag&&(c.pool?c.pool.push(a):c.pool=[a])}}var b=1,d=0;a.attrs&&a.attrs.onbeforeremove&&(b++,a.attrs.onbeforeremove.call(a.state,a,m(g)));"string"!==typeof a.tag&&a.tag.onbeforeremove&&(b++,a.tag.onbeforeremove.call(a.state,a,m(g)));g()}function w(a){a.attrs&&a.attrs.onremove&&a.attrs.onremove.call(a.state,a);"string"!==typeof a.tag&&a.tag.onremove&&a.tag.onremove.call(a.state,a);if(null!=a.instance)w(a.instance);else if(a=a.children,a instanceof
|
||||
Array)for(var c=0;c<a.length;c++){var g=a[c];null!=g&&w(g)}}function u(a,c,e,b,d){var g=a.dom;if("key"!==c&&(e!==b||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===B.activeElement||"object"===typeof b)&&"undefined"!==typeof b&&!M(c)){var f=c.indexOf(":");if(-1<f&&"xlink"===c.substr(0,f))g.setAttributeNS("http://www.w3.org/1999/xlink",c.slice(f+1),b);else if("o"===c[0]&&"n"===c[1]&&"function"===typeof b)F(a,c,b);else if("style"===c)if(a=e,a===b&&(g.style.cssText="",a=null),
|
||||
null==b)g.style.cssText="";else if("string"===typeof b)g.style.cssText=b;else{"string"===typeof a&&(g.style.cssText="");for(var h in b)g.style[h]=b[h];if(null!=a&&"string"!==typeof a)for(h in a)h in b||(g.style[h]="")}else c in g&&"href"!==c&&"list"!==c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===d?"input"===a.tag&&"value"===c&&a.dom.value===b&&a.dom===B.activeElement||"select"===a.tag&&"value"===c&&a.dom.value===b&&a.dom===B.activeElement||"option"===a.tag&&"value"===c&&a.dom.value===b||(g[c]=
|
||||
b):"boolean"===typeof b?b?g.setAttribute(c,""):g.removeAttribute(c):g.setAttribute("className"===c?"class":c,b)}}function M(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function F(a,c,b){var e=a.dom,g=function(a){var c=b.call(e,a);"function"===typeof K&&K.call(e,a);return c};if(c in e)e[c]="function"===typeof b?g:null;else{var d=c.slice(2);void 0===a.events&&(a.events={});null!=a.events[c]&&e.removeEventListener(d,a.events[c],!1);
|
||||
"function"===typeof b&&(a.events[c]=g,e.addEventListener(d,a.events[c],!1))}}function t(a,c,b){"function"===typeof a.oninit&&a.oninit.call(c.state,c);"function"===typeof a.oncreate&&b.push(a.oncreate.bind(c.state,c))}function A(a,c,b,d){d?t(a,c,b):"function"===typeof a.onupdate&&b.push(a.onupdate.bind(c.state,c))}function E(a,c){Object.keys(c).forEach(function(b){a[b]=c[b]})}var B=a.document,H=B.createDocumentFragment(),K;return{render:function(a,c){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");
|
||||
a.text||null!=c&&0!==c.length)throw Error("Child node of a contenteditable must be trusted");}function r(a,c,e,b){for(;c<e;c++){var g=a[c];null!=g&&(g.skip?g.skip=!1:d(g,b))}}function m(a){var c=!1;return function(){c||(c=!0,a())}}function d(a,c){function g(){if(++d===b&&(w(a),a.dom)){var g=a.domSize||1;if(1<g)for(var e=a.dom;--g;){var f=e.nextSibling,h=f.parentNode;null!=h&&h.removeChild(f)}g=a.dom;e=g.parentNode;null!=e&&e.removeChild(g);if(g=null!=c&&null==a.domSize)g=a.attrs,g=!(null!=g&&(g.oncreate||
|
||||
g.onupdate||g.onbeforeremove||g.onremove));g&&"string"===typeof a.tag&&(c.pool?c.pool.push(a):c.pool=[a])}}var b=1,d=0;a.attrs&&a.attrs.onbeforeremove&&(b++,a.attrs.onbeforeremove.call(a.state,a,m(g)));"string"!==typeof a.tag&&a.tag.onbeforeremove&&(b++,a.tag.onbeforeremove.call(a.state,a,m(g)));g()}function w(a){a.attrs&&a.attrs.onremove&&a.attrs.onremove.call(a.state,a);"string"!==typeof a.tag&&a.tag.onremove&&a.tag.onremove.call(a.state,a);if(null!=a.instance)w(a.instance);else if(a=a.children,
|
||||
a instanceof Array)for(var c=0;c<a.length;c++){var g=a[c];null!=g&&w(g)}}function u(a,c,e,b,d){var g=a.dom;if("key"!==c&&(e!==b||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===B.activeElement||"object"===typeof b)&&"undefined"!==typeof b&&!M(c)){var f=c.indexOf(":");if(-1<f&&"xlink"===c.substr(0,f))g.setAttributeNS("http://www.w3.org/1999/xlink",c.slice(f+1),b);else if("o"===c[0]&&"n"===c[1]&&"function"===typeof b)F(a,c,b);else if("style"===c)if(a=e,a===b&&(g.style.cssText=
|
||||
"",a=null),null==b)g.style.cssText="";else if("string"===typeof b)g.style.cssText=b;else{"string"===typeof a&&(g.style.cssText="");for(var h in b)g.style[h]=b[h];if(null!=a&&"string"!==typeof a)for(h in a)h in b||(g.style[h]="")}else c in g&&"href"!==c&&"list"!==c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===d?"input"===a.tag&&"value"===c&&a.dom.value===b&&a.dom===B.activeElement||"select"===a.tag&&"value"===c&&a.dom.value===b&&a.dom===B.activeElement||"option"===a.tag&&"value"===c&&a.dom.value===
|
||||
b||(g[c]=b):"boolean"===typeof b?b?g.setAttribute(c,""):g.removeAttribute(c):g.setAttribute("className"===c?"class":c,b)}}function M(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function F(a,c,b){var e=a.dom,g=function(a){var c=b.call(e,a);"function"===typeof K&&K.call(e,a);return c};if(c in e)e[c]="function"===typeof b?g:null;else{var d=c.slice(2);void 0===a.events&&(a.events={});null!=a.events[c]&&e.removeEventListener(d,a.events[c],
|
||||
!1);"function"===typeof b&&(a.events[c]=g,e.addEventListener(d,a.events[c],!1))}}function t(a,c,b){"function"===typeof a.oninit&&a.oninit.call(c.state,c);"function"===typeof a.oncreate&&b.push(a.oncreate.bind(c.state,c))}function A(a,c,b,d){d?t(a,c,b):"function"===typeof a.onupdate&&b.push(a.onupdate.bind(c.state,c))}function E(a,c){Object.keys(c).forEach(function(b){a[b]=c[b]})}var B=a.document,H=B.createDocumentFragment(),K;return{render:function(a,c){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");
|
||||
var b=[],d=B.activeElement;null==a.vnodes&&(a.textContent="");c instanceof Array||(c=[c]);f(a,a.vnodes,n.normalizeChildren(c),b,null,void 0);a.vnodes=c;for(var g=0;g<b.length;g++)b[g]();B.activeElement!==d&&d.focus()},setEventCallback:function(a){return K=a}}},E=function(a){function h(a){a=b.indexOf(a);-1<a&&b.splice(a,2)}function l(){for(var a=1;a<b.length;a+=2)b[a]()}a=O(a);a.setEventCallback(function(a){!1!==a.redraw&&l()});var b=[];return{subscribe:function(a,k){h(a);b.push(a,k)},unsubscribe:h,
|
||||
redraw:l,render:a.render}}(window);J.setCompletionCallback(E.redraw);A.mount=function(a){function h(a){var b=0,f=null,h="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var k=Date.now();0===b||16<=k-b?(b=k,a()):null===f&&(f=h(function(){f=null;a();b=Date.now()},16-(k-b)))}}return function(l,b){if(null===b)a.render(l,[]),a.unsubscribe(l);else{if(null==b.view)throw Error("m.mount(element, component) expects a component, not a vnode");var f=h(function(){a.render(l,
|
||||
n(b))});a.subscribe(l,f);f()}}}(E);var L=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var h={},l={},b=0;b<a.length;b++){var f=a[b].split("="),k=decodeURIComponent(f[0]),f=2===f.length?decodeURIComponent(f[1]):"";"true"===f?f=!0:"false"===f&&(f=!1);var n=k.split(/\]\[?|\[/),p=h;-1<k.indexOf("[")&&n.pop();for(var q=0;q<n.length;q++){var k=n[q],t=n[q+1],t=""==t||!isNaN(parseInt(t,10)),r=q===n.length-1;""===k&&(k=n.slice(0,q).join(),null==l[k]&&(l[k]=0),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue