Comparing version 0.9.1 to 0.9.2
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.hyperapp=e.hyperapp||{})}(this,function(e){"use strict";var t=function(e,t){for(var n,r=[],a=[],o=arguments.length;o-- >2;)r[r.length]=arguments[o];for(;r.length;)if(Array.isArray(n=r.pop()))for(var o=n.length;o--;)r[r.length]=n[o];else null!=n&&!0!==n&&!1!==n&&("number"==typeof n&&(n+=""),a[a.length]=n);return"string"==typeof e?{tag:e,data:t||{},children:a}:e(t,a)},n=function(e){function t(e,n,i){Object.keys(n||[]).map(function(u){var f=n[u],c=i?i+"."+u:u;"function"==typeof f?e[u]=function(e){var t=f(v,g,r("action",{name:c,data:e}).data,r);if(null==t||"function"==typeof t.then)return t;a(v=o(v,r("update",t)),h)}:t(e[u]||(e[u]={}),f,c)})}function n(){a(v,h),r("loaded")}function r(e,t){return(y[e]||[]).map(function(e){var n=e(v,g,t,r);null!=n&&(t=n)}),t}function a(t,n){s=d(e.root||(e.root=document.body),s,p,p=r("render",n)(t,g))}function o(e,t){var n={};if("object"!=typeof t||Array.isArray(t))return t;for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function i(e,t){if("string"==typeof e)var n=document.createTextNode(e);else{for(var n=(t=t||"svg"===e.tag)?document.createElementNS("http://www.w3.org/2000/svg",e.tag):document.createElement(e.tag),r=0;r<e.children.length;)n.appendChild(i(e.children[r++],t));for(var r in e.data)"oncreate"===r?e.data[r](n):u(n,r,e.data[r])}return n}function u(e,t,n,r){if("key"===t);else if("style"===t)for(var a in o(r,n=n||{}))e.style[a]=n[a]||"";else{try{e[t]=n}catch(e){}"function"!=typeof n&&(n?e.setAttribute(t,n):e.removeAttribute(t))}}function f(e,t,n){for(var r in o(t,n)){var a=n[r],i=t[r];"onupdate"===r?a(e):a===i&&a===e[r]||u(e,r,a,i)}}function c(e){if(e&&(e=e.data))return e.key}function l(e,t,n){n.data&&n.data.onremove&&n.data.onremove(t),e.removeChild(t)}function d(e,t,n,r){if(null==n)t=e.insertBefore(i(r),t);else if(r.tag&&r.tag===n.tag){f(t,n.data,r.data);for(var a=r.children.length,o=n.children.length,u={},p=[],s={},v=0;v<o;v++){var h=t.childNodes[v];p[v]=h;var g=n.children[v],y=c(g);null!=y&&(u[y]=[h,g])}for(var v=0,m=0;m<a;){var h=p[v],g=n.children[v],b=r.children[m],y=c(g);if(s[y])v++;else{var w=c(b),A=u[w],k=0,x=0;A&&(k=A[0],x=A[1]),null==w?(null==y&&(d(t,h,g,b),m++),v++):(y===w?(d(t,k,x,b),v++):k?(t.insertBefore(k,h),d(t,k,x,b)):d(t,h,null,b),m++,s[w]=b)}}for(;v<o;){var g=n.children[v],y=c(g);null==y&&l(t,p[v],g),v++}for(var v in u){var A=u[v],x=A[1];s[x.data.key]||l(t,A[0],x)}}else if(r!==n){var v=t;e.replaceChild(t=i(r),v)}return t}for(var p,s,v={},h=e.view,g={},y={},m=-1,b=e.plugins||[];m<b.length;m++){var w=b[m]?b[m](e):e;null!=w.state&&(v=o(v,w.state)),t(g,w.actions),Object.keys(w.events||[]).map(function(e){y[e]=(y[e]||[]).concat(w.events[e])})}"l"!==document.readyState[0]?n():addEventListener("DOMContentLoaded",n)},r=function(e){function t(t){var n,r={};for(var a in e.view){var o=[];n||"*"===a||t.replace(RegExp("^"+a.replace(/\//g,"\\/").replace(/:([\w]+)/g,function(e,t){return o.push(t),"([-\\w]+)"})+"/?$","g"),function(){for(var e=1;e<arguments.length-2;)r[o.shift()]=arguments[e++];n=a})}return{match:n||"*",params:r}}return{state:{router:t(location.pathname)},actions:{router:{match:function(e,n,r,a){return{router:a("route",t(r))}},go:function(e,t,n){history.pushState({},"",n),t.router.match(n)}}},events:{loaded:function(e,t){function n(){t.router.match(location.pathname)}n(),addEventListener("popstate",n)},render:function(e,t,n){return n[e.router.match]}}}};e.h=t,e.app=n,e.Router=r}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.hyperapp=e.hyperapp||{})}(this,function(e){"use strict";var t=function(e,t){for(var n,r=[],a=[],o=arguments.length;o-- >2;)r[r.length]=arguments[o];for(;r.length;)if(Array.isArray(n=r.pop()))for(o=n.length;o--;)r[r.length]=n[o];else null!=n&&!0!==n&&!1!==n&&("number"==typeof n&&(n+=""),a[a.length]=n);return"string"==typeof e?{tag:e,data:t||{},children:a}:e(t,a)},n=function(e){function t(e,n,i){Object.keys(n||[]).map(function(u){var c=n[u],f=i?i+"."+u:u;"function"==typeof c?e[u]=function(e){var t=c(h,g,r("action",{name:f,data:e}).data,r);if(null==t||"function"==typeof t.then)return t;a(h=o(h,r("update",t)),v)}:t(e[u]||(e[u]={}),c,f)})}function n(){a(h,v),r("loaded")}function r(e,t){return(y[e]||[]).map(function(e){var n=e(h,g,t,r);null!=n&&(t=n)}),t}function a(t,n){s=d(e.root||(e.root=document.body),s,p,p=r("render",n)(t,g))}function o(e,t){var n={};if("object"!=typeof t||Array.isArray(t))return t;for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function i(e,t){if("string"==typeof e)n=document.createTextNode(e);else{for(var n=(t=t||"svg"===e.tag)?document.createElementNS("http://www.w3.org/2000/svg",e.tag):document.createElement(e.tag),r=0;r<e.children.length;)n.appendChild(i(e.children[r++],t));for(var r in e.data)"oncreate"===r?e.data[r](n):u(n,r,e.data[r])}return n}function u(e,t,n,r){if("key"===t);else if("style"===t)for(var a in o(r,n=n||{}))e.style[a]=n[a]||"";else{try{e[t]=n}catch(e){}"function"!=typeof n&&(n?e.setAttribute(t,n):e.removeAttribute(t))}}function c(e,t,n){for(var r in o(t,n)){var a=n[r],i="value"===r||"checked"===r?e[r]:t[r];"onupdate"===r&&a?a(e):a!==i&&u(e,r,a,i)}}function f(e){if(e&&(e=e.data))return e.key}function l(e,t,n){function r(){e.removeChild(t)}(n.data&&n.data.onremove||r)(t,r)}function d(e,t,n,r){if(null==n)t=e.insertBefore(i(r),t);else if(r.tag&&r.tag===n.tag){c(t,n.data,r.data);for(var a=r.children.length,o=n.children.length,u={},p=[],s={},h=0;h<o;h++){g=t.childNodes[h];p[h]=g,null!=(k=f(y=n.children[h]))&&(u[k]=[g,y])}for(var h=0,v=0;v<a;){var g=p[h],y=n.children[h],m=r.children[v];if(s[k=f(y)])h++;else{var b=f(m),w=u[b]||[];null==b?(null==k&&(d(t,g,y,m),v++),h++):(k===b?(d(t,w[0],w[1],m),h++):w[0]?(t.insertBefore(w[0],g),d(t,w[0],w[1],m)):d(t,g,null,m),v++,s[b]=m)}}for(;h<o;){var k=f(y=n.children[h]);null==k&&l(t,p[h],y),h++}for(var h in u){var A=(w=u[h])[1];s[A.data.key]||l(t,w[0],A)}}else if(r!==n){h=t;e.replaceChild(t=i(r),h)}return t}for(var p,s,h={},v=e.view,g={},y={},m=-1,b=e.plugins||[];m<b.length;m++){var w=b[m]?b[m](e):e;null!=w.state&&(h=o(h,w.state)),t(g,w.actions),Object.keys(w.events||[]).map(function(e){y[e]=(y[e]||[]).concat(w.events[e])})}"l"!==document.readyState[0]?n():addEventListener("DOMContentLoaded",n)},r=function(e){function t(t){var n,r={};for(var a in e.view){var o=[];n||"*"===a||t.replace(RegExp("^"+a.replace(/\//g,"\\/").replace(/:([\w]+)/g,function(e,t){return o.push(t),"([-\\w]+)"})+"/?$","g"),function(){for(var e=1;e<arguments.length-2;)r[o.shift()]=arguments[e++];n=a})}return{match:n||"*",params:r}}return{state:{router:t(location.pathname)},actions:{router:{match:function(e,n,r,a){return{router:a("route",t(r))}},go:function(e,t,n){history.pushState({},"",n),t.router.match(n.split("?")[0])}}},events:{loaded:function(e,t){function n(){t.router.match(location.pathname)}n(),addEventListener("popstate",n)},render:function(e,t,n){return n[e.router.match]}}}};e.h=t,e.app=n,e.Router=r}); | ||
//# sourceMappingURL=hyperapp.js.map |
@@ -1,2 +0,2 @@ | ||
Copyright © 2017 [Jorge Bucaran](https://github.com/jbucaran) | ||
Copyright © 2017-present [Jorge Bucaran](https://github.com/jbucaran) | ||
@@ -3,0 +3,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "hyperapp", | ||
"description": "1kb JavaScript library for building frontend applications.", | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"main": "dist/hyperapp.js", | ||
@@ -34,8 +34,8 @@ "jsnext:main": "src/index.js", | ||
"devDependencies": { | ||
"babel-preset-es2015": "^6.22.0", | ||
"jest": "^19.0.2", | ||
"prettier": "~1.2.2", | ||
"rollup": "^0.41.4", | ||
"rollup-plugin-uglify": "^1.0.1" | ||
"babel-preset-es2015": "^6.24.1", | ||
"jest": "^20.0.4", | ||
"prettier": "~1.4.1", | ||
"rollup": "^0.41.6", | ||
"rollup-plugin-uglify": "^2.0.1" | ||
} | ||
} |
# [hyperapp](https://hyperapp.glitch.me) | ||
[![Travis CI](https://img.shields.io/travis/hyperapp/hyperapp/master.svg)](https://travis-ci.org/hyperapp/hyperapp) | ||
[![Codecov](https://img.shields.io/codecov/c/github/hyperapp/hyperapp/master.svg)](https://codecov.io/gh/hyperapp/hyperapp) | ||
[![CDNJS](https://img.shields.io/cdnjs/v/hyperapp.svg?colorB=ff69b4)](https://cdnjs.com/libraries/hyperapp) | ||
[![npm](https://img.shields.io/npm/v/hyperapp.svg?colorB=ff69b4)](https://www.npmjs.org/package/hyperapp) | ||
[![npm](https://img.shields.io/npm/v/hyperapp.svg?colorB=09e5f9)](https://www.npmjs.org/package/hyperapp) | ||
[![Slack](https://hyperappjs.herokuapp.com/badge.svg)](https://hyperappjs.herokuapp.com "Join us") | ||
@@ -23,8 +22,18 @@ | ||
[Try it online](https://codepen.io/hyperapp/pen/Qdwpxy?editors=0010) | ||
[Try it online](https://codepen.io/hyperapp/pen/zNxZLP?editors=0010) | ||
```jsx | ||
app({ | ||
state: "Hi.", | ||
view: state => <h1>{state}</h1> | ||
state: 0, | ||
view: (state, actions) => ( | ||
<main> | ||
<h1>{state}</h1> | ||
<button onclick={actions.add}>+</button> | ||
<button onclick={actions.sub}>-</button> | ||
</main> | ||
), | ||
actions: { | ||
add: state => state + 1, | ||
sub: state => state - 1 | ||
} | ||
}) | ||
@@ -31,0 +40,0 @@ ``` |
@@ -148,7 +148,9 @@ export default function(app) { | ||
var value = data[name] | ||
var oldValue = oldData[name] | ||
var oldValue = name === "value" || name === "checked" | ||
? element[name] | ||
: oldData[name] | ||
if (name === "onupdate") { | ||
if (name === "onupdate" && value) { | ||
value(element) | ||
} else if (value !== oldValue || value !== element[name]) { | ||
} else if (value !== oldValue) { | ||
setElementData(element, name, value, oldValue) | ||
@@ -166,6 +168,6 @@ } | ||
function removeElement(parent, element, node) { | ||
if (node.data && node.data.onremove) { | ||
node.data.onremove(element) | ||
;((node.data && node.data.onremove) || removeChild)(element, removeChild) | ||
function removeChild() { | ||
parent.removeChild(element) | ||
} | ||
parent.removeChild(element) | ||
} | ||
@@ -213,11 +215,4 @@ | ||
var reusableChild = reusableChildren[newKey] | ||
var reusableElement = 0 | ||
var reusableNode = 0 | ||
var reusableChild = reusableChildren[newKey] || [] | ||
if (reusableChild) { | ||
reusableElement = reusableChild[0] | ||
reusableNode = reusableChild[1] | ||
} | ||
if (null == newKey) { | ||
@@ -231,7 +226,7 @@ if (null == oldKey) { | ||
if (oldKey === newKey) { | ||
patch(element, reusableElement, reusableNode, newChild) | ||
patch(element, reusableChild[0], reusableChild[1], newChild) | ||
i++ | ||
} else if (reusableElement) { | ||
element.insertBefore(reusableElement, oldElement) | ||
patch(element, reusableElement, reusableNode, newChild) | ||
} else if (reusableChild[0]) { | ||
element.insertBefore(reusableChild[0], oldElement) | ||
patch(element, reusableChild[0], reusableChild[1], newChild) | ||
} else { | ||
@@ -238,0 +233,0 @@ patch(element, oldElement, null, newChild) |
@@ -15,3 +15,3 @@ export default function(app) { | ||
history.pushState({}, "", data) | ||
actions.router.match(data) | ||
actions.router.match(data.split("?")[0]) | ||
} | ||
@@ -18,0 +18,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11
59
33274
328
1