diff --git a/dist/computed-properties.min.mjs b/dist/computed-properties.min.mjs index 35591f9..9a9b55b 100644 --- a/dist/computed-properties.min.mjs +++ b/dist/computed-properties.min.mjs @@ -1 +1 @@ -var r=new WeakMap,t=new WeakMap,e=[],n=!1,o=Symbol("stackDelimiter"),f=Symbol("ref"),i=Symbol("hasUnmounted"),a=Symbol("proxyTarget"),u=function(){var r=h();return{get:s,set:r,deleteProperty:r}}(),l=function(){var r=h(!0);return{get:s,set:r,deleteProperty:r}}();function c(){for(;e.length;)e.pop();return n=!1}function v(){for(var r=e.length-1;r>=0&&e.pop()!==o;r-=1);}function s(r,t,f){if(t===a)return r;for(var i=!1,u=e.length-1;u>=0;u-=1){var l=e[u];if(l===o)break;l[0]===r&&l[1]===t&&(i=!0)}return i||(e.push([r,t]),n||(n=!0,queueMicrotask(c))),Reflect.get(r,t,f)}function p(r){return r&&"object"==typeof r}function h(t){return function(e,n,o,u){var l=e[n];if(l===o)return!0;if(t&&p(o)&&!o[f]){if(p(l)&&!l[f])return y(u[a][n],o),!0;o=g(o,!0)}void 0!==o?Reflect.set(e,n,o,u):Reflect.deleteProperty(e,n);var c,v=r.get(e);if(!v)return!0;for(var s=(c=v[n]||[]).length-1;s>=0;s-=1){var h=c[s];if(h){var d=h[0],m=h[1],P=h[2];d[i]||b(d,m,P)}}return!0}}function y(r,t){var e=r[a];for(var n in t){var o=t[n],f=e[n];p(o)&&p(f)?y(f,o):r[n]=o}for(var n in e){e[n];t.hasOwnProperty(n)||delete r[n]}}function g(r,t){r||(r={});var e=new Proxy(r,t?l:u),n=r[Object.getOwnPropertySymbols(r)[0]];if(t)for(var o in r){var i=r[o];p(i)&&!i[f]&&(r[o]=g(i,!0))}return"function"==typeof n&&n.call(e),e}function b(n,f,i){e.push(o);var a=e.length-1,u=null,l=i.call(n),c=[];void 0!==l?n[f]=l:delete n[f],t.set(n,c);for(var s=e.length-1,p=a+1;p<=s&&e[p]!==o;p+=1)u=p;var h=a+1;for(p=u;p>=h;p-=1){var y=e[p],g=y[0],b=y[1],d=null;c.includes(g)||c.push(g),r.has(g)||r.set(g,{}),(d=r.get(g)).hasOwnProperty(b)||(d[b]=[]);var m=d[b],P=m.findIndex((function(r){return r[0]===n&&r[1]===f}));-1!==P&&m.splice(P,1),m.push([n,f,i])}return v(),l}function d(e){var n=t.get(e);if(n){for(var o=n.length,f=0;f=0;v-=1){c[v][0]===e&&c.splice(v,1)}}return e[i]=!0}}function m(r,t){return function(e){var n=e[r],o=e[t];return e[r]=function(){if(n&&n.call(this),!arguments.length)for(var r in e){var t=e[r];"function"==typeof t&&t.call(this)}},e[t]=function(){return o&&o.call(this),d(this)},Object.keys(e).forEach((function(r){var t=e[r];if("function"==typeof t){return e[r]=function(){var e=this[r];return e&&e.isEventListener?t.apply(this,arguments):b(this,r,t)}}})),e}}function P(r){return r[f]=!0,r}export{g as observable,g as createSource,m as createComputed,P as ref}; +var r=new WeakMap,t=new WeakMap,e=[],n=!1,o=Symbol("stackDelimiter"),f=Symbol("ref"),i=Symbol("hasUnmounted"),a=Symbol("proxyTarget"),u=function(){var r=p();return{get:s,set:r,deleteProperty:r}}(),c=function(){var r=p(!0);return{get:s,set:r,deleteProperty:r}}();function l(){for(;e.length;)e.pop();return n=!1}function v(){for(var r=e.length-1;r>=0&&e.pop()!==o;r-=1);}function s(r,t,f){if(t===a)return r;for(var i=!1,u=e.length-1;u>=0;u-=1){var c=e[u];if(c===o)break;c[0]===r&&c[1]===t&&(i=!0)}return i||(e.push([r,t]),n||(n=!0,queueMicrotask(l))),Reflect.get(r,t,f)}function h(r){return r&&"object"==typeof r}function p(t){return function(e,n,o,a){var u=e[n];if(u===o)return!0;if(t&&h(o)&&!o[f]){if(h(u)&&!u[f])return g(u,o),!0;o=y(o,!0)}void 0!==o?Reflect.set(e,n,o,a):Reflect.deleteProperty(e,n);var c,l=r.get(e);if(!l)return!0;for(var v=(c=l[n]||[]).length-1;v>=0;v-=1){var s=c[v];if(s){var p=s[0],d=s[1],m=s[2];p[i]||b(p,d,m)}}return!0}}function g(r,t){var e=r[a];for(var n in t){var o=t[n],i=e[n];h(o)&&h(i)&&!i[f]?g(i,o):r[n]=o}for(var n in e){e[n];Object.hasOwn(t,n)||delete r[n]}}function y(r,t){r||(r={});var e=new Proxy(r,t?c:u),n=r[Object.getOwnPropertySymbols(r)[0]];if(t)for(var o in r){var i=r[o];h(i)&&!i[f]&&(r[o]=y(i,!0))}return"function"==typeof n&&n.call(e),e}function b(n,f,i){e.push(o);var a=e.length-1,u=null,c=i.call(n),l=[];void 0!==c?n[f]=c:delete n[f],t.set(n,l);for(var s=e.length-1,h=a+1;h<=s&&e[h]!==o;h+=1)u=h;var p=a+1;for(h=u;h>=p;h-=1){var g=e[h],y=g[0],b=g[1],d=null;l.includes(y)||l.push(y),r.has(y)||r.set(y,{}),d=r.get(y),Object.hasOwn(d,b)||(d[b]=[]);var m=d[b],O=m.findIndex((function(r){return r[0]===n&&r[1]===f}));-1!==O&&m.splice(O,1),m.push([n,f,i])}return v(),c}function d(e){var n=t.get(e);if(n){for(var o=n.length,f=0;f=0;v-=1){l[v][0]===e&&l.splice(v,1)}}return e[i]=!0}}function m(r,t){return function(e){var n=e[r],o=e[t];return e[r]=function(){if(n&&n.call(this),!arguments.length)for(var r in e){var t=e[r];"function"==typeof t&&t.call(this)}},e[t]=function(){return o&&o.call(this),d(this)},Object.keys(e).forEach((function(r){var t=e[r];if("function"==typeof t){return e[r]=function(){var e=this[r];return e&&e.isEventListener?t.apply(this,arguments):b(this,r,t)}}})),e}}function O(r){return r[f]=!0,r}export{y as observable,y as createSource,m as createComputed,O as ref}; diff --git a/dist/computed-properties.mjs b/dist/computed-properties.mjs index 21574c0..e8a4df0 100644 --- a/dist/computed-properties.mjs +++ b/dist/computed-properties.mjs @@ -109,8 +109,7 @@ function isObject(obj) { (IF (AND (IS-OBJECT OLD-VALUE) (NOT (GETPROP OLD-VALUE *REF-SYMBOL*))) (PROGN - (DEEP-REPLACE - (GETPROP (GETPROP RECEIVER *PROXY-TARGET-SYMBOL*) KEY) VALUE) + (DEEP-REPLACE OLD-VALUE VALUE) (RETURN-FROM SET-PROPERTY T)) (SETF VALUE (CREATE-SOURCE VALUE T))))) (IF (NOT (EQ VALUE UNDEFINED)) @@ -138,7 +137,7 @@ function makeSetProperty(isDeep) { }; if (isDeep && isObject(value) && !value[REFSYMBOL]) { if (isObject(oldValue) && !oldValue[REFSYMBOL]) { - deepReplace(receiver[PROXYTARGETSYMBOL][key], value); + deepReplace(oldValue, value); return true; } else { @@ -180,27 +179,28 @@ function makeSetProperty(isDeep) { (LOOP FOR KEY OF OBJ DO (LET ((VALUE (GETPROP OBJ KEY)) (OLD-VALUE (GETPROP OLD-TARGET KEY))) - (IF (AND (IS-OBJECT VALUE) (IS-OBJECT OLD-VALUE)) + (IF (AND (IS-OBJECT VALUE) (IS-OBJECT OLD-VALUE) + (NOT (GETPROP OLD-VALUE *REF-SYMBOL*))) (DEEP-REPLACE OLD-VALUE VALUE) (SETF (GETPROP PROXY KEY) VALUE)))) (LOOP FOR KEY OF OLD-TARGET DO (LET ((OLD-VALUE (GETPROP OLD-TARGET KEY))) - (WHEN (NOT (CHAIN OBJ (HAS-OWN-PROPERTY KEY))) + (WHEN (NOT (CHAIN *OBJECT (HAS-OWN OBJ KEY))) (DELETE (GETPROP PROXY KEY))))))) */ function deepReplace(proxy, obj) { var oldTarget = proxy[PROXYTARGETSYMBOL]; for (var key in obj) { var value = obj[key]; var oldValue = oldTarget[key]; - if (isObject(value) && isObject(oldValue)) { + if (isObject(value) && isObject(oldValue) && !oldValue[REFSYMBOL]) { deepReplace(oldValue, value); } else { proxy[key] = value; }; }; for (var key in oldTarget) { - var oldValue1 = oldTarget[key]; - if (!obj.hasOwnProperty(key)) { + var oldValue5 = oldTarget[key]; + if (!Object.hasOwn(obj, key)) { delete proxy[key]; }; }; @@ -269,7 +269,7 @@ function createSource(obj, isDeep) { (CHAIN *OBSERVABLE-CONTEXT-MAP* (SET OBSERVABLE (CREATE)))) (SETF CONTEXT (CHAIN *OBSERVABLE-CONTEXT-MAP* (GET OBSERVABLE))) - (WHEN (NOT (CHAIN CONTEXT (HAS-OWN-PROPERTY OBSERVABLE-KEY))) + (WHEN (NOT (CHAIN *OBJECT (HAS-OWN CONTEXT OBSERVABLE-KEY))) (SETF (GETPROP CONTEXT OBSERVABLE-KEY) (LIST))) (LET* ((KEY-BINDINGS (GETPROP CONTEXT OBSERVABLE-KEY)) (MATCH-INDEX @@ -295,15 +295,15 @@ function computeDependencies(obj, key, fn) { delete obj[key]; }; TARGETOBSERVABLESMAP.set(obj, observables); - var _js1 = READSTACK.length - 1; - for (var i = delimiterIndex + 1; i <= _js1; i += 1) { + var _js5 = READSTACK.length - 1; + for (var i = delimiterIndex + 1; i <= _js5; i += 1) { if (READSTACK[i] === STACKDELIMITERSYMBOL) { break; }; upperIndex = i; }; - var _js2 = delimiterIndex + 1; - for (var i = upperIndex; i >= _js2; i -= 1) { + var _js6 = delimiterIndex + 1; + for (var i = upperIndex; i >= _js6; i -= 1) { var tuple = READSTACK[i]; var observable = tuple[0]; var observableKey = tuple[1]; @@ -315,7 +315,7 @@ function computeDependencies(obj, key, fn) { OBSERVABLECONTEXTMAP.set(observable, { }); }; context = OBSERVABLECONTEXTMAP.get(observable); - if (!context.hasOwnProperty(observableKey)) { + if (!Object.hasOwn(context, observableKey)) { context[observableKey] = []; }; var keyBindings = context[observableKey]; @@ -353,9 +353,9 @@ function unmountObject(obj) { if (!observables) { return; }; - var _js4 = observables.length; - for (var _js3 = 0; _js3 < _js4; _js3 += 1) { - var observable = observables[_js3]; + var _js8 = observables.length; + for (var _js7 = 0; _js7 < _js8; _js7 += 1) { + var observable = observables[_js7]; var context = OBSERVABLECONTEXTMAP.get(observable); for (var key in context) { var keyBindings = context[key]; diff --git a/dist/dep-check.mjs b/dist/dep-check.mjs index 39dc161..38632aa 100644 --- a/dist/dep-check.mjs +++ b/dist/dep-check.mjs @@ -52,15 +52,15 @@ function depCheck(root) { if (PASSEDCHECK) { return; }; - var _js2 = DEPMAP.length; - for (var _js1 = 0; _js1 < _js2; _js1 += 1) { - var tuple = DEPMAP[_js1]; + var _js6 = DEPMAP.length; + for (var _js5 = 0; _js5 < _js6; _js5 += 1) { + var tuple = DEPMAP[_js5]; var path = tuple[0]; var typeStr = tuple[1]; var target = root || window; if (typeStr === 'property') { - var _js3 = path.length - 2; - for (var i = 0; i <= _js3; i += 1) { + var _js7 = path.length - 2; + for (var i = 0; i <= _js7; i += 1) { var key = path[i]; if (target[key]) { target = target[key]; @@ -74,11 +74,11 @@ function depCheck(root) { }; continue; }; - var _js5 = path.length; - for (var _js4 = 0; _js4 < _js5; _js4 += 1) { - var key6 = path[_js4]; - if (target[key6]) { - target = target[key6]; + var _js9 = path.length; + for (var _js8 = 0; _js8 < _js9; _js8 += 1) { + var key10 = path[_js8]; + if (target[key10]) { + target = target[key10]; } else { target = undefined; break; diff --git a/dist/main.mjs b/dist/main.mjs index 43d110f..96f3fc2 100644 --- a/dist/main.mjs +++ b/dist/main.mjs @@ -264,8 +264,8 @@ function setIndex(target, key, value, receiver, isInitializing) { var isIndex = !Number.isNaN(numkey); var isSetter = value !== undefined; if (key === 'length') { - var _js1 = target.length - 1; - for (var i = value; i <= _js1; i += 1) { + var _js5 = target.length - 1; + for (var i = value; i <= _js5; i += 1) { var proxy = target[i]; var nodes = PROXYDELIMITERMAP.get(proxy); var unmount = PROXYUNMOUNTMAP.get(proxy); @@ -276,10 +276,10 @@ function setIndex(target, key, value, receiver, isInitializing) { }; }; if (!isSetter && target[key]) { - var proxy2 = target[key]; - var nodes3 = PROXYDELIMITERMAP.get(proxy2); - var unmount4 = PROXYUNMOUNTMAP.get(proxy2); - removeBetweenDelimiters(nodes3[0], nodes3[1], unmount4, proxy2); + var proxy6 = target[key]; + var nodes7 = PROXYDELIMITERMAP.get(proxy6); + var unmount8 = PROXYUNMOUNTMAP.get(proxy6); + removeBetweenDelimiters(nodes7[0], nodes7[1], unmount8, proxy6); delete target[key]; }; if (isSetter) { @@ -289,15 +289,15 @@ function setIndex(target, key, value, receiver, isInitializing) { }; if (!target.includes(value)) { var anchor = PROXYANCHORMAP.get(receiver); - var parentNode5 = anchor.parentNode; + var parentNode9 = anchor.parentNode; var template = PROXYTEMPLATEMAP.get(receiver); var result = createBinding(value, template, receiver[SYMBOLROOT]); - var proxy6 = result[0]; + var proxy10 = result[0]; var node = result[1]; var previousProxy = target[key]; var nextProxy = null; - var _js7 = target.length - 1; - for (var i = numkey + 1; i <= _js7; i += 1) { + var _js11 = target.length - 1; + for (var i = numkey + 1; i <= _js11; i += 1) { nextProxy = target[i]; if (nextProxy) { break; @@ -307,75 +307,75 @@ function setIndex(target, key, value, receiver, isInitializing) { if (!target.find(function (p, i) { return p === previousProxy && i !== numkey; })) { - var nodes8 = PROXYDELIMITERMAP.get(previousProxy); - var unmount9 = PROXYUNMOUNTMAP.get(previousProxy); - removeBetweenDelimiters(nodes8[0], nodes8[1], unmount9, proxy6); + var nodes12 = PROXYDELIMITERMAP.get(previousProxy); + var unmount13 = PROXYUNMOUNTMAP.get(previousProxy); + removeBetweenDelimiters(nodes12[0], nodes12[1], unmount13, proxy10); }; }; if (nextProxy) { var nextAnchor = PROXYDELIMITERMAP.get(nextProxy)[0]; - parentNode5.insertBefore(node, nextAnchor); + parentNode9.insertBefore(node, nextAnchor); } else { var endNode = PROXYDELIMITERMAP.get(receiver)[1]; - parentNode5.insertBefore(node, endNode); + parentNode9.insertBefore(node, endNode); }; - return Reflect.set(target, key, proxy6, receiver); + return Reflect.set(target, key, proxy10, receiver); } else { var otherIndex = target.findIndex(function (p, i) { return p === value && i !== numkey; }); var otherProxy = target[key]; var move = PROXYMOVEMAP.get(value); - var nodes10 = PROXYDELIMITERMAP.get(value); - var startNode = nodes10[0]; - var endNode11 = nodes10[1]; + var nodes14 = PROXYDELIMITERMAP.get(value); + var startNode = nodes14[0]; + var endNode15 = nodes14[1]; if (otherProxy) { var otherNodes = PROXYDELIMITERMAP.get(otherProxy); var otherStartNode = otherNodes[0]; var otherEndNode = otherNodes[1]; var otherMove = PROXYMOVEMAP.get(otherProxy); - var anchor12 = nodes10[1].nextSibling; - var parentNode13 = anchor12.parentNode; + var anchor16 = nodes14[1].nextSibling; + var parentNode17 = anchor16.parentNode; if (value !== otherProxy) { if (move) { - var node14 = startNode.nextSibling; - while (!node14.isSameNode(endNode11)) { - var oldNode = node14; - node14 = node14.nextSibling; + var node18 = startNode.nextSibling; + while (!node18.isSameNode(endNode15)) { + var oldNode = node18; + node18 = node18.nextSibling; move.call(value, oldNode); }; }; if (otherMove) { - var node15 = otherStartNode.nextSibling; - while (!node15.isSameNode(otherEndNode)) { - var oldNode16 = node15; - node15 = node15.nextSibling; - otherMove.call(otherProxy, oldNode16); + var node19 = otherStartNode.nextSibling; + while (!node19.isSameNode(otherEndNode)) { + var oldNode20 = node19; + node19 = node19.nextSibling; + otherMove.call(otherProxy, oldNode20); }; }; - var node16 = startNode; - while (!node16.isSameNode(endNode11)) { - var oldNode17 = node16; - node16 = node16.nextSibling; - parentNode13.insertBefore(oldNode17, otherStartNode); + var node20 = startNode; + while (!node20.isSameNode(endNode15)) { + var oldNode21 = node20; + node20 = node20.nextSibling; + parentNode17.insertBefore(oldNode21, otherStartNode); }; - parentNode13.insertBefore(endNode11, otherStartNode); - var node17 = otherStartNode; - while (!node17.isSameNode(otherEndNode)) { - var oldNode18 = node17; - node17 = node17.nextSibling; - parentNode13.insertBefore(oldNode18, anchor12); + parentNode17.insertBefore(endNode15, otherStartNode); + var node21 = otherStartNode; + while (!node21.isSameNode(otherEndNode)) { + var oldNode22 = node21; + node21 = node21.nextSibling; + parentNode17.insertBefore(oldNode22, anchor16); }; - parentNode13.insertBefore(otherEndNode, anchor12); + parentNode17.insertBefore(otherEndNode, anchor16); }; } else { if (move) { - var node18 = startNode.nextSibling; - while (!node18.isSameNode(endNode11)) { - var oldNode19 = node18; - node18 = node18.nextSibling; - move.call(value, oldNode19); + var node22 = startNode.nextSibling; + while (!node22.isSameNode(endNode15)) { + var oldNode23 = node22; + node22 = node22.nextSibling; + move.call(value, oldNode23); }; }; }; @@ -514,9 +514,9 @@ function setProperty(target, key, value, receiver, isInitializing) { var returnValue = null; var hasReturnValue = false; if (descriptors) { - var _js20 = descriptors.length; - for (var _js19 = 0; _js19 < _js20; _js19 += 1) { - var descriptor = descriptors[_js19]; + var _js24 = descriptors.length; + for (var _js23 = 0; _js23 < _js24; _js23 += 1) { + var descriptor = descriptors[_js23]; node = descriptor.node; type = descriptor.type; if (isChanged || isInitializing) { @@ -775,11 +775,11 @@ function setSlot(target, key, value, receiver, descriptor, isInitializing) { return; }; var anchor = descriptor.node; - var slot21 = descriptor.slot; - var template22 = descriptor.template; + var slot25 = descriptor.slot; + var template26 = descriptor.template; var hash = TARGETDELIMITERMAP.get(target); var nodes = hash[key]; - var parentNode23 = anchor.parentNode; + var parentNode27 = anchor.parentNode; var startNode = createAnchor(0, key); var endNode = createAnchor(1, key); var previousValue = target[key]; @@ -790,21 +790,21 @@ function setSlot(target, key, value, receiver, descriptor, isInitializing) { var returnValue = null; if (nodes && (!value || value && !previousValue || isTypeMismatch)) { if (Array.isArray(previousValue)) { - var _js25 = previousValue.length; - for (var _js24 = 0; _js24 < _js25; _js24 += 1) { - var proxy = previousValue[_js24]; + var _js29 = previousValue.length; + for (var _js28 = 0; _js28 < _js29; _js28 += 1) { + var proxy = previousValue[_js28]; var unmount = PROXYUNMOUNTMAP.get(proxy); - var nodes26 = PROXYDELIMITERMAP.get(proxy); - if (nodes26) { - removeBetweenDelimiters(nodes26[0], nodes26[1], unmount, proxy); + var nodes30 = PROXYDELIMITERMAP.get(proxy); + if (nodes30) { + removeBetweenDelimiters(nodes30[0], nodes30[1], unmount, proxy); }; }; } else { if (previousValue) { - var unmount26 = PROXYUNMOUNTMAP.get(previousValue); - var nodes27 = PROXYDELIMITERMAP.get(previousValue); - if (nodes27) { - removeBetweenDelimiters(nodes27[0], nodes27[1], unmount26, previousValue); + var unmount30 = PROXYUNMOUNTMAP.get(previousValue); + var nodes31 = PROXYDELIMITERMAP.get(previousValue); + if (nodes31) { + removeBetweenDelimiters(nodes31[0], nodes31[1], unmount30, previousValue); }; }; }; @@ -816,33 +816,33 @@ function setSlot(target, key, value, receiver, descriptor, isInitializing) { }; }; hash[key] = [startNode, endNode]; - parentNode23.insertBefore(startNode, anchor); + parentNode27.insertBefore(startNode, anchor); if (value) { if (!previousValue || !isPreviousObject || isTypeMismatch) { if (Array.isArray(value)) { - var result = createArray(value, template22, receiver[SYMBOLROOT]); - var nodes28 = result[0]; - var proxy29 = result[1]; - var _js31 = nodes28.length; - for (var _js30 = 0; _js30 < _js31; _js30 += 1) { - var node = nodes28[_js30]; - parentNode23.insertBefore(node, anchor); + var result = createArray(value, template26, receiver[SYMBOLROOT]); + var nodes32 = result[0]; + var proxy33 = result[1]; + var _js35 = nodes32.length; + for (var _js34 = 0; _js34 < _js35; _js34 += 1) { + var node = nodes32[_js34]; + parentNode27.insertBefore(node, anchor); }; - PROXYANCHORMAP.set(proxy29, anchor); - PROXYDELIMITERMAP.set(proxy29, hash[key]); - returnValue = proxy29; - } else { - var result32 = createBinding(value, template22, receiver[SYMBOLROOT]); - var proxy33 = result32[0]; - var node34 = result32[1]; - parentNode23.insertBefore(node34, anchor); + PROXYANCHORMAP.set(proxy33, anchor); + PROXYDELIMITERMAP.set(proxy33, hash[key]); returnValue = proxy33; + } else { + var result36 = createBinding(value, template26, receiver[SYMBOLROOT]); + var proxy37 = result36[0]; + var node38 = result36[1]; + parentNode27.insertBefore(node38, anchor); + returnValue = proxy37; }; } else { var previousValues = isPreviousArray ? previousValue : [previousValue]; var values = isValueArray ? value : [value]; - var _js35 = values.length - 1; - for (var i = 0; i <= _js35; i += 1) { + var _js39 = values.length - 1; + for (var i = 0; i <= _js39; i += 1) { var prev = previousValues[i]; var obj = values[i]; if (prev && obj) { @@ -864,14 +864,14 @@ function setSlot(target, key, value, receiver, descriptor, isInitializing) { returnValue = previousValue; }; } else { - var _js36 = slot21.childNodes; - var _js38 = _js36.length; - for (var _js37 = 0; _js37 < _js38; _js37 += 1) { - var node39 = _js36[_js37]; - parentNode23.insertBefore(node39.cloneNode(true), anchor); + var _js40 = slot25.childNodes; + var _js42 = _js40.length; + for (var _js41 = 0; _js41 < _js42; _js41 += 1) { + var node43 = _js40[_js41]; + parentNode27.insertBefore(node43.cloneNode(true), anchor); }; }; - parentNode23.insertBefore(endNode, anchor); + parentNode27.insertBefore(endNode, anchor); return returnValue; }; @@ -896,24 +896,24 @@ function setSlot(target, key, value, receiver, descriptor, isInitializing) { (@ BOUND-LISTENER OPTIONS))) (CHAIN LISTENERS (PUSH BOUND-LISTENER)))))) */ function setEvent(target, value, descriptor, receiver) { - var node39 = descriptor.node; - var event40 = descriptor.event; + var node43 = descriptor.node; + var event44 = descriptor.event; var hash = TARGETEVENTMAP.get(target); - var listeners = hash[event40]; + var listeners = hash[event44]; if (!listeners) { listeners = []; - hash[event40] = listeners; + hash[event44] = listeners; }; - var _js42 = listeners.length; - for (var _js41 = 0; _js41 < _js42; _js41 += 1) { - var listener = listeners[_js41]; - node39.removeEventListener(event40, listener, listener.options); + var _js46 = listeners.length; + for (var _js45 = 0; _js45 < _js46; _js45 += 1) { + var listener = listeners[_js45]; + node43.removeEventListener(event44, listener, listener.options); }; if (value) { value.isEventListener = true; var boundListener = value.bind(receiver); boundListener.options = value.options; - node39.addEventListener(event40, boundListener, boundListener.options); + node43.addEventListener(event44, boundListener, boundListener.options); return listeners.push(boundListener); }; }; @@ -1041,8 +1041,8 @@ function processTemplate(template) { var clone = root.cloneNode(true); var context = { }; function walk(parentNode, path) { - var _js43 = parentNode.childNodes.length - 1; - for (var i = 0; i <= _js43; i += 1) { + var _js47 = parentNode.childNodes.length - 1; + for (var i = 0; i <= _js47; i += 1) { var node = parentNode.childNodes[i]; if (node.nodeType !== main.window.Node['ELEMENT_NODE']) { continue; @@ -1153,12 +1153,12 @@ function createContext(clone, template) { var clonedContext = { }; for (var key in context) { clonedContext[key] = []; - var _js44 = context[key]; - var _js46 = _js44.length; - for (var _js45 = 0; _js45 < _js46; _js45 += 1) { - var descriptor = _js44[_js45]; - var path47 = descriptor.path; - var node = getPath(clone, path47); + var _js48 = context[key]; + var _js50 = _js48.length; + for (var _js49 = 0; _js49 < _js50; _js49 += 1) { + var descriptor = _js48[_js49]; + var path51 = descriptor.path; + var node = getPath(clone, path51); clonedContext[key].push(Object.assign({ node : node }, descriptor)); }; }; @@ -1173,8 +1173,8 @@ function createContext(clone, template) { RESULT)) */ function getPath(node, path) { var result = node; - var _js44 = path.length - 1; - for (var i = 0; i <= _js44; i += 1) { + var _js48 = path.length - 1; + for (var i = 0; i <= _js48; i += 1) { var j = path[i]; result = result.childNodes[j]; }; @@ -1194,9 +1194,9 @@ function createArray(array, template, root) { var nodes = []; var proxies = []; var proxy = null; - var _js46 = array.length; - for (var _js45 = 0; _js45 < _js46; _js45 += 1) { - var item = array[_js45]; + var _js50 = array.length; + for (var _js49 = 0; _js49 < _js50; _js49 += 1) { + var item = array[_js49]; var result = createBinding(item, template, root); proxies.push(result[0]); nodes.push(result[1]); @@ -1371,13 +1371,13 @@ function observeUnmount(bindings) { var fragment = bindings[1]; var fragmentNodes = Array.from(fragment.childNodes); var observeFn = function (mutations, observer) { - var _js48 = mutations.length; - for (var _js47 = 0; _js47 < _js48; _js47 += 1) { - var mutation = mutations[_js47]; - var _js49 = mutation.removedNodes; - var _js51 = _js49.length; - for (var _js50 = 0; _js50 < _js51; _js50 += 1) { - var node = _js49[_js50]; + var _js52 = mutations.length; + for (var _js51 = 0; _js51 < _js52; _js51 += 1) { + var mutation = mutations[_js51]; + var _js53 = mutation.removedNodes; + var _js55 = _js53.length; + for (var _js54 = 0; _js54 < _js55; _js54 += 1) { + var node = _js53[_js54]; for (var i = fragmentNodes.length - 1; i >= 0; i -= 1) { var fragmentNode = fragmentNodes[i]; if (node.contains(fragmentNode)) { diff --git a/dist/mustache.mjs b/dist/mustache.mjs index b40242f..8b55063 100644 --- a/dist/mustache.mjs +++ b/dist/mustache.mjs @@ -193,27 +193,27 @@ function createMustacheTag(registerTemplate) { var args = Array.prototype.slice.call(arguments, 1).map(function (element) { return TEMPLATEHASHMAP.get(element); }); - var element1 = null; + var element5 = null; var hash = null; - var _js3 = args.length; - var _js4 = strs.length; - var FIRST5 = true; - for (var _js2 = 0; _js2 < _js3; _js2 += 1) { - var hash6 = args[_js2]; - var i = FIRST5 ? 1 : i + 1; - if (i > _js4) { + var _js7 = args.length; + var _js8 = strs.length; + var FIRST9 = true; + for (var _js6 = 0; _js6 < _js7; _js6 += 1) { + var hash10 = args[_js6]; + var i = FIRST9 ? 1 : i + 1; + if (i > _js8) { break; }; - result.push(hash6 ? '{{>' + hash6 + '}}' : arguments[i], strs[i]); - FIRST5 = null; + result.push(hash10 ? '{{>' + hash10 + '}}' : arguments[i], strs[i]); + FIRST9 = null; }; result = result.join(''); - element1 = parseMustache(result); + element5 = parseMustache(result); hash = 'template' + hashStr(result); - TEMPLATEHASHMAP.set(element1, hash); - registerTemplate(hash, element1); + TEMPLATEHASHMAP.set(element5, hash); + registerTemplate(hash, element5); - return element1; + return element5; }; return taggedMustache; }; diff --git a/docs/computed-properties.mjs b/docs/computed-properties.mjs index 21574c0..e8a4df0 100644 --- a/docs/computed-properties.mjs +++ b/docs/computed-properties.mjs @@ -109,8 +109,7 @@ function isObject(obj) { (IF (AND (IS-OBJECT OLD-VALUE) (NOT (GETPROP OLD-VALUE *REF-SYMBOL*))) (PROGN - (DEEP-REPLACE - (GETPROP (GETPROP RECEIVER *PROXY-TARGET-SYMBOL*) KEY) VALUE) + (DEEP-REPLACE OLD-VALUE VALUE) (RETURN-FROM SET-PROPERTY T)) (SETF VALUE (CREATE-SOURCE VALUE T))))) (IF (NOT (EQ VALUE UNDEFINED)) @@ -138,7 +137,7 @@ function makeSetProperty(isDeep) { }; if (isDeep && isObject(value) && !value[REFSYMBOL]) { if (isObject(oldValue) && !oldValue[REFSYMBOL]) { - deepReplace(receiver[PROXYTARGETSYMBOL][key], value); + deepReplace(oldValue, value); return true; } else { @@ -180,27 +179,28 @@ function makeSetProperty(isDeep) { (LOOP FOR KEY OF OBJ DO (LET ((VALUE (GETPROP OBJ KEY)) (OLD-VALUE (GETPROP OLD-TARGET KEY))) - (IF (AND (IS-OBJECT VALUE) (IS-OBJECT OLD-VALUE)) + (IF (AND (IS-OBJECT VALUE) (IS-OBJECT OLD-VALUE) + (NOT (GETPROP OLD-VALUE *REF-SYMBOL*))) (DEEP-REPLACE OLD-VALUE VALUE) (SETF (GETPROP PROXY KEY) VALUE)))) (LOOP FOR KEY OF OLD-TARGET DO (LET ((OLD-VALUE (GETPROP OLD-TARGET KEY))) - (WHEN (NOT (CHAIN OBJ (HAS-OWN-PROPERTY KEY))) + (WHEN (NOT (CHAIN *OBJECT (HAS-OWN OBJ KEY))) (DELETE (GETPROP PROXY KEY))))))) */ function deepReplace(proxy, obj) { var oldTarget = proxy[PROXYTARGETSYMBOL]; for (var key in obj) { var value = obj[key]; var oldValue = oldTarget[key]; - if (isObject(value) && isObject(oldValue)) { + if (isObject(value) && isObject(oldValue) && !oldValue[REFSYMBOL]) { deepReplace(oldValue, value); } else { proxy[key] = value; }; }; for (var key in oldTarget) { - var oldValue1 = oldTarget[key]; - if (!obj.hasOwnProperty(key)) { + var oldValue5 = oldTarget[key]; + if (!Object.hasOwn(obj, key)) { delete proxy[key]; }; }; @@ -269,7 +269,7 @@ function createSource(obj, isDeep) { (CHAIN *OBSERVABLE-CONTEXT-MAP* (SET OBSERVABLE (CREATE)))) (SETF CONTEXT (CHAIN *OBSERVABLE-CONTEXT-MAP* (GET OBSERVABLE))) - (WHEN (NOT (CHAIN CONTEXT (HAS-OWN-PROPERTY OBSERVABLE-KEY))) + (WHEN (NOT (CHAIN *OBJECT (HAS-OWN CONTEXT OBSERVABLE-KEY))) (SETF (GETPROP CONTEXT OBSERVABLE-KEY) (LIST))) (LET* ((KEY-BINDINGS (GETPROP CONTEXT OBSERVABLE-KEY)) (MATCH-INDEX @@ -295,15 +295,15 @@ function computeDependencies(obj, key, fn) { delete obj[key]; }; TARGETOBSERVABLESMAP.set(obj, observables); - var _js1 = READSTACK.length - 1; - for (var i = delimiterIndex + 1; i <= _js1; i += 1) { + var _js5 = READSTACK.length - 1; + for (var i = delimiterIndex + 1; i <= _js5; i += 1) { if (READSTACK[i] === STACKDELIMITERSYMBOL) { break; }; upperIndex = i; }; - var _js2 = delimiterIndex + 1; - for (var i = upperIndex; i >= _js2; i -= 1) { + var _js6 = delimiterIndex + 1; + for (var i = upperIndex; i >= _js6; i -= 1) { var tuple = READSTACK[i]; var observable = tuple[0]; var observableKey = tuple[1]; @@ -315,7 +315,7 @@ function computeDependencies(obj, key, fn) { OBSERVABLECONTEXTMAP.set(observable, { }); }; context = OBSERVABLECONTEXTMAP.get(observable); - if (!context.hasOwnProperty(observableKey)) { + if (!Object.hasOwn(context, observableKey)) { context[observableKey] = []; }; var keyBindings = context[observableKey]; @@ -353,9 +353,9 @@ function unmountObject(obj) { if (!observables) { return; }; - var _js4 = observables.length; - for (var _js3 = 0; _js3 < _js4; _js3 += 1) { - var observable = observables[_js3]; + var _js8 = observables.length; + for (var _js7 = 0; _js7 < _js8; _js7 += 1) { + var observable = observables[_js7]; var context = OBSERVABLECONTEXTMAP.get(observable); for (var key in context) { var keyBindings = context[key]; diff --git a/docs/dep-check.mjs b/docs/dep-check.mjs index 39dc161..38632aa 100644 --- a/docs/dep-check.mjs +++ b/docs/dep-check.mjs @@ -52,15 +52,15 @@ function depCheck(root) { if (PASSEDCHECK) { return; }; - var _js2 = DEPMAP.length; - for (var _js1 = 0; _js1 < _js2; _js1 += 1) { - var tuple = DEPMAP[_js1]; + var _js6 = DEPMAP.length; + for (var _js5 = 0; _js5 < _js6; _js5 += 1) { + var tuple = DEPMAP[_js5]; var path = tuple[0]; var typeStr = tuple[1]; var target = root || window; if (typeStr === 'property') { - var _js3 = path.length - 2; - for (var i = 0; i <= _js3; i += 1) { + var _js7 = path.length - 2; + for (var i = 0; i <= _js7; i += 1) { var key = path[i]; if (target[key]) { target = target[key]; @@ -74,11 +74,11 @@ function depCheck(root) { }; continue; }; - var _js5 = path.length; - for (var _js4 = 0; _js4 < _js5; _js4 += 1) { - var key6 = path[_js4]; - if (target[key6]) { - target = target[key6]; + var _js9 = path.length; + for (var _js8 = 0; _js8 < _js9; _js8 += 1) { + var key10 = path[_js8]; + if (target[key10]) { + target = target[key10]; } else { target = undefined; break; diff --git a/docs/main.mjs b/docs/main.mjs index 43d110f..96f3fc2 100644 --- a/docs/main.mjs +++ b/docs/main.mjs @@ -264,8 +264,8 @@ function setIndex(target, key, value, receiver, isInitializing) { var isIndex = !Number.isNaN(numkey); var isSetter = value !== undefined; if (key === 'length') { - var _js1 = target.length - 1; - for (var i = value; i <= _js1; i += 1) { + var _js5 = target.length - 1; + for (var i = value; i <= _js5; i += 1) { var proxy = target[i]; var nodes = PROXYDELIMITERMAP.get(proxy); var unmount = PROXYUNMOUNTMAP.get(proxy); @@ -276,10 +276,10 @@ function setIndex(target, key, value, receiver, isInitializing) { }; }; if (!isSetter && target[key]) { - var proxy2 = target[key]; - var nodes3 = PROXYDELIMITERMAP.get(proxy2); - var unmount4 = PROXYUNMOUNTMAP.get(proxy2); - removeBetweenDelimiters(nodes3[0], nodes3[1], unmount4, proxy2); + var proxy6 = target[key]; + var nodes7 = PROXYDELIMITERMAP.get(proxy6); + var unmount8 = PROXYUNMOUNTMAP.get(proxy6); + removeBetweenDelimiters(nodes7[0], nodes7[1], unmount8, proxy6); delete target[key]; }; if (isSetter) { @@ -289,15 +289,15 @@ function setIndex(target, key, value, receiver, isInitializing) { }; if (!target.includes(value)) { var anchor = PROXYANCHORMAP.get(receiver); - var parentNode5 = anchor.parentNode; + var parentNode9 = anchor.parentNode; var template = PROXYTEMPLATEMAP.get(receiver); var result = createBinding(value, template, receiver[SYMBOLROOT]); - var proxy6 = result[0]; + var proxy10 = result[0]; var node = result[1]; var previousProxy = target[key]; var nextProxy = null; - var _js7 = target.length - 1; - for (var i = numkey + 1; i <= _js7; i += 1) { + var _js11 = target.length - 1; + for (var i = numkey + 1; i <= _js11; i += 1) { nextProxy = target[i]; if (nextProxy) { break; @@ -307,75 +307,75 @@ function setIndex(target, key, value, receiver, isInitializing) { if (!target.find(function (p, i) { return p === previousProxy && i !== numkey; })) { - var nodes8 = PROXYDELIMITERMAP.get(previousProxy); - var unmount9 = PROXYUNMOUNTMAP.get(previousProxy); - removeBetweenDelimiters(nodes8[0], nodes8[1], unmount9, proxy6); + var nodes12 = PROXYDELIMITERMAP.get(previousProxy); + var unmount13 = PROXYUNMOUNTMAP.get(previousProxy); + removeBetweenDelimiters(nodes12[0], nodes12[1], unmount13, proxy10); }; }; if (nextProxy) { var nextAnchor = PROXYDELIMITERMAP.get(nextProxy)[0]; - parentNode5.insertBefore(node, nextAnchor); + parentNode9.insertBefore(node, nextAnchor); } else { var endNode = PROXYDELIMITERMAP.get(receiver)[1]; - parentNode5.insertBefore(node, endNode); + parentNode9.insertBefore(node, endNode); }; - return Reflect.set(target, key, proxy6, receiver); + return Reflect.set(target, key, proxy10, receiver); } else { var otherIndex = target.findIndex(function (p, i) { return p === value && i !== numkey; }); var otherProxy = target[key]; var move = PROXYMOVEMAP.get(value); - var nodes10 = PROXYDELIMITERMAP.get(value); - var startNode = nodes10[0]; - var endNode11 = nodes10[1]; + var nodes14 = PROXYDELIMITERMAP.get(value); + var startNode = nodes14[0]; + var endNode15 = nodes14[1]; if (otherProxy) { var otherNodes = PROXYDELIMITERMAP.get(otherProxy); var otherStartNode = otherNodes[0]; var otherEndNode = otherNodes[1]; var otherMove = PROXYMOVEMAP.get(otherProxy); - var anchor12 = nodes10[1].nextSibling; - var parentNode13 = anchor12.parentNode; + var anchor16 = nodes14[1].nextSibling; + var parentNode17 = anchor16.parentNode; if (value !== otherProxy) { if (move) { - var node14 = startNode.nextSibling; - while (!node14.isSameNode(endNode11)) { - var oldNode = node14; - node14 = node14.nextSibling; + var node18 = startNode.nextSibling; + while (!node18.isSameNode(endNode15)) { + var oldNode = node18; + node18 = node18.nextSibling; move.call(value, oldNode); }; }; if (otherMove) { - var node15 = otherStartNode.nextSibling; - while (!node15.isSameNode(otherEndNode)) { - var oldNode16 = node15; - node15 = node15.nextSibling; - otherMove.call(otherProxy, oldNode16); + var node19 = otherStartNode.nextSibling; + while (!node19.isSameNode(otherEndNode)) { + var oldNode20 = node19; + node19 = node19.nextSibling; + otherMove.call(otherProxy, oldNode20); }; }; - var node16 = startNode; - while (!node16.isSameNode(endNode11)) { - var oldNode17 = node16; - node16 = node16.nextSibling; - parentNode13.insertBefore(oldNode17, otherStartNode); + var node20 = startNode; + while (!node20.isSameNode(endNode15)) { + var oldNode21 = node20; + node20 = node20.nextSibling; + parentNode17.insertBefore(oldNode21, otherStartNode); }; - parentNode13.insertBefore(endNode11, otherStartNode); - var node17 = otherStartNode; - while (!node17.isSameNode(otherEndNode)) { - var oldNode18 = node17; - node17 = node17.nextSibling; - parentNode13.insertBefore(oldNode18, anchor12); + parentNode17.insertBefore(endNode15, otherStartNode); + var node21 = otherStartNode; + while (!node21.isSameNode(otherEndNode)) { + var oldNode22 = node21; + node21 = node21.nextSibling; + parentNode17.insertBefore(oldNode22, anchor16); }; - parentNode13.insertBefore(otherEndNode, anchor12); + parentNode17.insertBefore(otherEndNode, anchor16); }; } else { if (move) { - var node18 = startNode.nextSibling; - while (!node18.isSameNode(endNode11)) { - var oldNode19 = node18; - node18 = node18.nextSibling; - move.call(value, oldNode19); + var node22 = startNode.nextSibling; + while (!node22.isSameNode(endNode15)) { + var oldNode23 = node22; + node22 = node22.nextSibling; + move.call(value, oldNode23); }; }; }; @@ -514,9 +514,9 @@ function setProperty(target, key, value, receiver, isInitializing) { var returnValue = null; var hasReturnValue = false; if (descriptors) { - var _js20 = descriptors.length; - for (var _js19 = 0; _js19 < _js20; _js19 += 1) { - var descriptor = descriptors[_js19]; + var _js24 = descriptors.length; + for (var _js23 = 0; _js23 < _js24; _js23 += 1) { + var descriptor = descriptors[_js23]; node = descriptor.node; type = descriptor.type; if (isChanged || isInitializing) { @@ -775,11 +775,11 @@ function setSlot(target, key, value, receiver, descriptor, isInitializing) { return; }; var anchor = descriptor.node; - var slot21 = descriptor.slot; - var template22 = descriptor.template; + var slot25 = descriptor.slot; + var template26 = descriptor.template; var hash = TARGETDELIMITERMAP.get(target); var nodes = hash[key]; - var parentNode23 = anchor.parentNode; + var parentNode27 = anchor.parentNode; var startNode = createAnchor(0, key); var endNode = createAnchor(1, key); var previousValue = target[key]; @@ -790,21 +790,21 @@ function setSlot(target, key, value, receiver, descriptor, isInitializing) { var returnValue = null; if (nodes && (!value || value && !previousValue || isTypeMismatch)) { if (Array.isArray(previousValue)) { - var _js25 = previousValue.length; - for (var _js24 = 0; _js24 < _js25; _js24 += 1) { - var proxy = previousValue[_js24]; + var _js29 = previousValue.length; + for (var _js28 = 0; _js28 < _js29; _js28 += 1) { + var proxy = previousValue[_js28]; var unmount = PROXYUNMOUNTMAP.get(proxy); - var nodes26 = PROXYDELIMITERMAP.get(proxy); - if (nodes26) { - removeBetweenDelimiters(nodes26[0], nodes26[1], unmount, proxy); + var nodes30 = PROXYDELIMITERMAP.get(proxy); + if (nodes30) { + removeBetweenDelimiters(nodes30[0], nodes30[1], unmount, proxy); }; }; } else { if (previousValue) { - var unmount26 = PROXYUNMOUNTMAP.get(previousValue); - var nodes27 = PROXYDELIMITERMAP.get(previousValue); - if (nodes27) { - removeBetweenDelimiters(nodes27[0], nodes27[1], unmount26, previousValue); + var unmount30 = PROXYUNMOUNTMAP.get(previousValue); + var nodes31 = PROXYDELIMITERMAP.get(previousValue); + if (nodes31) { + removeBetweenDelimiters(nodes31[0], nodes31[1], unmount30, previousValue); }; }; }; @@ -816,33 +816,33 @@ function setSlot(target, key, value, receiver, descriptor, isInitializing) { }; }; hash[key] = [startNode, endNode]; - parentNode23.insertBefore(startNode, anchor); + parentNode27.insertBefore(startNode, anchor); if (value) { if (!previousValue || !isPreviousObject || isTypeMismatch) { if (Array.isArray(value)) { - var result = createArray(value, template22, receiver[SYMBOLROOT]); - var nodes28 = result[0]; - var proxy29 = result[1]; - var _js31 = nodes28.length; - for (var _js30 = 0; _js30 < _js31; _js30 += 1) { - var node = nodes28[_js30]; - parentNode23.insertBefore(node, anchor); + var result = createArray(value, template26, receiver[SYMBOLROOT]); + var nodes32 = result[0]; + var proxy33 = result[1]; + var _js35 = nodes32.length; + for (var _js34 = 0; _js34 < _js35; _js34 += 1) { + var node = nodes32[_js34]; + parentNode27.insertBefore(node, anchor); }; - PROXYANCHORMAP.set(proxy29, anchor); - PROXYDELIMITERMAP.set(proxy29, hash[key]); - returnValue = proxy29; - } else { - var result32 = createBinding(value, template22, receiver[SYMBOLROOT]); - var proxy33 = result32[0]; - var node34 = result32[1]; - parentNode23.insertBefore(node34, anchor); + PROXYANCHORMAP.set(proxy33, anchor); + PROXYDELIMITERMAP.set(proxy33, hash[key]); returnValue = proxy33; + } else { + var result36 = createBinding(value, template26, receiver[SYMBOLROOT]); + var proxy37 = result36[0]; + var node38 = result36[1]; + parentNode27.insertBefore(node38, anchor); + returnValue = proxy37; }; } else { var previousValues = isPreviousArray ? previousValue : [previousValue]; var values = isValueArray ? value : [value]; - var _js35 = values.length - 1; - for (var i = 0; i <= _js35; i += 1) { + var _js39 = values.length - 1; + for (var i = 0; i <= _js39; i += 1) { var prev = previousValues[i]; var obj = values[i]; if (prev && obj) { @@ -864,14 +864,14 @@ function setSlot(target, key, value, receiver, descriptor, isInitializing) { returnValue = previousValue; }; } else { - var _js36 = slot21.childNodes; - var _js38 = _js36.length; - for (var _js37 = 0; _js37 < _js38; _js37 += 1) { - var node39 = _js36[_js37]; - parentNode23.insertBefore(node39.cloneNode(true), anchor); + var _js40 = slot25.childNodes; + var _js42 = _js40.length; + for (var _js41 = 0; _js41 < _js42; _js41 += 1) { + var node43 = _js40[_js41]; + parentNode27.insertBefore(node43.cloneNode(true), anchor); }; }; - parentNode23.insertBefore(endNode, anchor); + parentNode27.insertBefore(endNode, anchor); return returnValue; }; @@ -896,24 +896,24 @@ function setSlot(target, key, value, receiver, descriptor, isInitializing) { (@ BOUND-LISTENER OPTIONS))) (CHAIN LISTENERS (PUSH BOUND-LISTENER)))))) */ function setEvent(target, value, descriptor, receiver) { - var node39 = descriptor.node; - var event40 = descriptor.event; + var node43 = descriptor.node; + var event44 = descriptor.event; var hash = TARGETEVENTMAP.get(target); - var listeners = hash[event40]; + var listeners = hash[event44]; if (!listeners) { listeners = []; - hash[event40] = listeners; + hash[event44] = listeners; }; - var _js42 = listeners.length; - for (var _js41 = 0; _js41 < _js42; _js41 += 1) { - var listener = listeners[_js41]; - node39.removeEventListener(event40, listener, listener.options); + var _js46 = listeners.length; + for (var _js45 = 0; _js45 < _js46; _js45 += 1) { + var listener = listeners[_js45]; + node43.removeEventListener(event44, listener, listener.options); }; if (value) { value.isEventListener = true; var boundListener = value.bind(receiver); boundListener.options = value.options; - node39.addEventListener(event40, boundListener, boundListener.options); + node43.addEventListener(event44, boundListener, boundListener.options); return listeners.push(boundListener); }; }; @@ -1041,8 +1041,8 @@ function processTemplate(template) { var clone = root.cloneNode(true); var context = { }; function walk(parentNode, path) { - var _js43 = parentNode.childNodes.length - 1; - for (var i = 0; i <= _js43; i += 1) { + var _js47 = parentNode.childNodes.length - 1; + for (var i = 0; i <= _js47; i += 1) { var node = parentNode.childNodes[i]; if (node.nodeType !== main.window.Node['ELEMENT_NODE']) { continue; @@ -1153,12 +1153,12 @@ function createContext(clone, template) { var clonedContext = { }; for (var key in context) { clonedContext[key] = []; - var _js44 = context[key]; - var _js46 = _js44.length; - for (var _js45 = 0; _js45 < _js46; _js45 += 1) { - var descriptor = _js44[_js45]; - var path47 = descriptor.path; - var node = getPath(clone, path47); + var _js48 = context[key]; + var _js50 = _js48.length; + for (var _js49 = 0; _js49 < _js50; _js49 += 1) { + var descriptor = _js48[_js49]; + var path51 = descriptor.path; + var node = getPath(clone, path51); clonedContext[key].push(Object.assign({ node : node }, descriptor)); }; }; @@ -1173,8 +1173,8 @@ function createContext(clone, template) { RESULT)) */ function getPath(node, path) { var result = node; - var _js44 = path.length - 1; - for (var i = 0; i <= _js44; i += 1) { + var _js48 = path.length - 1; + for (var i = 0; i <= _js48; i += 1) { var j = path[i]; result = result.childNodes[j]; }; @@ -1194,9 +1194,9 @@ function createArray(array, template, root) { var nodes = []; var proxies = []; var proxy = null; - var _js46 = array.length; - for (var _js45 = 0; _js45 < _js46; _js45 += 1) { - var item = array[_js45]; + var _js50 = array.length; + for (var _js49 = 0; _js49 < _js50; _js49 += 1) { + var item = array[_js49]; var result = createBinding(item, template, root); proxies.push(result[0]); nodes.push(result[1]); @@ -1371,13 +1371,13 @@ function observeUnmount(bindings) { var fragment = bindings[1]; var fragmentNodes = Array.from(fragment.childNodes); var observeFn = function (mutations, observer) { - var _js48 = mutations.length; - for (var _js47 = 0; _js47 < _js48; _js47 += 1) { - var mutation = mutations[_js47]; - var _js49 = mutation.removedNodes; - var _js51 = _js49.length; - for (var _js50 = 0; _js50 < _js51; _js50 += 1) { - var node = _js49[_js50]; + var _js52 = mutations.length; + for (var _js51 = 0; _js51 < _js52; _js51 += 1) { + var mutation = mutations[_js51]; + var _js53 = mutation.removedNodes; + var _js55 = _js53.length; + for (var _js54 = 0; _js54 < _js55; _js54 += 1) { + var node = _js53[_js54]; for (var i = fragmentNodes.length - 1; i >= 0; i -= 1) { var fragmentNode = fragmentNodes[i]; if (node.contains(fragmentNode)) { diff --git a/docs/mustache.mjs b/docs/mustache.mjs index b40242f..8b55063 100644 --- a/docs/mustache.mjs +++ b/docs/mustache.mjs @@ -193,27 +193,27 @@ function createMustacheTag(registerTemplate) { var args = Array.prototype.slice.call(arguments, 1).map(function (element) { return TEMPLATEHASHMAP.get(element); }); - var element1 = null; + var element5 = null; var hash = null; - var _js3 = args.length; - var _js4 = strs.length; - var FIRST5 = true; - for (var _js2 = 0; _js2 < _js3; _js2 += 1) { - var hash6 = args[_js2]; - var i = FIRST5 ? 1 : i + 1; - if (i > _js4) { + var _js7 = args.length; + var _js8 = strs.length; + var FIRST9 = true; + for (var _js6 = 0; _js6 < _js7; _js6 += 1) { + var hash10 = args[_js6]; + var i = FIRST9 ? 1 : i + 1; + if (i > _js8) { break; }; - result.push(hash6 ? '{{>' + hash6 + '}}' : arguments[i], strs[i]); - FIRST5 = null; + result.push(hash10 ? '{{>' + hash10 + '}}' : arguments[i], strs[i]); + FIRST9 = null; }; result = result.join(''); - element1 = parseMustache(result); + element5 = parseMustache(result); hash = 'template' + hashStr(result); - TEMPLATEHASHMAP.set(element1, hash); - registerTemplate(hash, element1); + TEMPLATEHASHMAP.set(element5, hash); + registerTemplate(hash, element5); - return element1; + return element5; }; return taggedMustache; }; diff --git a/package.json b/package.json index a04ec53..4554322 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "s2-engine", - "version": "1.0.6", + "version": "1.0.7", "description": "A function for reactive web UI.", "main": "api.mjs", "types": "api.d.ts", diff --git a/src/computed-properties.lisp b/src/computed-properties.lisp index 1f8f50f..01cfe31 100644 --- a/src/computed-properties.lisp +++ b/src/computed-properties.lisp @@ -75,8 +75,7 @@ (when (and is-deep (is-object value) (not (getprop value *ref-symbol*))) (if (and (is-object old-value) (not (getprop old-value *ref-symbol*))) (progn - (deep-replace - (getprop (getprop receiver *proxy-target-symbol*) key) value) + (deep-replace old-value value) (return-from set-property t)) (setf value (create-source value t))))) @@ -108,13 +107,14 @@ for key of obj do (let ((value (getprop obj key)) (old-value (getprop old-target key))) - (if (and (is-object value) (is-object old-value)) + (if (and (is-object value) (is-object old-value) + (not (getprop old-value *ref-symbol*))) (deep-replace old-value value) (setf (getprop proxy key) value)))) (loop for key of old-target do (let ((old-value (getprop old-target key))) - (when (not (chain obj (has-own-property key))) + (when (not (chain *object (has-own obj key))) (delete (getprop proxy key))))))) @@ -172,7 +172,7 @@ (chain *observable-context-map* (set observable (create)))) (setf context (chain *observable-context-map* (get observable))) - (when (not (chain context (has-own-property observable-key))) + (when (not (chain *object (has-own context observable-key))) (setf (getprop context observable-key) (list))) (let* ((key-bindings (getprop context observable-key))