-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnabbdom.js
1 lines (1 loc) · 9.87 KB
/
snabbdom.js
1
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).snabbdom=e()}}(function(){var e={};Object.defineProperty(e,"__esModule",{value:!0}),e.array=Array.isArray,e.primitive=function(e){return"string"==typeof e||"number"==typeof e};var t={};function n(e,t,n,r,o){return{sel:e,data:t,children:n,text:r,elm:o,key:void 0===t?void 0:t.key}}Object.defineProperty(t,"__esModule",{value:!0}),t.vnode=n,t.default=n;var r={};function o(n,r,o){var a,i,l,d={};if(void 0!==o?(d=r,e.array(o)?a=o:e.primitive(o)?i=o:o&&o.sel&&(a=[o])):void 0!==r&&(e.array(r)?a=r:e.primitive(r)?i=r:r&&r.sel?a=[r]:d=r),void 0!==a)for(l=0;l<a.length;++l)e.primitive(a[l])&&(a[l]=t.vnode(void 0,void 0,void 0,a[l],void 0));return"s"!==n[0]||"v"!==n[1]||"g"!==n[2]||3!==n.length&&"."!==n[3]&&"#"!==n[3]||function e(t,n,r){if(t.ns="http://www.w3.org/2000/svg","foreignObject"!==r&&void 0!==n)for(var o=0;o<n.length;++o){var a=n[o].data;void 0!==a&&e(a,n[o].children,n[o].sel)}}(d,a,n),t.vnode(n,d,a,i,void 0)}Object.defineProperty(r,"__esModule",{value:!0}),r.h=o,r.default=o;var a={};Object.defineProperty(a,"__esModule",{value:!0});var i="http://www.w3.org/1999/xlink",l="http://www.w3.org/XML/1998/namespace",d=58,f=120;function u(e,t){var n,r=t.elm,o=e.data.attrs,a=t.data.attrs;if((o||a)&&o!==a){for(n in o=o||{},a=a||{}){var u=a[n];o[n]!==u&&(!0===u?r.setAttribute(n,""):!1===u?r.removeAttribute(n):n.charCodeAt(0)!==f?r.setAttribute(n,u):n.charCodeAt(3)===d?r.setAttributeNS(l,n,u):n.charCodeAt(5)===d?r.setAttributeNS(i,n,u):r.setAttribute(n,u))}for(n in o)n in a||r.removeAttribute(n)}}a.attributesModule={create:u,update:u},a.default=a.attributesModule;var s={};function v(e,t){var n,r,o=t.elm,a=e.data.class,i=t.data.class;if((a||i)&&a!==i){for(r in i=i||{},a=a||{})i[r]||o.classList.remove(r);for(r in i)(n=i[r])!==a[r]&&o.classList[n?"add":"remove"](r)}}Object.defineProperty(s,"__esModule",{value:!0}),s.classModule={create:v,update:v},s.default=s.classModule;var c={};Object.defineProperty(c,"__esModule",{value:!0});var p=/[A-Z]/g;function m(e,t){var n,r=t.elm,o=e.data.dataset,a=t.data.dataset;if((o||a)&&o!==a){o=o||{},a=a||{};var i=r.dataset;for(n in o)a[n]||(i?n in i&&delete i[n]:r.removeAttribute("data-"+n.replace(p,"-$&").toLowerCase()));for(n in a)o[n]!==a[n]&&(i?i[n]=a[n]:r.setAttribute("data-"+n.replace(p,"-$&").toLowerCase(),a[n]))}}c.datasetModule={create:m,update:m},c.default=c.datasetModule;var h={};function y(e,t){var n,r=e.data.on,o=e.listener,a=e.elm,i=t&&t.data.on,l=t&&t.elm;if(r!==i){if(r&&o)if(i)for(n in r)i[n]||a.removeEventListener(n,o,!1);else for(n in r)a.removeEventListener(n,o,!1);if(i){var d=t.listener=e.listener||function e(t){!function(e,t){var n=e.type,r=t.data.on;r&&r[n]&&function e(t,n,r){if("function"==typeof t)t.call(n,r,n);else if("object"==typeof t)if("function"==typeof t[0])if(2===t.length)t[0].call(n,t[1],r,n);else{var o=t.slice(1);o.push(r),o.push(n),t[0].apply(n,o)}else for(var a=0;a<t.length;a++)e(t[a],n,r)}(r[n],t,e)}(t,e.vnode)};if(d.vnode=t,r)for(n in i)r[n]||l.addEventListener(n,d,!1);else for(n in i)l.addEventListener(n,d,!1)}}}Object.defineProperty(h,"__esModule",{value:!0}),h.eventListenersModule={create:y,update:y,destroy:y},h.default=h.eventListenersModule;var g={};function b(e,t){var n,r,o=t.elm,a=e.data.props,i=t.data.props;if((a||i)&&a!==i){for(n in i=i||{},a=a||{})i[n]||delete o[n];for(n in i)r=i[n],a[n]===r||"value"===n&&o[n]===r||(o[n]=r)}}Object.defineProperty(g,"__esModule",{value:!0}),g.propsModule={create:b,update:b},g.default=g.propsModule;var x={};Object.defineProperty(x,"__esModule",{value:!0});var C="undefined"!=typeof window&&window.requestAnimationFrame.bind(window)||setTimeout,M=function(e){C(function(){C(e)})},w=!1;function _(e,t,n){M(function(){e[t]=n})}function k(e,t){var n,r,o=t.elm,a=e.data.style,i=t.data.style;if((a||i)&&a!==i){i=i||{};var l="delayed"in(a=a||{});for(r in a)i[r]||("-"===r[0]&&"-"===r[1]?o.style.removeProperty(r):o.style[r]="");for(r in i)if(n=i[r],"delayed"===r&&i.delayed)for(var d in i.delayed)n=i.delayed[d],l&&n===a.delayed[d]||_(o.style,d,n);else"remove"!==r&&n!==a[r]&&("-"===r[0]&&"-"===r[1]?o.style.setProperty(r,n):o.style[r]=n)}}x.styleModule={pre:function(){w=!1},create:k,update:k,destroy:function(e){var t,n,r=e.elm,o=e.data.style;if(o&&(t=o.destroy))for(n in t)r.style[n]=t[n]},remove:function(e,t){var n=e.data.style;if(n&&n.remove){w||(getComputedStyle(document.body).transform,w=!0);var r,o=e.elm,a=0,i=n.remove,l=0,d=[];for(r in i)d.push(r),o.style[r]=i[r];for(var f=getComputedStyle(o)["transition-property"].split(", ");a<f.length;++a)-1!==d.indexOf(f[a])&&l++;o.addEventListener("transitionend",function(e){e.target===o&&--l,0===l&&t()})}else t()}},x.default=x.styleModule;var A={};Object.defineProperty(A,"__esModule",{value:!0}),A.htmlDomApi={createElement:function(e){return document.createElement(e)},createElementNS:function(e,t){return document.createElementNS(e,t)},createTextNode:function(e){return document.createTextNode(e)},createComment:function(e){return document.createComment(e)},insertBefore:function(e,t,n){e.insertBefore(t,n)},removeChild:function(e,t){e.removeChild(t)},appendChild:function(e,t){e.appendChild(t)},parentNode:function(e){return e.parentNode},nextSibling:function(e){return e.nextSibling},tagName:function(e){return e.tagName},setTextContent:function(e,t){e.textContent=t},getTextContent:function(e){return e.textContent},isElement:function(e){return 1===e.nodeType},isText:function(e){return 3===e.nodeType},isComment:function(e){return 8===e.nodeType}},A.default=A.htmlDomApi;var N={};function j(e,t){t.elm=e.elm,e.data.fn=t.data.fn,e.data.args=t.data.args,t.data=e.data,t.children=e.children,t.text=e.text,t.elm=e.elm}function O(e){var t=e.data;j(t.fn.apply(void 0,t.args),e)}function P(e,t){var n,r=e.data,o=t.data,a=r.args,i=o.args;if(r.fn===o.fn&&a.length===i.length){for(n=0;n<i.length;++n)if(a[n]!==i[n])return void j(o.fn.apply(void 0,i),t);j(e,t)}else j(o.fn.apply(void 0,i),t)}Object.defineProperty(N,"__esModule",{value:!0}),N.thunk=function(e,t,n,o){return void 0===o&&(o=n,n=t,t=void 0),r.h(e,{key:t,hook:{init:O,prepatch:P},fn:n,args:o})},N.default=N.thunk;var T={};function L(e){return void 0===e}function E(e){return void 0!==e}Object.defineProperty(T,"__esModule",{value:!0});var S=t.default("",{},[],void 0,void 0);function B(e,t){return e.key===t.key&&e.sel===t.sel}function D(e,t,n){var r,o,a,i={};for(r=t;r<=n;++r)null!=(a=e[r])&&void 0!==(o=a.key)&&(i[o]=r);return i}var $=["create","update","remove","destroy","pre","post"];r.h,N.thunk,T.init=function(n,r){var o,a,i={},l=void 0!==r?r:A.default;for(o=0;o<$.length;++o)for(i[$[o]]=[],a=0;a<n.length;++a){var d=n[a][$[o]];void 0!==d&&i[$[o]].push(d)}function f(e,t){return function(){if(0==--t){var n=l.parentNode(e);l.removeChild(n,e)}}}function u(t,n){var r,o=t.data;void 0!==o&&E(r=o.hook)&&E(r=r.init)&&(r(t),o=t.data);var a=t.children,d=t.sel;if("!"===d)L(t.text)&&(t.text=""),t.elm=l.createComment(t.text);else if(void 0!==d){var f=d.indexOf("#"),s=d.indexOf(".",f),v=f>0?f:d.length,c=s>0?s:d.length,p=-1!==f||-1!==s?d.slice(0,Math.min(v,c)):d,m=t.elm=E(o)&&E(r=o.ns)?l.createElementNS(r,p):l.createElement(p);for(v<c&&m.setAttribute("id",d.slice(v+1,c)),s>0&&m.setAttribute("class",d.slice(c+1).replace(/\./g," ")),r=0;r<i.create.length;++r)i.create[r](S,t);if(e.array(a))for(r=0;r<a.length;++r){var h=a[r];null!=h&&l.appendChild(m,u(h,n))}else e.primitive(t.text)&&l.appendChild(m,l.createTextNode(t.text));E(r=t.data.hook)&&(r.create&&r.create(S,t),r.insert&&n.push(t))}else t.elm=l.createTextNode(t.text);return t.elm}function s(e,t,n,r,o,a){for(;r<=o;++r){var i=n[r];null!=i&&l.insertBefore(e,u(i,a),t)}}function v(e){var t,n,r=e.data;if(void 0!==r){for(E(t=r.hook)&&E(t=t.destroy)&&t(e),t=0;t<i.destroy.length;++t)i.destroy[t](e);if(void 0!==e.children)for(n=0;n<e.children.length;++n)null!=(t=e.children[n])&&"string"!=typeof t&&v(t)}}function c(e,t,n,r){for(;n<=r;++n){var o=void 0,a=void 0,d=void 0,u=t[n];if(null!=u)if(E(u.sel)){for(v(u),a=i.remove.length+1,d=f(u.elm,a),o=0;o<i.remove.length;++o)i.remove[o](u,d);E(o=u.data)&&E(o=o.hook)&&E(o=o.remove)?o(u,d):d()}else l.removeChild(e,u.elm)}}return function(e,n){var r,o,a,d=[];for(r=0;r<i.pre.length;++r)i.pre[r]();for(void 0!==e.sel||(e=function(e){var n=e.id?"#"+e.id:"",r=e.className?"."+e.className.split(" ").join("."):"";return t.default(l.tagName(e).toLowerCase()+n+r,{},[],void 0,e)}(e)),B(e,n)?function e(t,n,r){var o,a;E(o=n.data)&&E(a=o.hook)&&E(o=a.prepatch)&&o(t,n);var d=n.elm=t.elm,f=t.children,v=n.children;if(t!==n){if(void 0!==n.data){for(o=0;o<i.update.length;++o)i.update[o](t,n);E(o=n.data.hook)&&E(o=o.update)&&o(t,n)}L(n.text)?E(f)&&E(v)?f!==v&&function(t,n,r,o){for(var a,i,d,f=0,v=0,p=n.length-1,m=n[0],h=n[p],y=r.length-1,g=r[0],b=r[y];f<=p&&v<=y;)null==m?m=n[++f]:null==h?h=n[--p]:null==g?g=r[++v]:null==b?b=r[--y]:B(m,g)?(e(m,g,o),m=n[++f],g=r[++v]):B(h,b)?(e(h,b,o),h=n[--p],b=r[--y]):B(m,b)?(e(m,b,o),l.insertBefore(t,m.elm,l.nextSibling(h.elm)),m=n[++f],b=r[--y]):B(h,g)?(e(h,g,o),l.insertBefore(t,h.elm,m.elm),h=n[--p],g=r[++v]):(void 0===a&&(a=D(n,f,p)),L(i=a[g.key])?(l.insertBefore(t,u(g,o),m.elm),g=r[++v]):((d=n[i]).sel!==g.sel?l.insertBefore(t,u(g,o),m.elm):(e(d,g,o),n[i]=void 0,l.insertBefore(t,d.elm,m.elm)),g=r[++v]));(f<=p||v<=y)&&(f>p?s(t,null==r[y+1]?null:r[y+1].elm,r,v,y,o):c(t,n,f,p))}(d,f,v,r):E(v)?(E(t.text)&&l.setTextContent(d,""),s(d,null,v,0,v.length-1,r)):E(f)?c(d,f,0,f.length-1):E(t.text)&&l.setTextContent(d,""):t.text!==n.text&&(E(f)&&c(d,f,0,f.length-1),l.setTextContent(d,n.text)),E(a)&&E(o=a.postpatch)&&o(t,n)}}(e,n,d):(o=e.elm,a=l.parentNode(o),u(n,d),null!==a&&(l.insertBefore(a,n.elm,l.nextSibling(o)),c(a,[e],0,0))),r=0;r<d.length;++r)d[r].data.hook.insert(d[r]);for(r=0;r<i.post.length;++r)i.post[r]();return n}};const q=T.init([s.default,g.default,a.default,x.default,c.default,h.default]);return{h:r.default,thunk:N.default,patch:q}});