diff --git a/README.md b/README.md index ab2038b..3aa78a1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# JDOM `3.1.7` +# JDOM `3.1.8` ## A wrapper for query selector and html elements + templating & reactivity framework - [Installation or embedding](#install) @@ -28,12 +28,12 @@ npm install jdomjs ### Module ```js -import { $, $n, $c, $r, $h, JDOM } from 'https://cdn.jsdelivr.net/npm/jdomjs@3.1.7' +import { $, $n, $c, $r, $h, JDOM } from 'https://cdn.jsdelivr.net/npm/jdomjs@3.1.8' ``` ### HTML import ```js - + ``` ## DOM Manipulation diff --git a/dist/jdom.js b/dist/jdom.js index ad23f81..c5c312e 100644 --- a/dist/jdom.js +++ b/dist/jdom.js @@ -1,2 +1,2 @@ /*! For license information please see jdom.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,(()=>(()=>{var t={7694:(t,e,n)=>{n(1761),t.exports=n(5645).RegExp.escape},4963:t=>{t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},3365:(t,e,n)=>{var r=n(2032);t.exports=function(t,e){if("number"!=typeof t&&"Number"!=r(t))throw TypeError(e);return+t}},7722:(t,e,n)=>{var r=n(6314)("unscopables"),i=Array.prototype;null==i[r]&&n(7728)(i,r,{}),t.exports=function(t){i[r][t]=!0}},6793:(t,e,n)=>{"use strict";var r=n(4496)(!0);t.exports=function(t,e,n){return e+(n?r(t,e).length:1)}},3328:t=>{t.exports=function(t,e,n,r){if(!(t instanceof e)||void 0!==r&&r in t)throw TypeError(n+": incorrect invocation!");return t}},7007:(t,e,n)=>{var r=n(5286);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},5216:(t,e,n)=>{"use strict";var r=n(508),i=n(2337),o=n(875);t.exports=[].copyWithin||function(t,e){var n=r(this),a=o(n.length),u=i(t,a),c=i(e,a),s=arguments.length>2?arguments[2]:void 0,f=Math.min((void 0===s?a:i(s,a))-c,a-u),l=1;for(c0;)c in n?n[u]=n[c]:delete n[u],u+=l,c+=l;return n}},6852:(t,e,n)=>{"use strict";var r=n(508),i=n(2337),o=n(875);t.exports=function(t){for(var e=r(this),n=o(e.length),a=arguments.length,u=i(a>1?arguments[1]:void 0,n),c=a>2?arguments[2]:void 0,s=void 0===c?n:i(c,n);s>u;)e[u++]=t;return e}},9490:(t,e,n)=>{var r=n(3531);t.exports=function(t,e){var n=[];return r(t,!1,n.push,n,e),n}},9315:(t,e,n)=>{var r=n(2110),i=n(875),o=n(2337);t.exports=function(t){return function(e,n,a){var u,c=r(e),s=i(c.length),f=o(a,s);if(t&&n!=n){for(;s>f;)if((u=c[f++])!=u)return!0}else for(;s>f;f++)if((t||f in c)&&c[f]===n)return t||f||0;return!t&&-1}}},50:(t,e,n)=>{var r=n(741),i=n(9797),o=n(508),a=n(875),u=n(6886);t.exports=function(t,e){var n=1==t,c=2==t,s=3==t,f=4==t,l=6==t,h=5==t||l,v=e||u;return function(e,u,p){for(var y,d,g=o(e),m=i(g),b=r(u,p,3),w=a(m.length),x=0,S=n?v(e,w):c?v(e,0):void 0;w>x;x++)if((h||x in m)&&(d=b(y=m[x],x,g),t))if(n)S[x]=d;else if(d)switch(t){case 3:return!0;case 5:return y;case 6:return x;case 2:S.push(y)}else if(f)return!1;return l?-1:s||f?f:S}}},7628:(t,e,n)=>{var r=n(4963),i=n(508),o=n(9797),a=n(875);t.exports=function(t,e,n,u,c){r(e);var s=i(t),f=o(s),l=a(s.length),h=c?l-1:0,v=c?-1:1;if(n<2)for(;;){if(h in f){u=f[h],h+=v;break}if(h+=v,c?h<0:l<=h)throw TypeError("Reduce of empty array with no initial value")}for(;c?h>=0:l>h;h+=v)h in f&&(u=e(u,f[h],h,s));return u}},2736:(t,e,n)=>{var r=n(5286),i=n(4302),o=n(6314)("species");t.exports=function(t){var e;return i(t)&&("function"!=typeof(e=t.constructor)||e!==Array&&!i(e.prototype)||(e=void 0),r(e)&&null===(e=e[o])&&(e=void 0)),void 0===e?Array:e}},6886:(t,e,n)=>{var r=n(2736);t.exports=function(t,e){return new(r(t))(e)}},4398:(t,e,n)=>{"use strict";var r=n(4963),i=n(5286),o=n(7242),a=[].slice,u={},c=function(t,e,n){if(!(e in u)){for(var r=[],i=0;i{var r=n(2032),i=n(6314)("toStringTag"),o="Arguments"==r(function(){return arguments}());t.exports=function(t){var e,n,a;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),i))?n:o?r(e):"Object"==(a=r(e))&&"function"==typeof e.callee?"Arguments":a}},2032:t=>{var e={}.toString;t.exports=function(t){return e.call(t).slice(8,-1)}},9824:(t,e,n)=>{"use strict";var r=n(9275).f,i=n(2503),o=n(4408),a=n(741),u=n(3328),c=n(3531),s=n(2923),f=n(5436),l=n(2974),h=n(7057),v=n(4728).fastKey,p=n(1616),y=h?"_s":"size",d=function(t,e){var n,r=v(e);if("F"!==r)return t._i[r];for(n=t._f;n;n=n.n)if(n.k==e)return n};t.exports={getConstructor:function(t,e,n,s){var f=t((function(t,r){u(t,f,e,"_i"),t._t=e,t._i=i(null),t._f=void 0,t._l=void 0,t[y]=0,null!=r&&c(r,n,t[s],t)}));return o(f.prototype,{clear:function(){for(var t=p(this,e),n=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete n[r.i];t._f=t._l=void 0,t[y]=0},delete:function(t){var n=p(this,e),r=d(n,t);if(r){var i=r.n,o=r.p;delete n._i[r.i],r.r=!0,o&&(o.n=i),i&&(i.p=o),n._f==r&&(n._f=i),n._l==r&&(n._l=o),n[y]--}return!!r},forEach:function(t){p(this,e);for(var n,r=a(t,arguments.length>1?arguments[1]:void 0,3);n=n?n.n:this._f;)for(r(n.v,n.k,this);n&&n.r;)n=n.p},has:function(t){return!!d(p(this,e),t)}}),h&&r(f.prototype,"size",{get:function(){return p(this,e)[y]}}),f},def:function(t,e,n){var r,i,o=d(t,e);return o?o.v=n:(t._l=o={i:i=v(e,!0),k:e,v:n,p:r=t._l,n:void 0,r:!1},t._f||(t._f=o),r&&(r.n=o),t[y]++,"F"!==i&&(t._i[i]=o)),t},getEntry:d,setStrong:function(t,e,n){s(t,e,(function(t,n){this._t=p(t,e),this._k=n,this._l=void 0}),(function(){for(var t=this,e=t._k,n=t._l;n&&n.r;)n=n.p;return t._t&&(t._l=n=n?n.n:t._t._f)?f(0,"keys"==e?n.k:"values"==e?n.v:[n.k,n.v]):(t._t=void 0,f(1))}),n?"entries":"values",!n,!0),l(e)}}},6132:(t,e,n)=>{var r=n(1488),i=n(9490);t.exports=function(t){return function(){if(r(this)!=t)throw TypeError(t+"#toJSON isn't generic");return i(this)}}},3657:(t,e,n)=>{"use strict";var r=n(4408),i=n(4728).getWeak,o=n(7007),a=n(5286),u=n(3328),c=n(3531),s=n(50),f=n(9181),l=n(1616),h=s(5),v=s(6),p=0,y=function(t){return t._l||(t._l=new d)},d=function(){this.a=[]},g=function(t,e){return h(t.a,(function(t){return t[0]===e}))};d.prototype={get:function(t){var e=g(this,t);if(e)return e[1]},has:function(t){return!!g(this,t)},set:function(t,e){var n=g(this,t);n?n[1]=e:this.a.push([t,e])},delete:function(t){var e=v(this.a,(function(e){return e[0]===t}));return~e&&this.a.splice(e,1),!!~e}},t.exports={getConstructor:function(t,e,n,o){var s=t((function(t,r){u(t,s,e,"_i"),t._t=e,t._i=p++,t._l=void 0,null!=r&&c(r,n,t[o],t)}));return r(s.prototype,{delete:function(t){if(!a(t))return!1;var n=i(t);return!0===n?y(l(this,e)).delete(t):n&&f(n,this._i)&&delete n[this._i]},has:function(t){if(!a(t))return!1;var n=i(t);return!0===n?y(l(this,e)).has(t):n&&f(n,this._i)}}),s},def:function(t,e,n){var r=i(o(e),!0);return!0===r?y(t).set(e,n):r[t._i]=n,t},ufstore:y}},5795:(t,e,n)=>{"use strict";var r=n(3816),i=n(2985),o=n(7234),a=n(4408),u=n(4728),c=n(3531),s=n(3328),f=n(5286),l=n(4253),h=n(7462),v=n(2943),p=n(266);t.exports=function(t,e,n,y,d,g){var m=r[t],b=m,w=d?"set":"add",x=b&&b.prototype,S={},E=function(t){var e=x[t];o(x,t,"delete"==t||"has"==t?function(t){return!(g&&!f(t))&&e.call(this,0===t?0:t)}:"get"==t?function(t){return g&&!f(t)?void 0:e.call(this,0===t?0:t)}:"add"==t?function(t){return e.call(this,0===t?0:t),this}:function(t,n){return e.call(this,0===t?0:t,n),this})};if("function"==typeof b&&(g||x.forEach&&!l((function(){(new b).entries().next()})))){var _=new b,k=_[w](g?{}:-0,1)!=_,O=l((function(){_.has(1)})),j=h((function(t){new b(t)})),A=!g&&l((function(){for(var t=new b,e=5;e--;)t[w](e,e);return!t.has(-0)}));j||((b=e((function(e,n){s(e,b,t);var r=p(new m,e,b);return null!=n&&c(n,d,r[w],r),r}))).prototype=x,x.constructor=b),(O||A)&&(E("delete"),E("has"),d&&E("get")),(A||k)&&E(w),g&&x.clear&&delete x.clear}else b=y.getConstructor(e,t,d,w),a(b.prototype,n),u.NEED=!0;return v(b,t),S[t]=b,i(i.G+i.W+i.F*(b!=m),S),g||y.setStrong(b,t,d),b}},5645:t=>{var e=t.exports={version:"2.6.12"};"number"==typeof __e&&(__e=e)},2811:(t,e,n)=>{"use strict";var r=n(9275),i=n(681);t.exports=function(t,e,n){e in t?r.f(t,e,i(0,n)):t[e]=n}},741:(t,e,n)=>{var r=n(4963);t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}}},3537:(t,e,n)=>{"use strict";var r=n(4253),i=Date.prototype.getTime,o=Date.prototype.toISOString,a=function(t){return t>9?t:"0"+t};t.exports=r((function(){return"0385-07-25T07:06:39.999Z"!=o.call(new Date(-50000000000001))}))||!r((function(){o.call(new Date(NaN))}))?function(){if(!isFinite(i.call(this)))throw RangeError("Invalid time value");var t=this,e=t.getUTCFullYear(),n=t.getUTCMilliseconds(),r=e<0?"-":e>9999?"+":"";return r+("00000"+Math.abs(e)).slice(r?-6:-4)+"-"+a(t.getUTCMonth()+1)+"-"+a(t.getUTCDate())+"T"+a(t.getUTCHours())+":"+a(t.getUTCMinutes())+":"+a(t.getUTCSeconds())+"."+(n>99?n:"0"+a(n))+"Z"}:o},870:(t,e,n)=>{"use strict";var r=n(7007),i=n(1689),o="number";t.exports=function(t){if("string"!==t&&t!==o&&"default"!==t)throw TypeError("Incorrect hint");return i(r(this),t!=o)}},1355:t=>{t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},7057:(t,e,n)=>{t.exports=!n(4253)((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},2457:(t,e,n)=>{var r=n(5286),i=n(3816).document,o=r(i)&&r(i.createElement);t.exports=function(t){return o?i.createElement(t):{}}},4430:t=>{t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},5541:(t,e,n)=>{var r=n(7184),i=n(4548),o=n(4682);t.exports=function(t){var e=r(t),n=i.f;if(n)for(var a,u=n(t),c=o.f,s=0;u.length>s;)c.call(t,a=u[s++])&&e.push(a);return e}},2985:(t,e,n)=>{var r=n(3816),i=n(5645),o=n(7728),a=n(7234),u=n(741),c="prototype",s=function(t,e,n){var f,l,h,v,p=t&s.F,y=t&s.G,d=t&s.S,g=t&s.P,m=t&s.B,b=y?r:d?r[e]||(r[e]={}):(r[e]||{})[c],w=y?i:i[e]||(i[e]={}),x=w[c]||(w[c]={});for(f in y&&(n=e),n)h=((l=!p&&b&&void 0!==b[f])?b:n)[f],v=m&&l?u(h,r):g&&"function"==typeof h?u(Function.call,h):h,b&&a(b,f,h,t&s.U),w[f]!=h&&o(w,f,v),g&&x[f]!=h&&(x[f]=h)};r.core=i,s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,t.exports=s},8852:(t,e,n)=>{var r=n(6314)("match");t.exports=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[r]=!1,!"/./"[t](e)}catch(t){}}return!0}},4253:t=>{t.exports=function(t){try{return!!t()}catch(t){return!0}}},8082:(t,e,n)=>{"use strict";n(8269);var r=n(7234),i=n(7728),o=n(4253),a=n(1355),u=n(6314),c=n(1165),s=u("species"),f=!o((function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$")})),l=function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2===n.length&&"a"===n[0]&&"b"===n[1]}();t.exports=function(t,e,n){var h=u(t),v=!o((function(){var e={};return e[h]=function(){return 7},7!=""[t](e)})),p=v?!o((function(){var e=!1,n=/a/;return n.exec=function(){return e=!0,null},"split"===t&&(n.constructor={},n.constructor[s]=function(){return n}),n[h](""),!e})):void 0;if(!v||!p||"replace"===t&&!f||"split"===t&&!l){var y=/./[h],d=n(a,h,""[t],(function(t,e,n,r,i){return e.exec===c?v&&!i?{done:!0,value:y.call(e,n,r)}:{done:!0,value:t.call(n,e,r)}:{done:!1}})),g=d[0],m=d[1];r(String.prototype,t,g),i(RegExp.prototype,h,2==e?function(t,e){return m.call(t,this,e)}:function(t){return m.call(t,this)})}}},3218:(t,e,n)=>{"use strict";var r=n(7007);t.exports=function(){var t=r(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e}},3325:(t,e,n)=>{"use strict";var r=n(4302),i=n(5286),o=n(875),a=n(741),u=n(6314)("isConcatSpreadable");t.exports=function t(e,n,c,s,f,l,h,v){for(var p,y,d=f,g=0,m=!!h&&a(h,v,3);g0)d=t(e,n,p,o(p.length),d,l-1)-1;else{if(d>=9007199254740991)throw TypeError();e[d]=p}d++}g++}return d}},3531:(t,e,n)=>{var r=n(741),i=n(8851),o=n(6555),a=n(7007),u=n(875),c=n(9002),s={},f={},l=t.exports=function(t,e,n,l,h){var v,p,y,d,g=h?function(){return t}:c(t),m=r(n,l,e?2:1),b=0;if("function"!=typeof g)throw TypeError(t+" is not iterable!");if(o(g)){for(v=u(t.length);v>b;b++)if((d=e?m(a(p=t[b])[0],p[1]):m(t[b]))===s||d===f)return d}else for(y=g.call(t);!(p=y.next()).done;)if((d=i(y,m,p.value,e))===s||d===f)return d};l.BREAK=s,l.RETURN=f},18:(t,e,n)=>{t.exports=n(3825)("native-function-to-string",Function.toString)},3816:t=>{var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)},9181:t=>{var e={}.hasOwnProperty;t.exports=function(t,n){return e.call(t,n)}},7728:(t,e,n)=>{var r=n(9275),i=n(681);t.exports=n(7057)?function(t,e,n){return r.f(t,e,i(1,n))}:function(t,e,n){return t[e]=n,t}},639:(t,e,n)=>{var r=n(3816).document;t.exports=r&&r.documentElement},1734:(t,e,n)=>{t.exports=!n(7057)&&!n(4253)((function(){return 7!=Object.defineProperty(n(2457)("div"),"a",{get:function(){return 7}}).a}))},266:(t,e,n)=>{var r=n(5286),i=n(7375).set;t.exports=function(t,e,n){var o,a=e.constructor;return a!==n&&"function"==typeof a&&(o=a.prototype)!==n.prototype&&r(o)&&i&&i(t,o),t}},7242:t=>{t.exports=function(t,e,n){var r=void 0===n;switch(e.length){case 0:return r?t():t.call(n);case 1:return r?t(e[0]):t.call(n,e[0]);case 2:return r?t(e[0],e[1]):t.call(n,e[0],e[1]);case 3:return r?t(e[0],e[1],e[2]):t.call(n,e[0],e[1],e[2]);case 4:return r?t(e[0],e[1],e[2],e[3]):t.call(n,e[0],e[1],e[2],e[3])}return t.apply(n,e)}},9797:(t,e,n)=>{var r=n(2032);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},6555:(t,e,n)=>{var r=n(2803),i=n(6314)("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(r.Array===t||o[i]===t)}},4302:(t,e,n)=>{var r=n(2032);t.exports=Array.isArray||function(t){return"Array"==r(t)}},8367:(t,e,n)=>{var r=n(5286),i=Math.floor;t.exports=function(t){return!r(t)&&isFinite(t)&&i(t)===t}},5286:t=>{t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},5364:(t,e,n)=>{var r=n(5286),i=n(2032),o=n(6314)("match");t.exports=function(t){var e;return r(t)&&(void 0!==(e=t[o])?!!e:"RegExp"==i(t))}},8851:(t,e,n)=>{var r=n(7007);t.exports=function(t,e,n,i){try{return i?e(r(n)[0],n[1]):e(n)}catch(e){var o=t.return;throw void 0!==o&&r(o.call(t)),e}}},9988:(t,e,n)=>{"use strict";var r=n(2503),i=n(681),o=n(2943),a={};n(7728)(a,n(6314)("iterator"),(function(){return this})),t.exports=function(t,e,n){t.prototype=r(a,{next:i(1,n)}),o(t,e+" Iterator")}},2923:(t,e,n)=>{"use strict";var r=n(4461),i=n(2985),o=n(7234),a=n(7728),u=n(2803),c=n(9988),s=n(2943),f=n(468),l=n(6314)("iterator"),h=!([].keys&&"next"in[].keys()),v="keys",p="values",y=function(){return this};t.exports=function(t,e,n,d,g,m,b){c(n,e,d);var w,x,S,E=function(t){if(!h&&t in j)return j[t];switch(t){case v:case p:return function(){return new n(this,t)}}return function(){return new n(this,t)}},_=e+" Iterator",k=g==p,O=!1,j=t.prototype,A=j[l]||j["@@iterator"]||g&&j[g],P=A||E(g),L=g?k?E("entries"):P:void 0,M="Array"==e&&j.entries||A;if(M&&(S=f(M.call(new t)))!==Object.prototype&&S.next&&(s(S,_,!0),r||"function"==typeof S[l]||a(S,l,y)),k&&A&&A.name!==p&&(O=!0,P=function(){return A.call(this)}),r&&!b||!h&&!O&&j[l]||a(j,l,P),u[e]=P,u[_]=y,g)if(w={values:k?P:E(p),keys:m?P:E(v),entries:L},b)for(x in w)x in j||o(j,x,w[x]);else i(i.P+i.F*(h||O),e,w);return w}},7462:(t,e,n)=>{var r=n(6314)("iterator"),i=!1;try{var o=[7][r]();o.return=function(){i=!0},Array.from(o,(function(){throw 2}))}catch(t){}t.exports=function(t,e){if(!e&&!i)return!1;var n=!1;try{var o=[7],a=o[r]();a.next=function(){return{done:n=!0}},o[r]=function(){return a},t(o)}catch(t){}return n}},5436:t=>{t.exports=function(t,e){return{value:e,done:!!t}}},2803:t=>{t.exports={}},4461:t=>{t.exports=!1},3086:t=>{var e=Math.expm1;t.exports=!e||e(10)>22025.465794806718||e(10)<22025.465794806718||-2e-17!=e(-2e-17)?function(t){return 0==(t=+t)?t:t>-1e-6&&t<1e-6?t+t*t/2:Math.exp(t)-1}:e},4934:(t,e,n)=>{var r=n(1801),i=Math.pow,o=i(2,-52),a=i(2,-23),u=i(2,127)*(2-a),c=i(2,-126);t.exports=Math.fround||function(t){var e,n,i=Math.abs(t),s=r(t);return iu||n!=n?s*(1/0):s*n}},6206:t=>{t.exports=Math.log1p||function(t){return(t=+t)>-1e-8&&t<1e-8?t-t*t/2:Math.log(1+t)}},8757:t=>{t.exports=Math.scale||function(t,e,n,r,i){return 0===arguments.length||t!=t||e!=e||n!=n||r!=r||i!=i?NaN:t===1/0||t===-1/0?t:(t-e)*(i-r)/(n-e)+r}},1801:t=>{t.exports=Math.sign||function(t){return 0==(t=+t)||t!=t?t:t<0?-1:1}},4728:(t,e,n)=>{var r=n(3953)("meta"),i=n(5286),o=n(9181),a=n(9275).f,u=0,c=Object.isExtensible||function(){return!0},s=!n(4253)((function(){return c(Object.preventExtensions({}))})),f=function(t){a(t,r,{value:{i:"O"+ ++u,w:{}}})},l=t.exports={KEY:r,NEED:!1,fastKey:function(t,e){if(!i(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!o(t,r)){if(!c(t))return"F";if(!e)return"E";f(t)}return t[r].i},getWeak:function(t,e){if(!o(t,r)){if(!c(t))return!0;if(!e)return!1;f(t)}return t[r].w},onFreeze:function(t){return s&&l.NEED&&c(t)&&!o(t,r)&&f(t),t}}},133:(t,e,n)=>{var r=n(8416),i=n(2985),o=n(3825)("metadata"),a=o.store||(o.store=new(n(147))),u=function(t,e,n){var i=a.get(t);if(!i){if(!n)return;a.set(t,i=new r)}var o=i.get(e);if(!o){if(!n)return;i.set(e,o=new r)}return o};t.exports={store:a,map:u,has:function(t,e,n){var r=u(e,n,!1);return void 0!==r&&r.has(t)},get:function(t,e,n){var r=u(e,n,!1);return void 0===r?void 0:r.get(t)},set:function(t,e,n,r){u(n,r,!0).set(t,e)},keys:function(t,e){var n=u(t,e,!1),r=[];return n&&n.forEach((function(t,e){r.push(e)})),r},key:function(t){return void 0===t||"symbol"==typeof t?t:String(t)},exp:function(t){i(i.S,"Reflect",t)}}},4351:(t,e,n)=>{var r=n(3816),i=n(4193).set,o=r.MutationObserver||r.WebKitMutationObserver,a=r.process,u=r.Promise,c="process"==n(2032)(a);t.exports=function(){var t,e,n,s=function(){var r,i;for(c&&(r=a.domain)&&r.exit();t;){i=t.fn,t=t.next;try{i()}catch(r){throw t?n():e=void 0,r}}e=void 0,r&&r.enter()};if(c)n=function(){a.nextTick(s)};else if(!o||r.navigator&&r.navigator.standalone)if(u&&u.resolve){var f=u.resolve(void 0);n=function(){f.then(s)}}else n=function(){i.call(r,s)};else{var l=!0,h=document.createTextNode("");new o(s).observe(h,{characterData:!0}),n=function(){h.data=l=!l}}return function(r){var i={fn:r,next:void 0};e&&(e.next=i),t||(t=i,n()),e=i}}},3499:(t,e,n)=>{"use strict";var r=n(4963);function i(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=r(e),this.reject=r(n)}t.exports.f=function(t){return new i(t)}},5345:(t,e,n)=>{"use strict";var r=n(7057),i=n(7184),o=n(4548),a=n(4682),u=n(508),c=n(9797),s=Object.assign;t.exports=!s||n(4253)((function(){var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach((function(t){e[t]=t})),7!=s({},t)[n]||Object.keys(s({},e)).join("")!=r}))?function(t,e){for(var n=u(t),s=arguments.length,f=1,l=o.f,h=a.f;s>f;)for(var v,p=c(arguments[f++]),y=l?i(p).concat(l(p)):i(p),d=y.length,g=0;d>g;)v=y[g++],r&&!h.call(p,v)||(n[v]=p[v]);return n}:s},2503:(t,e,n)=>{var r=n(7007),i=n(5588),o=n(4430),a=n(9335)("IE_PROTO"),u=function(){},c="prototype",s=function(){var t,e=n(2457)("iframe"),r=o.length;for(e.style.display="none",n(639).appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write(" + + \ No newline at end of file diff --git a/ex/main.js b/ex/main.js new file mode 100644 index 0000000..48f464d --- /dev/null +++ b/ex/main.js @@ -0,0 +1,17 @@ +import { JDOMComponent, html, $r, $, computed, Hook } from 'https://esm.run/jdomjs@3.1.7' + +class MyComponent extends JDOMComponent { + example = new Hook('Hello World') + + render() { + setTimeout(() => this.example.value = "Yooo", 5000) + + return html` +
${computed(() => this.example.value, [this.example])}
+ ` + } +} + +$r('my-component', MyComponent) + +$(document).append(html``) \ No newline at end of file diff --git a/examples/example.html b/examples/example.html index 9d130f4..cfd04a0 100644 --- a/examples/example.html +++ b/examples/example.html @@ -21,8 +21,6 @@ import Hook from "../src/Hook.js"; import { ForEach, Awaiting } from "../src/template/helper/components.js"; - const a = state(0) - function Test(props) { console.log(props) return html` @@ -30,18 +28,7 @@

Halloooo

` } - html` - - -

a.value === 0, [a])}>Hallo

- <${Test} :else-if=${computed(() => a.value === 3, [a])} /> -

ESLE

- - - - `.appendTo(document) - /* const paste = fetch(`https://pastefy.app/api/v2/paste/9XH0KD7g`) .then(r => r.json()) .then(r => JSON.parse(r.content)) diff --git a/examples/js-components/main.js b/examples/js-components/main.js index 7e0f64c..db4a29f 100644 --- a/examples/js-components/main.js +++ b/examples/js-components/main.js @@ -4,6 +4,7 @@ import Hook from "../../src/Hook.js"; class ToDoApp extends JDOMComponent { tasks = new Hook([]); newTaskText = new Hook(''); + constructor() { super(); } diff --git a/package-lock.json b/package-lock.json index 73b799f..a7a2457 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "jdomjs", - "version": "3.1.6", + "version": "3.1.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e29d59d..59ac10f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jdomjs", - "version": "3.1.7", + "version": "3.1.8", "description": "A wrapper for query selector and html elements", "main": "./index.js", "types": "./types/index.d.ts", diff --git a/src/Hook.js b/src/Hook.js index 154d5c6..cf01d78 100644 --- a/src/Hook.js +++ b/src/Hook.js @@ -41,13 +41,13 @@ export default class Hook { set: (target, prop, value) => { if (Object.hasOwn(target, prop) || prop in target || prop === 'value') { if (target[prop] === value) - return; + return true; return Reflect.set(target, prop, value); } if (typeof target._value === 'object' && !Array.isArray(target._value) && target._value !== null) { if (target._value[prop] === value) - return; + return true; return Reflect.set(target._value, prop, value); } @@ -69,7 +69,7 @@ export default class Hook { return new Proxy(val, { set: (target, prop, value) => { if (val === val[prop]) - return; + return true; val[prop] = value this.setValue(val) diff --git a/src/hooks.js b/src/hooks.js index 3b187d2..41d5427 100644 --- a/src/hooks.js +++ b/src/hooks.js @@ -3,17 +3,17 @@ import Hook from './Hook.js' /** * @template T * @param {T} initialValue - * @return {Hook} + * @return {Hook} */ export function state(initialValue) { return new Hook(initialValue) } /** - * - * @param {function()} callable + * @template T + * @param {function(): T} callable * @param {Hook[]} dependencies - * @return {Hook} + * @return {Hook} */ export function computed(callable, dependencies = []) { const hook = new Hook(callable()) diff --git a/src/template/TemplateDOMAdapter.js b/src/template/TemplateDOMAdapter.js index a59b666..8e92e7e 100644 --- a/src/template/TemplateDOMAdapter.js +++ b/src/template/TemplateDOMAdapter.js @@ -144,7 +144,7 @@ export default class TemplateDOMAdapter { } }) - model.listeners.push(val => { + model.addListener(val => { if (elem.value !== model.value) { elem.value = val elem.dispatchEvent(new InputEvent('input:value')) @@ -329,18 +329,15 @@ export default class TemplateDOMAdapter { }) if (isArray) { - const comment = document.createComment('JDOM-Templating:arrhook') + const comment = document.createComment('JDOM-Templating:arrhook1') outputElement = comment let elements = [] - removeEl = () => elements.forEach(e => e.forEach(i => this.removeElement(i))) const setElements = () => { for (const item of elements) { - item.elements.forEach(e => this.removeElement(e)) - elements = elements.filter(e => e !== item) + this.removeElement(item) } - let i = 0 if (!Array.isArray(state.value)) { this.replaceElement(outputElement, this.createFromValue({ value: state.value })) @@ -349,17 +346,37 @@ export default class TemplateDOMAdapter { } let lastEl = comment + let i = 0 for (const item of state.value) { let itemEls = this.createFromValue({value: item}) if (!Array.isArray(itemEls)) itemEls = [itemEls] - elements = [...elements, { - key: ++i, - elements: itemEls - }] + const currentIndex = i++ + elements = [...elements, ...itemEls] - itemEls.forEach(e => lastEl = this.afterElement(lastEl, e)) + itemEls.forEach((e) => { + lastEl = this.afterElement(lastEl, e) + + const addReplaceListener = toRepl => { + toRepl.addEventListener(':replaced_with', ({detail: {to}}) => { + for (const e of to) { + addReplaceListener(e) + elements.push(e) + } + }) + + toRepl.addEventListener(':attached', () => { + elements.push(toRepl) + }) + + toRepl.addEventListener(':detached', () => { + elements = elements.filter(e => e !== toRepl) + }) + } + + addReplaceListener(lastEl) + }) } } @@ -369,12 +386,7 @@ export default class TemplateDOMAdapter { setElements() - let out = [] - - for (const item of elements) { - item.elements.forEach(e => out = [...out, e]) - } - return [comment, ...out] + return [comment, ...elements] } else if (typeof state.value === 'string' || typeof state.value === 'number' || typeof state.value === 'boolean') { outputElement = this.createText({value: state.value}) @@ -446,6 +458,7 @@ export default class TemplateDOMAdapter { replaceElement(from, to) { const replElements = Array.isArray(from) ? [...from] : [from] const endElements = Array.isArray(to) ? [...to] : [to] + const finalEndElements = [...endElements] if (endElements.length === 0) endElements.push(document.createComment('JDOM-Templating:REPLACEMENT')) @@ -456,7 +469,7 @@ export default class TemplateDOMAdapter { const firstEndEl = endElements.shift() - firstEl.dispatchEvent(new CustomEvent(':replace_with', { to })) + firstEl.dispatchEvent(new CustomEvent(':replace_with', { detail: { to: finalEndElements } })) firstEl.dispatchEvent(new CustomEvent(':detach')) firstEndEl.dispatchEvent(new CustomEvent(':child_attach')) firstEl.replaceWith(firstEndEl) @@ -468,7 +481,7 @@ export default class TemplateDOMAdapter { lastEl = this.afterElement(lastEl, e) }) - firstEl.dispatchEvent(new CustomEvent(':replaced_with', { to })) + firstEl.dispatchEvent(new CustomEvent(':replaced_with', { detail: { to: finalEndElements } })) firstEl.dispatchEvent(new CustomEvent(':detached')) firstEndEl.dispatchEvent(new CustomEvent(':child_attached')) diff --git a/src/template/template.js b/src/template/template.js index 6afb523..932cdeb 100644 --- a/src/template/template.js +++ b/src/template/template.js @@ -11,16 +11,20 @@ import Hook from '../Hook.js' * @return {JDOM} */ export function html(strings, ...values) { - // console.time("myFunction"); const parser = JDOMTemplateParser.fromTemplate(strings, ...values) const parsed = parser.parse() const adapter = new TemplateJDOMAdapter(parsed) - // console.timeEnd("myFunction"); return adapter.create() } - +/** + * Usage: css`h1 {font-size: 20px}` + * + * @param strings + * @param values + * @return string + */ export function css(strings, ...values) { let out = '' let i = 0 @@ -45,9 +49,9 @@ export function css(strings, ...values) { * ` * ``` * - * @param {string[]} strings - * @param {...any} values - * @return {Hook} + * @param strings + * @param values + * @return {Hook} */ export function comp(strings, ...values) { return computed(() => { diff --git a/types/src/hooks.d.ts b/types/src/hooks.d.ts index 32bc43f..e6ca886 100644 --- a/types/src/hooks.d.ts +++ b/types/src/hooks.d.ts @@ -1,16 +1,16 @@ /** * @template T * @param {T} initialValue - * @return {Hook} + * @return {Hook} */ -export function state(initialValue: T): Hook; +export function state(initialValue: T): Hook; /** - * - * @param {function()} callable + * @template T + * @param {function(): T} callable * @param {Hook[]} dependencies - * @return {Hook} + * @return {Hook} */ -export function computed(callable: () => any, dependencies?: Hook[]): Hook; +export function computed(callable: () => T, dependencies?: Hook[]): Hook; /** * @param {Hook[]} hooks * @param {function()} callable diff --git a/types/src/router/Router.d.ts b/types/src/router/Router.d.ts index b2d56dd..90afb3f 100644 --- a/types/src/router/Router.d.ts +++ b/types/src/router/Router.d.ts @@ -25,7 +25,7 @@ export default class Router { * @type Route[] */ routes: Route[]; - view: import("src/Hook.js").default; + view: import("src/Hook.js").default; link: (to: any, text: any) => any; /** * @param to diff --git a/types/src/template/template.d.ts b/types/src/template/template.d.ts index 1be94af..fff42b6 100644 --- a/types/src/template/template.d.ts +++ b/types/src/template/template.d.ts @@ -6,6 +6,13 @@ * @return {JDOM} */ export function html(strings: any, ...values: any[]): JDOM; +/** + * Usage: css`h1 {font-size: 20px}` + * + * @param strings + * @param values + * @return string + */ export function css(strings: any, ...values: any[]): string; /** * usage: @@ -18,9 +25,9 @@ export function css(strings: any, ...values: any[]): string; * ` * ``` * - * @param {string[]} strings - * @param {...any} values - * @return {Hook} + * @param strings + * @param values + * @return {Hook} */ -export function comp(strings: string[], ...values: any[]): Hook; +export function comp(strings: any, ...values: any[]): Hook; import Hook from '../Hook.js';