closures 0.7.5 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/closures.cjs +5 -3
- package/dist/closures.js +5 -3
- package/dist/closures.min.js +1 -1
- package/package.json +1 -1
package/dist/closures.cjs
CHANGED
@@ -117,7 +117,7 @@ let patchAttributes = (el, newProps, oldProps, env) => {
|
|
117
117
|
|
118
118
|
let oldValue = oldProps[key],
|
119
119
|
newValue = newProps[key];
|
120
|
-
|
120
|
+
|
121
121
|
if (oldValue !== newValue)
|
122
122
|
key.startsWith('on')
|
123
123
|
? el[key.toLowerCase()] = ev => { newValue(ev); !env.manualRedraw && env.rerender(); }
|
@@ -509,8 +509,10 @@ function h(_t, ...children) {
|
|
509
509
|
|
510
510
|
// inline class parsing
|
511
511
|
if (isStr(_t) && ~(idx = _t.indexOf('.'))) {
|
512
|
-
let
|
513
|
-
|
512
|
+
let classProp = props.class || props.className,
|
513
|
+
className = _t.slice(idx + 1).replace(/\./g, ' ') + (classProp ? ' ' + classProp : '');
|
514
|
+
|
515
|
+
if (className) props.class = className;
|
514
516
|
_t = _t.slice(0, idx);
|
515
517
|
}
|
516
518
|
|
package/dist/closures.js
CHANGED
@@ -117,7 +117,7 @@ let patchAttributes = (el, newProps, oldProps, env) => {
|
|
117
117
|
|
118
118
|
let oldValue = oldProps[key],
|
119
119
|
newValue = newProps[key];
|
120
|
-
|
120
|
+
|
121
121
|
if (oldValue !== newValue)
|
122
122
|
key.startsWith('on')
|
123
123
|
? el[key.toLowerCase()] = ev => { newValue(ev); !env.manualRedraw && env.rerender(); }
|
@@ -509,8 +509,10 @@ export function h(_t, ...children) {
|
|
509
509
|
|
510
510
|
// inline class parsing
|
511
511
|
if (isStr(_t) && ~(idx = _t.indexOf('.'))) {
|
512
|
-
let
|
513
|
-
|
512
|
+
let classProp = props.class || props.className,
|
513
|
+
className = _t.slice(idx + 1).replace(/\./g, ' ') + (classProp ? ' ' + classProp : '');
|
514
|
+
|
515
|
+
if (className) props.class = className;
|
514
516
|
_t = _t.slice(0, idx);
|
515
517
|
}
|
516
518
|
|
package/dist/closures.min.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.closures={})}(this,(function(e){let t=void 0,r=e=>{},n=e=>({mount(t,r=""){t[e]=r},patch(t,r="",n){r!==n&&(t[e]=r)},unmount(r){r[e]=t}}),i={isSVG:!1,redraw:r,directives:{selected:n("selected"),checked:n("checked"),value:n("value"),innerHTML:n("innerHTML")}},o=[],l=[],d=new WeakMap,c=1,s={},f="http://www.w3.org/1999/xlink",h={show:f,actuate:f,href:f},p=e=>"function"==typeof e,u=e=>"string"==typeof e,a=e=>null!==e&&"object"==typeof e,y=e=>Array.isArray(e),v=e=>JSON.stringify(e),w=e=>null===e||!1===e||e===t||y(e)&&0===e.length||e&&"="===e._t,m=e=>y(e)&&e.length>0,g=e=>u(e)||"number"==typeof e,k=e=>e&&1===e.vtype,R=e=>e&&2===e.vtype,
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.closures={})}(this,(function(e){let t=void 0,r=e=>{},n=e=>({mount(t,r=""){t[e]=r},patch(t,r="",n){r!==n&&(t[e]=r)},unmount(r){r[e]=t}}),i={isSVG:!1,redraw:r,directives:{selected:n("selected"),checked:n("checked"),value:n("value"),innerHTML:n("innerHTML")}},o=[],l=[],d=new WeakMap,c=1,s={},f="http://www.w3.org/1999/xlink",h={show:f,actuate:f,href:f},p=e=>"function"==typeof e,u=e=>"string"==typeof e,a=e=>null!==e&&"object"==typeof e,y=e=>Array.isArray(e),v=e=>JSON.stringify(e),w=e=>null===e||!1===e||e===t||y(e)&&0===e.length||e&&"="===e._t,m=e=>y(e)&&e.length>0,g=e=>u(e)||"number"==typeof e,k=e=>e&&1===e.vtype,R=e=>e&&2===e.vtype,_=e=>{let t=e.type;if(1===t)return e.node;if(8===t)return _(e.childRef);if(4===t)return _(e.children[0]);throw Error("Unknown ref type "+v(e))},S=e=>{let t=e.type;if(1===t)return e.node.nextSibling;if(8===t)return S(e.childRef);if(4===t)return S(e.children[e.children.length-1]);throw Error("Unknown ref type "+v(e))},E=(e,t,r)=>{let n=t.type;if(1===n)e.insertBefore(t.node,r);else if(8===n)E(e,t.childRef,r);else{if(4!==n)throw Error("Unknown ref type "+v(t));for(let n=0;n<t.children.length;n++)E(e,t.children[n],r)}},N=(e,t)=>{let r=t.type;if(1===r)e.removeChild(t.node);else if(8===r)N(e,t.childRef);else{if(4!==r)throw Error("Unknown ref type "+v(t));for(let r=0;r<t.children.length;r++)N(e,t.children[r])}},V=(e,r,n,i)=>{"className"===r&&(r="class"),n===t&&(n=""),!0===n?e.setAttribute(r,""):!1===n?e.removeAttribute(r):i&&h[r]?e.setAttributeNS(h[r],r,n):e.setAttribute(r,n)},b=(e,n,i,o,s=r)=>{let f={closureId:i,closure:o,onRemove:s};if(w(e))return{...f,type:1,node:document.createComment("NULL")};if(g(e))return{...f,type:1,node:document.createTextNode(e)};if(k(e)){let r,{_t:i,props:o}=e;"svg"!==i||n.isSVG||(n={...n,isSVG:!0}),r=n.isSVG?document.createElementNS("http://www.w3.org/2000/svg",i):document.createElement(i),p(o.oncreate)&&o.oncreate(r),((e,t,r)=>{for(let n in t)"key"===n||"children"===n||"oncreate"===n||n in r.directives||(n.startsWith("on")?e[n.toLowerCase()]=e=>{t[n](e),!r.manualRedraw&&r.rerender()}:V(e,n,t[n],r.isSVG))})(r,o,n);let l=o.children===t?o.children:b(o.children,n);return l!==t&&E(r,l),((e,t,r)=>{for(let n in t)n in r.directives&&r.directives[n].mount(e,t[n])})(r,o,n),{...f,type:1,node:r,children:l}}if(m(e)){let t=0,r=[];for(;t<e.length;t++)r.push(b(e[t],n));return{...f,type:4,children:r}}if(R(e)){let t=e._t(e.props);if(p(t)){let i=c++,o=d.get(e._t)||new Map,s=l.pop()||r;o.set(i,t),d.set(e._t,o);let f=e._t;return e._t=t,b(e,n,i,f,s)}return{...f,type:8,childRef:b(t,n),childState:t}}if(e instanceof Node)return{...f,type:1,node:e};if(e===t)throw Error("mount: vnode is undefined");throw Error("mount: Invalid vnode")},x=(e,r,n)=>{if(k(e))((e,t,r)=>{for(let n in t)n in r.directives&&r.directives[n].unmount(e,t[n])})(r.node,e.props,n),e.props.children!==t&&x(e.props.children,r.children,n);else if(m(e))for(let t=0;t<e.length;t++)x(e[t],r.children[t],n);else if(R(e)){let e=r.closure,t=r.closureId,i=r.onRemove,o=d.get(e);o&&t&&o.get(t)&&(o.delete(t),!o.size&&d.delete(e),i()),x(r.childState,r.childRef,n)}},A=(e,t,r,n,i)=>{let o=G(e,t,r,n,i);return o!==n&&(((e,t,r)=>{E(e,t,_(r)),N(e,r)})(e,o,n),x(r,n,i)),o},G=(e,r,n,o,l={...i})=>{if(r&&"="===r._t)return o;let c,s;if(a(o)&&(c=o.closure,s=o.closureId),R(r)&&R(n)&&(r._t===n._t||c&&s)){let t,n=r._t,i=d.get(c);i&&s&&(t=i.get(s))&&(n=t);let f=n(r.props),h=G(e,f,o.childState,o.childRef,l);return h!==o.childRef?{type:8,childRef:h,childState:f}:(o.childState=f,o)}if(n===r||w(r)&&w(n))return o;if(g(r)&&g(n))return o.node.nodeValue=r,o;if(k(r)&&k(n)&&r._t===n._t){"svg"!==r._t||l.isSVG||(l={...l,isSVG:!0}),((e,r,n,i)=>{let o;for(o in r){if("key"===o||"children"===o||"oncreate"===o||o in i.directives)continue;let t=n[o],l=r[o];t!==l&&(o.startsWith("on")?e[o.toLowerCase()]=e=>{l(e),!i.manualRedraw&&i.rerender()}:V(e,o,l,i.isSVG))}for(o in n)"key"===o||"children"===o||o in r||o in i.directives||(o.startsWith("on")?e[o.toLowerCase()]=t:e.removeAttribute(o))})(o.node,r.props,n.props,l);let e=n.props.children,i=r.props.children;return e===t?i!==t&&(o.children=b(i,l),E(o.node,o.children)):i===t?(o.node.textContent="",x(e,o.children,l),o.children=t):o.children=A(o.node,i,e,o.children,l),((e,t,r,n)=>{let i;for(i in t)i in n.directives&&n.directives[i].patch(e,t[i],r[i]);for(i in r)i in n.directives&&!(i in t)&&n.directives[i].unmount(e,r[i])})(o.node,r.props,n.props,l),o}return m(r)&&m(n)?(((e,r,n,i,o)=>{let l,d,c,s,f,h,p,u,a=S(i),y=Array(r.length),v=i.children,w=0,m=0,g=r.length-1,k=n.length-1;for(;w<=g&&m<=k;)if(v[m]!==t)if(v[k]!==t)if(c=n[m],s=r[w],c&&s&&s.key===c.key)f=v[m],h=y[w]=A(e,s,c,f,o),w++,m++;else if(c=n[k],s=r[g],c&&s&&s.key===c.key)f=v[k],h=y[g]=A(e,s,c,f,o),g--,k--;else{if(p===t)for(l=m,p={};l<=k;l++)c=n[l],c&&c.key!==t&&(p[c.key]=l);s=r[w],d=s&&s.key!==t?p[s.key]:t,d!==t?(c=n[d],f=v[d],h=y[w]=G(e,s,c,f,o),E(e,h,_(v[m])),h!==f&&(N(e,f),x(c,f,o)),v[d]=t):(h=y[w]=b(s,o),E(e,h,_(v[m]))),w++}else k--;else m++;for(u=g<r.length-1?_(y[g+1]):a;w<=g;)h=b(r[w],o),y[w]=h,E(e,h,u),w++;for(;m<=k;)f=v[m],f!==t&&(N(e,f),x(n[m],f,o)),m++;i.children=y})(e,r,n,o,l),o):r instanceof Node&&n instanceof Node?(o.node=r,o):b(r,l)};function C(e,...r){let n,i=r[0];if(!i||!a(i)||y(i)||i._t||i.props?i=s:r.shift(),i=r.length>1?{...i,children:r}:1===r.length?{...i,children:r[0]}:i,u(e)&&~(n=e.indexOf("."))){let t=i.class||i.className,r=e.slice(n+1).replace(/\./g," ")+(t?" "+t:"");r&&(i.class=r),e=e.slice(0,n)}if(i.key!=i.key)throw new Error("Invalid NaN key");let o=u(e)?1:p(e)?2:t;if(o===t)throw new Error("Invalid VNode type");return{vtype:o,_t:e,key:i.key,props:i}}C.retain=e=>C("=");const L=C;e.Fragment=e=>e.children,e.app=function(e,r,n={}){let l,d={...i,manualRedraw:n.manualRedraw},c=r.$_REF;if(d.directives={...d.directives,...n.directives||{}},c!==t)throw Error("App already mounted on this node");return l=b(e,d),c=r.$_REF={ref:l,vnode:e},r.textContent="",E(r,l,t),o.push(d.rerender=(t=e)=>{c.ref=A(r,t,c.vnode,c.ref,d),c.vnode=t})&&d.rerender},e.h=C,e.m=L,e.onRemove=e=>l.push(e),e.redraw=e=>{for(let e=0;e<o.length;e++)o[e]()}}));
|