Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mithril

Package Overview
Dependencies
Maintainers
1
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mithril - npm Package Compare versions

Comparing version 0.1.25 to 0.1.26

10

mithril.js

@@ -346,3 +346,3 @@ var m = (function app(window, undefined) {

//- when using CSS selectors (e.g. `m("[style='']")`), style is used as a string, but it's an object in js
else if (attrName in node && !(attrName == "list" || attrName == "style" || attrName == "form")) {
else if (attrName in node && !(attrName == "list" || attrName == "style" || attrName == "form" || attrName == "type")) {
//#348 don't set the value if not needed otherwise cursor placement breaks in Chrome

@@ -557,6 +557,7 @@ if (node[attrName] != dataAttr) node[attrName] = dataAttr

var modes = {pathname: "", hash: "#", search: "?"};
var redirect = function() {}, routeParams = {}, currentRoute;
var redirect = function() {}, routeParams, currentRoute;
m.route = function() {
//m.route()
if (arguments.length === 0) return currentRoute;
//m.route(el, defaultRoute, routes)
else if (arguments.length === 3 && type.call(arguments[1]) == STRING) {

@@ -611,3 +612,6 @@ var root = arguments[0], defaultRoute = arguments[1], router = arguments[2];

};
m.route.param = function(key) {return routeParams[key]};
m.route.param = function(key) {
if (!routeParams) throw new Error("You must call m.route(element, defaultRoute, routes) before calling m.route.param()")
return routeParams[key]
};
m.route.mode = "search";

@@ -614,0 +618,0 @@ function normalizeRoute(route) {return route.slice(modes[m.route.mode].length)}

/*
Mithril v0.1.25
Mithril v0.1.26
http://github.com/lhorie/mithril.js

@@ -7,3 +7,3 @@ (c) Leo Horie

*/
var m=function a(b,c){function d(a){C=a.document,D=a.location,F=a.cancelAnimationFrame||a.clearTimeout,E=a.requestAnimationFrame||a.setTimeout}function e(){var a,b=[].slice.call(arguments),c=!(null==b[1]||K.call(b[1])!=G||"tag"in b[1]||"subtree"in b[1]),d=c?b[1]:{},e="class"in d?"class":"className",f={tag:"div",attrs:{}},g=[];if(K.call(b[0])!=I)throw new Error("selector in m(selector, attrs, children) should be a string");for(;a=L.exec(b[0]);)if(""==a[1]&&a[2])f.tag=a[2];else if("#"==a[1])f.attrs.id=a[2];else if("."==a[1])g.push(a[2]);else if("["==a[3][0]){var h=M.exec(a[3]);f.attrs[h[1]]=h[3]||(h[2]?"":!0)}g.length>0&&(f.attrs[e]=g.join(" "));var i=c?b[2]:b[1];f.children=K.call(i)==H?i:b.slice(c?2:1);for(var j in d)f.attrs[j]=j==e?(f.attrs[j]||"")+" "+d[j]:d[j];return f}function f(a,b,d,e,i,k,l,m,n,o,p){if(null==i&&(i=""),"retain"===i.subtree)return k;var q=K.call(k),r=K.call(i);if(null==k||q!=r){if(null!=k)if(d&&d.nodes){var s=m-e,t=s+(r==H?i:k.nodes).length;h(d.nodes.slice(s,t),d.slice(s,t))}else k.nodes&&h(k.nodes,k);k=new i.constructor,k.tag&&(k={}),k.nodes=[]}if(r==H){for(var u=0;u<i.length;u++)K.call(i[u])==H&&(i=i.concat.apply([],i),u--);for(var v=[],w=k.length===i.length,x=0,y=1,z=2,A=3,B={},D=[],E=!1,u=0;u<k.length;u++)k[u]&&k[u].attrs&&null!=k[u].attrs.key&&(E=!0,B[k[u].attrs.key]={action:y,index:u});if(E){for(var u=0;u<i.length;u++)if(i[u]&&i[u].attrs)if(null!=i[u].attrs.key){var F=i[u].attrs.key;B[F]=B[F]?{action:A,index:u,from:B[F].index,element:a.childNodes[B[F].index]||C.createElement("div")}:{action:z,index:u}}else D.push({index:u,element:a.childNodes[u]||C.createElement("div")});for(var L,M=Object.keys(B).map(function(a){return B[a]}),O=M.sort(function(a,b){return a.action-b.action||a.index-b.index}),P=k.slice(),u=0;L=O[u];u++){if(L.action==y&&(h(k[L.index].nodes,k[L.index]),P.splice(L.index,1)),L.action==z){var Q=C.createElement("div");Q.key=i[L.index].attrs.key,a.insertBefore(Q,a.childNodes[L.index]||null),P.splice(L.index,0,{attrs:{key:i[L.index].attrs.key},nodes:[Q]})}L.action==A&&(a.childNodes[L.index]!==L.element&&null!==L.element&&a.insertBefore(L.element,a.childNodes[L.index]||null),P[L.index]=k[L.from])}for(var u=0;u<D.length;u++){var L=D[u];a.insertBefore(L.element,a.childNodes[L.index]||null),P[L.index]=k[L.index]}k=P,k.nodes=[];for(var R,u=0;R=a.childNodes[u];u++)k.nodes.push(R)}for(var u=0,S=0;u<i.length;u++){var T=f(a,b,k,m,i[u],k[S],l,m+x||x,n,o,p);T!==c&&(T.nodes.intact||(w=!1),x+=T.$trusted?(T.match(/<[^\/]|\>\s*[^<]/g)||[]).length:K.call(T)==H?T.length:1,k[S++]=T)}if(!w){for(var u=0;u<i.length;u++)null!=k[u]&&v.push.apply(v,k[u].nodes);for(var U,u=0;U=k.nodes[u];u++)null!=U.parentNode&&v.indexOf(U)<0&&h([U],[k[u]]);i.length<k.length&&(k.length=i.length),k.nodes=v}}else if(null!=i&&r==G){i.attrs||(i.attrs={}),k.attrs||(k.attrs={});{var V=Object.keys(i.attrs);V.length>("key"in i.attrs?1:0)}if((i.tag!=k.tag||V.join()!=Object.keys(k.attrs).join()||i.attrs.id!=k.attrs.id)&&(k.nodes.length&&h(k.nodes),k.configContext&&typeof k.configContext.onunload==J&&k.configContext.onunload()),K.call(i.tag)!=I)return;var U,W=0===k.nodes.length;if(i.attrs.xmlns?o=i.attrs.xmlns:"svg"===i.tag?o="http://www.w3.org/2000/svg":"math"===i.tag&&(o="http://www.w3.org/1998/Math/MathML"),W?(U=i.attrs.is?o===c?C.createElement(i.tag,i.attrs.is):C.createElementNS(o,i.tag,i.attrs.is):o===c?C.createElement(i.tag):C.createElementNS(o,i.tag),k={tag:i.tag,attrs:V.length?g(U,i.tag,i.attrs,{},o):{},children:null!=i.children&&i.children.length>0?f(U,i.tag,c,c,i.children,k.children,!0,0,i.attrs.contenteditable?U:n,o,p):i.children,nodes:[U]},k.children&&!k.children.nodes&&(k.children.nodes=[]),"select"==i.tag&&i.attrs.value&&g(U,i.tag,{value:i.attrs.value},{},o),a.insertBefore(U,a.childNodes[m]||null)):(U=k.nodes[0],V.length&&g(U,i.tag,i.attrs,k.attrs,o),k.children=f(U,i.tag,c,c,i.children,k.children,!1,0,i.attrs.contenteditable?U:n,o,p),k.nodes.intact=!0,l===!0&&null!=U&&a.insertBefore(U,a.childNodes[m]||null)),typeof i.attrs.config==J){var X=k.configContext=k.configContext||{},Y=function(a,b){return function(){return a.attrs.config.apply(a,b)}};p.push(Y(i,[U,!W,X,k]))}}else if(typeof r!=J){var v;0===k.nodes.length?(i.$trusted?v=j(a,m,i):(v=[C.createTextNode(i)],a.nodeName.match(N)||a.insertBefore(v[0],a.childNodes[m]||null)),k="string number boolean".indexOf(typeof i)>-1?new i.constructor(i):i,k.nodes=v):k.valueOf()!==i.valueOf()||l===!0?(v=k.nodes,n&&n===C.activeElement||(i.$trusted?(h(v,k),v=j(a,m,i)):"textarea"===b?a.value=i:n?n.innerHTML=i:((1==v[0].nodeType||v.length>1)&&(h(k.nodes,k),v=[C.createTextNode(i)]),a.insertBefore(v[0],a.childNodes[m]||null),v[0].nodeValue=i)),k=new i.constructor(i),k.nodes=v):k.nodes.intact=!0}return k}function g(a,b,c,d,e){for(var f in c){var g=c[f],h=d[f];if(f in d&&h===g)"value"===f&&"input"===b&&a.value!=g&&(a.value=g);else{d[f]=g;try{if("config"===f)continue;if(typeof g==J&&0==f.indexOf("on"))a[f]=k(g,a);else if("style"===f&&null!=g&&K.call(g)==G){for(var i in g)(null==h||h[i]!==g[i])&&(a.style[i]=g[i]);for(var i in h)i in g||(a.style[i]="")}else null!=e?"href"===f?a.setAttributeNS("http://www.w3.org/1999/xlink","href",g):"className"===f?a.setAttribute("class",g):a.setAttribute(f,g):f in a&&"list"!=f&&"style"!=f&&"form"!=f?a[f]!=g&&(a[f]=g):a.setAttribute(f,g)}catch(j){if(j.message.indexOf("Invalid argument")<0)throw j}}}return d}function h(a,b){for(var c=a.length-1;c>-1;c--)if(a[c]&&a[c].parentNode){try{a[c].parentNode.removeChild(a[c])}catch(d){}b=[].concat(b),b[c]&&i(b[c])}0!=a.length&&(a.length=0)}function i(a){if(a.configContext&&typeof a.configContext.onunload==J&&a.configContext.onunload(),a.children)if(K.call(a.children)==H)for(var b=0;b<a.children.length;b++)i(a.children[b]);else a.children.tag&&i(a.children)}function j(a,b,c){var d=a.childNodes[b];if(d){var e=1!=d.nodeType,f=C.createElement("span");e?(a.insertBefore(f,d||null),f.insertAdjacentHTML("beforebegin",c),a.removeChild(f)):d.insertAdjacentHTML("beforebegin",c)}else a.insertAdjacentHTML("beforeend",c);for(var g=[];a.childNodes[b]!==d;)g.push(a.childNodes[b]),b++;return g}function k(a,b){return function(c){c=c||event,e.redraw.strategy("diff"),e.startComputation();try{return a.call(b,c)}finally{e.endComputation()}}}function l(a){var b=Q.indexOf(a);return 0>b?Q.push(a)-1:b}function m(a){var b=function(){return arguments.length&&(a=arguments[0]),a};return b.toJSON=function(){return a},b}function n(){for(var a=e.redraw.strategy(),b=0;b<T.length;b++)V[b]&&"none"!=a&&e.render(T[b],U[b].view(V[b]),"all"==a);Y&&(Y(),Y=null),W=null,X=new Date,e.redraw.strategy("diff")}function o(a){return a.slice(ab[e.route.mode].length)}function p(a,b,c){cb={};var d=c.indexOf("?");-1!==d&&(cb=t(c.substr(d+1,c.length)),c=c.substr(0,d));for(var f in b){if(f==c)return e.module(a,b[f]),!0;var g=new RegExp("^"+f.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$");if(g.test(c))return c.replace(g,function(){for(var c=f.match(/:[^\/]+/g)||[],d=[].slice.call(arguments,1,-2),g=0;g<c.length;g++)cb[c[g].replace(/:|\./g,"")]=decodeURIComponent(d[g]);e.module(a,b[f])}),!0}}function q(a){if(a=a||event,!a.ctrlKey&&!a.metaKey&&2!=a.which){a.preventDefault?a.preventDefault():a.returnValue=!1;var b=a.currentTarget||this,c="pathname"==e.route.mode&&b.search?t(b.search.slice(1)):{};e.route(b[e.route.mode].slice(ab[e.route.mode].length),c)}}function r(){"hash"!=e.route.mode&&D.hash?D.hash=D.hash:b.scrollTo(0,0)}function s(a,b){var c=[];for(var d in a){var e=b?b+"["+d+"]":d,f=a[d];c.push(null!=f&&K.call(f)==G?s(f,e):encodeURIComponent(e)+"="+encodeURIComponent(f))}return c.join("&")}function t(a){for(var b=a.split("&"),c={},d=0;d<b.length;d++){var e=b[d].split("=");c[u(e[0])]=e[1]?u(e[1]):""}return c}function u(a){return decodeURIComponent(a.replace(/\+/g," "))}function v(a){var b=l(a);h(a.childNodes,R[b]),R[b]=c}function w(a){var b=e.prop();return a.then(b),b.then=function(b,c){return w(a.then(b,c))},b}function x(a,b){function c(a){l=a||j,n.map(function(a){l==i&&a.resolve(m)||a.reject(m)})}function d(a,b,c,d){if((null!=m&&K.call(m)==G||typeof m==J)&&typeof a==J)try{var f=0;a.call(m,function(a){f++||(m=a,b())},function(a){f++||(m=a,c())})}catch(g){e.deferred.onerror(g),m=g,c()}else d()}function f(){var j;try{j=m&&m.then}catch(n){return e.deferred.onerror(n),m=n,l=h,f()}d(j,function(){l=g,f()},function(){l=h,f()},function(){try{l==g&&typeof a==J?m=a(m):l==h&&"function"==typeof b&&(m=b(m),l=g)}catch(f){return e.deferred.onerror(f),m=f,c()}m==k?(m=TypeError(),c()):d(j,function(){c(i)},c,function(){c(l==g&&i)})})}var g=1,h=2,i=3,j=4,k=this,l=0,m=0,n=[];k.promise={},k.resolve=function(a){return l||(m=a,l=g,f()),this},k.reject=function(a){return l||(m=a,l=h,f()),this},k.promise.then=function(a,b){var c=new x(a,b);return l==i?c.resolve(m):l==j?c.reject(m):n.push(c),c.promise}}function y(a){return a}function z(a){if(!a.dataType||"jsonp"!==a.dataType.toLowerCase()){var d=new b.XMLHttpRequest;if(d.open(a.method,a.url,!0,a.user,a.password),d.onreadystatechange=function(){4===d.readyState&&(d.status>=200&&d.status<300?a.onload({type:"load",target:d}):a.onerror({type:"error",target:d}))},a.serialize==JSON.stringify&&a.data&&"GET"!=a.method&&d.setRequestHeader("Content-Type","application/json; charset=utf-8"),a.deserialize==JSON.parse&&d.setRequestHeader("Accept","application/json, text/*"),typeof a.config==J){var e=a.config(d,a);null!=e&&(d=e)}var f="GET"!=a.method&&a.data?a.data:"";if(f&&K.call(f)!=I&&f.constructor!=b.FormData)throw"Request data should be either be a string or FormData. Check the `serialize` option in `m.request`";return d.send(f),d}var g="mithril_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),h=C.createElement("script");b[g]=function(d){C.body.removeChild(h),a.onload({type:"load",target:{responseText:d}}),b[g]=c},h.onerror=function(){return C.body.removeChild(h),a.onerror({type:"error",target:{status:500,responseText:JSON.stringify({error:"Error making jsonp request"})}}),b[g]=c,!1},h.onload=function(){return!1},h.src=a.url+(a.url.indexOf("?")>0?"&":"?")+(a.callbackKey?a.callbackKey:"callback")+"="+g+"&"+s(a.data||{}),C.body.appendChild(h)}function A(a,b,c){if("GET"==a.method&&"jsonp"!=a.dataType){var d=a.url.indexOf("?")<0?"?":"&",e=s(b);a.url=a.url+(e?d+e:"")}else a.data=c(b);return a}function B(a,b){var c=a.match(/:[a-z]\w+/gi);if(c&&b)for(var d=0;d<c.length;d++){var e=c[d].slice(1);a=a.replace(c[d],b[e]),delete b[e]}return a}var C,D,E,F,G="[object Object]",H="[object Array]",I="[object String]",J="function",K={}.toString,L=/(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g,M=/\[(.+?)(?:=("|'|)(.*?)\2)?\]/,N=/^(AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR)$/;d(b);var O,P={appendChild:function(a){O===c&&(O=C.createElement("html")),C.documentElement&&C.documentElement!==a?C.replaceChild(a,C.documentElement):C.appendChild(a),this.childNodes=C.childNodes},insertBefore:function(a){this.appendChild(a)},childNodes:[]},Q=[],R={};e.render=function(a,b,d){var e=[];if(!a)throw new Error("Please ensure the DOM element exists before rendering a template into it.");var g=l(a),i=a==C,j=i||a==C.documentElement?P:a;i&&"html"!=b.tag&&(b={tag:"html",attrs:{},children:b}),R[g]===c&&h(j.childNodes),d===!0&&v(a),R[g]=f(j,null,c,c,b,R[g],!1,0,null,c,e);for(var k=0;k<e.length;k++)e[k]()},e.trust=function(a){return a=new String(a),a.$trusted=!0,a},e.prop=function(a){return(null!=a&&K.call(a)==G||typeof a==J)&&typeof a.then==J?w(a):m(a)};var S,T=[],U=[],V=[],W=null,X=0,Y=null,Z=16;e.module=function(a,b){var c=T.indexOf(a);0>c&&(c=T.length);var d=!1;if(V[c]&&typeof V[c].onunload==J){var f={preventDefault:function(){d=!0}};V[c].onunload(f)}if(!d){e.redraw.strategy("all"),e.startComputation(),T[c]=a;var g=S=b,h=new b.controller;return g==S&&(V[c]=h,U[c]=b),e.endComputation(),V[c]}},e.redraw=function(a){W&&a!==!0?(new Date-X>Z||E==b.requestAnimationFrame)&&(W>0&&F(W),W=E(n,Z)):(n(),W=E(function(){W=null},Z))},e.redraw.strategy=e.prop();var $=0;e.startComputation=function(){$++},e.endComputation=function(){$=Math.max($-1,0),0==$&&e.redraw()},e.withAttr=function(a,b){return function(c){c=c||event;var d=c.currentTarget||this;b(a in d?d[a]:d.getAttribute(a))}};var _,ab={pathname:"",hash:"#",search:"?"},bb=function(){},cb={};return e.route=function(){if(0===arguments.length)return _;if(3===arguments.length&&K.call(arguments[1])==I){var a=arguments[0],c=arguments[1],d=arguments[2];bb=function(b){var f=_=o(b);p(a,d,f)||e.route(c,!0)};var f="hash"==e.route.mode?"onhashchange":"onpopstate";b[f]=function(){_!=o(D[e.route.mode])&&bb(D[e.route.mode])},Y=r,b[f]()}else if(arguments[0].addEventListener){{var g=arguments[0];arguments[1],arguments[2]}g.href=("pathname"!==e.route.mode?D.pathname:"")+ab[e.route.mode]+this.attrs.href,g.removeEventListener("click",q),g.addEventListener("click",q)}else if(K.call(arguments[0])==I){_=arguments[0];var h=arguments[1]||{},i=_.indexOf("?"),j=i>-1?t(_.slice(i+1)):{};for(var k in h)j[k]=h[k];var l=s(j),m=i>-1?_.slice(0,i):_;l&&(_=m+(-1===m.indexOf("?")?"?":"&")+l);var n=(3==arguments.length?arguments[2]:arguments[1])===!0;b.history.pushState?(Y=function(){b.history[n?"replaceState":"pushState"](null,C.title,ab[e.route.mode]+_),r()},bb(ab[e.route.mode]+_)):D[e.route.mode]=_}},e.route.param=function(a){return cb[a]},e.route.mode="search",e.deferred=function(){var a=new x;return a.promise=w(a.promise),a},e.deferred.onerror=function(a){if("[object Error]"==K.call(a)&&!a.constructor.toString().match(/ Error/))throw a},e.sync=function(a){function b(a,b){return function(e){return g[a]=e,b||(c="reject"),0==--f&&(d.promise(g),d[c](g)),e}}var c="resolve",d=e.deferred(),f=a.length,g=new Array(f);if(a.length>0)for(var h=0;h<a.length;h++)a[h].then(b(h,!0),b(h,!1));else d.resolve([]);return d.promise},e.request=function(a){a.background!==!0&&e.startComputation();var b=e.deferred(),c=a.dataType&&"jsonp"===a.dataType.toLowerCase(),d=a.serialize=c?y:a.serialize||JSON.stringify,f=a.deserialize=c?y:a.deserialize||JSON.parse,g=a.extract||function(a){return 0===a.responseText.length&&f===JSON.parse?null:a.responseText};return a.url=B(a.url,a.data),a=A(a,a.data,d),a.onload=a.onerror=function(c){try{c=c||event;var d=("load"==c.type?a.unwrapSuccess:a.unwrapError)||y,h=d(f(g(c.target,a)));if("load"==c.type)if(K.call(h)==H&&a.type)for(var i=0;i<h.length;i++)h[i]=new a.type(h[i]);else a.type&&(h=new a.type(h));b["load"==c.type?"resolve":"reject"](h)}catch(c){e.deferred.onerror(c),b.reject(c)}a.background!==!0&&e.endComputation()},z(a),b.promise(a.initialValue),b.promise},e.deps=function(a){return d(b=a||b),b},e.deps.factory=a,e}("undefined"!=typeof window?window:{});"undefined"!=typeof module&&null!==module&&module.exports?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m});
var m=function a(b,c){function d(a){C=a.document,D=a.location,F=a.cancelAnimationFrame||a.clearTimeout,E=a.requestAnimationFrame||a.setTimeout}function e(){var a,b=[].slice.call(arguments),c=!(null==b[1]||K.call(b[1])!=G||"tag"in b[1]||"subtree"in b[1]),d=c?b[1]:{},e="class"in d?"class":"className",f={tag:"div",attrs:{}},g=[];if(K.call(b[0])!=I)throw new Error("selector in m(selector, attrs, children) should be a string");for(;a=L.exec(b[0]);)if(""==a[1]&&a[2])f.tag=a[2];else if("#"==a[1])f.attrs.id=a[2];else if("."==a[1])g.push(a[2]);else if("["==a[3][0]){var h=M.exec(a[3]);f.attrs[h[1]]=h[3]||(h[2]?"":!0)}g.length>0&&(f.attrs[e]=g.join(" "));var i=c?b[2]:b[1];f.children=K.call(i)==H?i:b.slice(c?2:1);for(var j in d)f.attrs[j]=j==e?(f.attrs[j]||"")+" "+d[j]:d[j];return f}function f(a,b,d,e,i,k,l,m,n,o,p){if(null==i&&(i=""),"retain"===i.subtree)return k;var q=K.call(k),r=K.call(i);if(null==k||q!=r){if(null!=k)if(d&&d.nodes){var s=m-e,t=s+(r==H?i:k.nodes).length;h(d.nodes.slice(s,t),d.slice(s,t))}else k.nodes&&h(k.nodes,k);k=new i.constructor,k.tag&&(k={}),k.nodes=[]}if(r==H){for(var u=0;u<i.length;u++)K.call(i[u])==H&&(i=i.concat.apply([],i),u--);for(var v=[],w=k.length===i.length,x=0,y=1,z=2,A=3,B={},D=[],E=!1,u=0;u<k.length;u++)k[u]&&k[u].attrs&&null!=k[u].attrs.key&&(E=!0,B[k[u].attrs.key]={action:y,index:u});if(E){for(var u=0;u<i.length;u++)if(i[u]&&i[u].attrs)if(null!=i[u].attrs.key){var F=i[u].attrs.key;B[F]=B[F]?{action:A,index:u,from:B[F].index,element:a.childNodes[B[F].index]||C.createElement("div")}:{action:z,index:u}}else D.push({index:u,element:a.childNodes[u]||C.createElement("div")});for(var L,M=Object.keys(B).map(function(a){return B[a]}),O=M.sort(function(a,b){return a.action-b.action||a.index-b.index}),P=k.slice(),u=0;L=O[u];u++){if(L.action==y&&(h(k[L.index].nodes,k[L.index]),P.splice(L.index,1)),L.action==z){var Q=C.createElement("div");Q.key=i[L.index].attrs.key,a.insertBefore(Q,a.childNodes[L.index]||null),P.splice(L.index,0,{attrs:{key:i[L.index].attrs.key},nodes:[Q]})}L.action==A&&(a.childNodes[L.index]!==L.element&&null!==L.element&&a.insertBefore(L.element,a.childNodes[L.index]||null),P[L.index]=k[L.from])}for(var u=0;u<D.length;u++){var L=D[u];a.insertBefore(L.element,a.childNodes[L.index]||null),P[L.index]=k[L.index]}k=P,k.nodes=[];for(var R,u=0;R=a.childNodes[u];u++)k.nodes.push(R)}for(var u=0,S=0;u<i.length;u++){var T=f(a,b,k,m,i[u],k[S],l,m+x||x,n,o,p);T!==c&&(T.nodes.intact||(w=!1),x+=T.$trusted?(T.match(/<[^\/]|\>\s*[^<]/g)||[]).length:K.call(T)==H?T.length:1,k[S++]=T)}if(!w){for(var u=0;u<i.length;u++)null!=k[u]&&v.push.apply(v,k[u].nodes);for(var U,u=0;U=k.nodes[u];u++)null!=U.parentNode&&v.indexOf(U)<0&&h([U],[k[u]]);i.length<k.length&&(k.length=i.length),k.nodes=v}}else if(null!=i&&r==G){i.attrs||(i.attrs={}),k.attrs||(k.attrs={});{var V=Object.keys(i.attrs);V.length>("key"in i.attrs?1:0)}if((i.tag!=k.tag||V.join()!=Object.keys(k.attrs).join()||i.attrs.id!=k.attrs.id)&&(k.nodes.length&&h(k.nodes),k.configContext&&typeof k.configContext.onunload==J&&k.configContext.onunload()),K.call(i.tag)!=I)return;var U,W=0===k.nodes.length;if(i.attrs.xmlns?o=i.attrs.xmlns:"svg"===i.tag?o="http://www.w3.org/2000/svg":"math"===i.tag&&(o="http://www.w3.org/1998/Math/MathML"),W?(U=i.attrs.is?o===c?C.createElement(i.tag,i.attrs.is):C.createElementNS(o,i.tag,i.attrs.is):o===c?C.createElement(i.tag):C.createElementNS(o,i.tag),k={tag:i.tag,attrs:V.length?g(U,i.tag,i.attrs,{},o):{},children:null!=i.children&&i.children.length>0?f(U,i.tag,c,c,i.children,k.children,!0,0,i.attrs.contenteditable?U:n,o,p):i.children,nodes:[U]},k.children&&!k.children.nodes&&(k.children.nodes=[]),"select"==i.tag&&i.attrs.value&&g(U,i.tag,{value:i.attrs.value},{},o),a.insertBefore(U,a.childNodes[m]||null)):(U=k.nodes[0],V.length&&g(U,i.tag,i.attrs,k.attrs,o),k.children=f(U,i.tag,c,c,i.children,k.children,!1,0,i.attrs.contenteditable?U:n,o,p),k.nodes.intact=!0,l===!0&&null!=U&&a.insertBefore(U,a.childNodes[m]||null)),typeof i.attrs.config==J){var X=k.configContext=k.configContext||{},Y=function(a,b){return function(){return a.attrs.config.apply(a,b)}};p.push(Y(i,[U,!W,X,k]))}}else if(typeof r!=J){var v;0===k.nodes.length?(i.$trusted?v=j(a,m,i):(v=[C.createTextNode(i)],a.nodeName.match(N)||a.insertBefore(v[0],a.childNodes[m]||null)),k="string number boolean".indexOf(typeof i)>-1?new i.constructor(i):i,k.nodes=v):k.valueOf()!==i.valueOf()||l===!0?(v=k.nodes,n&&n===C.activeElement||(i.$trusted?(h(v,k),v=j(a,m,i)):"textarea"===b?a.value=i:n?n.innerHTML=i:((1==v[0].nodeType||v.length>1)&&(h(k.nodes,k),v=[C.createTextNode(i)]),a.insertBefore(v[0],a.childNodes[m]||null),v[0].nodeValue=i)),k=new i.constructor(i),k.nodes=v):k.nodes.intact=!0}return k}function g(a,b,c,d,e){for(var f in c){var g=c[f],h=d[f];if(f in d&&h===g)"value"===f&&"input"===b&&a.value!=g&&(a.value=g);else{d[f]=g;try{if("config"===f)continue;if(typeof g==J&&0==f.indexOf("on"))a[f]=k(g,a);else if("style"===f&&null!=g&&K.call(g)==G){for(var i in g)(null==h||h[i]!==g[i])&&(a.style[i]=g[i]);for(var i in h)i in g||(a.style[i]="")}else null!=e?"href"===f?a.setAttributeNS("http://www.w3.org/1999/xlink","href",g):"className"===f?a.setAttribute("class",g):a.setAttribute(f,g):f in a&&"list"!=f&&"style"!=f&&"form"!=f&&"type"!=f?a[f]!=g&&(a[f]=g):a.setAttribute(f,g)}catch(j){if(j.message.indexOf("Invalid argument")<0)throw j}}}return d}function h(a,b){for(var c=a.length-1;c>-1;c--)if(a[c]&&a[c].parentNode){try{a[c].parentNode.removeChild(a[c])}catch(d){}b=[].concat(b),b[c]&&i(b[c])}0!=a.length&&(a.length=0)}function i(a){if(a.configContext&&typeof a.configContext.onunload==J&&a.configContext.onunload(),a.children)if(K.call(a.children)==H)for(var b=0;b<a.children.length;b++)i(a.children[b]);else a.children.tag&&i(a.children)}function j(a,b,c){var d=a.childNodes[b];if(d){var e=1!=d.nodeType,f=C.createElement("span");e?(a.insertBefore(f,d||null),f.insertAdjacentHTML("beforebegin",c),a.removeChild(f)):d.insertAdjacentHTML("beforebegin",c)}else a.insertAdjacentHTML("beforeend",c);for(var g=[];a.childNodes[b]!==d;)g.push(a.childNodes[b]),b++;return g}function k(a,b){return function(c){c=c||event,e.redraw.strategy("diff"),e.startComputation();try{return a.call(b,c)}finally{e.endComputation()}}}function l(a){var b=Q.indexOf(a);return 0>b?Q.push(a)-1:b}function m(a){var b=function(){return arguments.length&&(a=arguments[0]),a};return b.toJSON=function(){return a},b}function n(){for(var a=e.redraw.strategy(),b=0;b<T.length;b++)V[b]&&"none"!=a&&e.render(T[b],U[b].view(V[b]),"all"==a);Y&&(Y(),Y=null),W=null,X=new Date,e.redraw.strategy("diff")}function o(a){return a.slice(bb[e.route.mode].length)}function p(a,b,c){_={};var d=c.indexOf("?");-1!==d&&(_=t(c.substr(d+1,c.length)),c=c.substr(0,d));for(var f in b){if(f==c)return e.module(a,b[f]),!0;var g=new RegExp("^"+f.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$");if(g.test(c))return c.replace(g,function(){for(var c=f.match(/:[^\/]+/g)||[],d=[].slice.call(arguments,1,-2),g=0;g<c.length;g++)_[c[g].replace(/:|\./g,"")]=decodeURIComponent(d[g]);e.module(a,b[f])}),!0}}function q(a){if(a=a||event,!a.ctrlKey&&!a.metaKey&&2!=a.which){a.preventDefault?a.preventDefault():a.returnValue=!1;var b=a.currentTarget||this,c="pathname"==e.route.mode&&b.search?t(b.search.slice(1)):{};e.route(b[e.route.mode].slice(bb[e.route.mode].length),c)}}function r(){"hash"!=e.route.mode&&D.hash?D.hash=D.hash:b.scrollTo(0,0)}function s(a,b){var c=[];for(var d in a){var e=b?b+"["+d+"]":d,f=a[d];c.push(null!=f&&K.call(f)==G?s(f,e):encodeURIComponent(e)+"="+encodeURIComponent(f))}return c.join("&")}function t(a){for(var b=a.split("&"),c={},d=0;d<b.length;d++){var e=b[d].split("=");c[u(e[0])]=e[1]?u(e[1]):""}return c}function u(a){return decodeURIComponent(a.replace(/\+/g," "))}function v(a){var b=l(a);h(a.childNodes,R[b]),R[b]=c}function w(a){var b=e.prop();return a.then(b),b.then=function(b,c){return w(a.then(b,c))},b}function x(a,b){function c(a){l=a||j,n.map(function(a){l==i&&a.resolve(m)||a.reject(m)})}function d(a,b,c,d){if((null!=m&&K.call(m)==G||typeof m==J)&&typeof a==J)try{var f=0;a.call(m,function(a){f++||(m=a,b())},function(a){f++||(m=a,c())})}catch(g){e.deferred.onerror(g),m=g,c()}else d()}function f(){var j;try{j=m&&m.then}catch(n){return e.deferred.onerror(n),m=n,l=h,f()}d(j,function(){l=g,f()},function(){l=h,f()},function(){try{l==g&&typeof a==J?m=a(m):l==h&&"function"==typeof b&&(m=b(m),l=g)}catch(f){return e.deferred.onerror(f),m=f,c()}m==k?(m=TypeError(),c()):d(j,function(){c(i)},c,function(){c(l==g&&i)})})}var g=1,h=2,i=3,j=4,k=this,l=0,m=0,n=[];k.promise={},k.resolve=function(a){return l||(m=a,l=g,f()),this},k.reject=function(a){return l||(m=a,l=h,f()),this},k.promise.then=function(a,b){var c=new x(a,b);return l==i?c.resolve(m):l==j?c.reject(m):n.push(c),c.promise}}function y(a){return a}function z(a){if(!a.dataType||"jsonp"!==a.dataType.toLowerCase()){var d=new b.XMLHttpRequest;if(d.open(a.method,a.url,!0,a.user,a.password),d.onreadystatechange=function(){4===d.readyState&&(d.status>=200&&d.status<300?a.onload({type:"load",target:d}):a.onerror({type:"error",target:d}))},a.serialize==JSON.stringify&&a.data&&"GET"!=a.method&&d.setRequestHeader("Content-Type","application/json; charset=utf-8"),a.deserialize==JSON.parse&&d.setRequestHeader("Accept","application/json, text/*"),typeof a.config==J){var e=a.config(d,a);null!=e&&(d=e)}var f="GET"!=a.method&&a.data?a.data:"";if(f&&K.call(f)!=I&&f.constructor!=b.FormData)throw"Request data should be either be a string or FormData. Check the `serialize` option in `m.request`";return d.send(f),d}var g="mithril_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),h=C.createElement("script");b[g]=function(d){C.body.removeChild(h),a.onload({type:"load",target:{responseText:d}}),b[g]=c},h.onerror=function(){return C.body.removeChild(h),a.onerror({type:"error",target:{status:500,responseText:JSON.stringify({error:"Error making jsonp request"})}}),b[g]=c,!1},h.onload=function(){return!1},h.src=a.url+(a.url.indexOf("?")>0?"&":"?")+(a.callbackKey?a.callbackKey:"callback")+"="+g+"&"+s(a.data||{}),C.body.appendChild(h)}function A(a,b,c){if("GET"==a.method&&"jsonp"!=a.dataType){var d=a.url.indexOf("?")<0?"?":"&",e=s(b);a.url=a.url+(e?d+e:"")}else a.data=c(b);return a}function B(a,b){var c=a.match(/:[a-z]\w+/gi);if(c&&b)for(var d=0;d<c.length;d++){var e=c[d].slice(1);a=a.replace(c[d],b[e]),delete b[e]}return a}var C,D,E,F,G="[object Object]",H="[object Array]",I="[object String]",J="function",K={}.toString,L=/(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g,M=/\[(.+?)(?:=("|'|)(.*?)\2)?\]/,N=/^(AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR)$/;d(b);var O,P={appendChild:function(a){O===c&&(O=C.createElement("html")),C.documentElement&&C.documentElement!==a?C.replaceChild(a,C.documentElement):C.appendChild(a),this.childNodes=C.childNodes},insertBefore:function(a){this.appendChild(a)},childNodes:[]},Q=[],R={};e.render=function(a,b,d){var e=[];if(!a)throw new Error("Please ensure the DOM element exists before rendering a template into it.");var g=l(a),i=a==C,j=i||a==C.documentElement?P:a;i&&"html"!=b.tag&&(b={tag:"html",attrs:{},children:b}),R[g]===c&&h(j.childNodes),d===!0&&v(a),R[g]=f(j,null,c,c,b,R[g],!1,0,null,c,e);for(var k=0;k<e.length;k++)e[k]()},e.trust=function(a){return a=new String(a),a.$trusted=!0,a},e.prop=function(a){return(null!=a&&K.call(a)==G||typeof a==J)&&typeof a.then==J?w(a):m(a)};var S,T=[],U=[],V=[],W=null,X=0,Y=null,Z=16;e.module=function(a,b){var c=T.indexOf(a);0>c&&(c=T.length);var d=!1;if(V[c]&&typeof V[c].onunload==J){var f={preventDefault:function(){d=!0}};V[c].onunload(f)}if(!d){e.redraw.strategy("all"),e.startComputation(),T[c]=a;var g=S=b,h=new b.controller;return g==S&&(V[c]=h,U[c]=b),e.endComputation(),V[c]}},e.redraw=function(a){W&&a!==!0?(new Date-X>Z||E==b.requestAnimationFrame)&&(W>0&&F(W),W=E(n,Z)):(n(),W=E(function(){W=null},Z))},e.redraw.strategy=e.prop();var $=0;e.startComputation=function(){$++},e.endComputation=function(){$=Math.max($-1,0),0==$&&e.redraw()},e.withAttr=function(a,b){return function(c){c=c||event;var d=c.currentTarget||this;b(a in d?d[a]:d.getAttribute(a))}};var _,ab,bb={pathname:"",hash:"#",search:"?"},cb=function(){};return e.route=function(){if(0===arguments.length)return ab;if(3===arguments.length&&K.call(arguments[1])==I){var a=arguments[0],c=arguments[1],d=arguments[2];cb=function(b){var f=ab=o(b);p(a,d,f)||e.route(c,!0)};var f="hash"==e.route.mode?"onhashchange":"onpopstate";b[f]=function(){ab!=o(D[e.route.mode])&&cb(D[e.route.mode])},Y=r,b[f]()}else if(arguments[0].addEventListener){{var g=arguments[0];arguments[1],arguments[2]}g.href=("pathname"!==e.route.mode?D.pathname:"")+bb[e.route.mode]+this.attrs.href,g.removeEventListener("click",q),g.addEventListener("click",q)}else if(K.call(arguments[0])==I){ab=arguments[0];var h=arguments[1]||{},i=ab.indexOf("?"),j=i>-1?t(ab.slice(i+1)):{};for(var k in h)j[k]=h[k];var l=s(j),m=i>-1?ab.slice(0,i):ab;l&&(ab=m+(-1===m.indexOf("?")?"?":"&")+l);var n=(3==arguments.length?arguments[2]:arguments[1])===!0;b.history.pushState?(Y=function(){b.history[n?"replaceState":"pushState"](null,C.title,bb[e.route.mode]+ab),r()},cb(bb[e.route.mode]+ab)):D[e.route.mode]=ab}},e.route.param=function(a){if(!_)throw new Error("You must call m.route(element, defaultRoute, routes) before calling m.route.param()");return _[a]},e.route.mode="search",e.deferred=function(){var a=new x;return a.promise=w(a.promise),a},e.deferred.onerror=function(a){if("[object Error]"==K.call(a)&&!a.constructor.toString().match(/ Error/))throw a},e.sync=function(a){function b(a,b){return function(e){return g[a]=e,b||(c="reject"),0==--f&&(d.promise(g),d[c](g)),e}}var c="resolve",d=e.deferred(),f=a.length,g=new Array(f);if(a.length>0)for(var h=0;h<a.length;h++)a[h].then(b(h,!0),b(h,!1));else d.resolve([]);return d.promise},e.request=function(a){a.background!==!0&&e.startComputation();var b=e.deferred(),c=a.dataType&&"jsonp"===a.dataType.toLowerCase(),d=a.serialize=c?y:a.serialize||JSON.stringify,f=a.deserialize=c?y:a.deserialize||JSON.parse,g=a.extract||function(a){return 0===a.responseText.length&&f===JSON.parse?null:a.responseText};return a.url=B(a.url,a.data),a=A(a,a.data,d),a.onload=a.onerror=function(c){try{c=c||event;var d=("load"==c.type?a.unwrapSuccess:a.unwrapError)||y,h=d(f(g(c.target,a)));if("load"==c.type)if(K.call(h)==H&&a.type)for(var i=0;i<h.length;i++)h[i]=new a.type(h[i]);else a.type&&(h=new a.type(h));b["load"==c.type?"resolve":"reject"](h)}catch(c){e.deferred.onerror(c),b.reject(c)}a.background!==!0&&e.endComputation()},z(a),b.promise(a.initialValue),b.promise},e.deps=function(a){return d(b=a||b),b},e.deps.factory=a,e}("undefined"!=typeof window?window:{});"undefined"!=typeof module&&null!==module&&module.exports?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m});
//# sourceMappingURL=mithril.min.js.map

@@ -5,3 +5,3 @@ {

"keywords": ["mvc", "framework"],
"version": "0.1.25",
"version": "0.1.26",
"author": "Leo Horie <leohorie@hotmail.com>",

@@ -8,0 +8,0 @@ "repository": {"type": "git", "url": "https://github.com/lhorie/mithril"},

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc