Comparing version 0.0.6 to 0.0.7
@@ -387,2 +387,3 @@ //============================================================================= | ||
while (potentialSoftMatch != null) { | ||
if (getIdIntersectionCount(ctx, potentialSoftMatch, newContent) > 0) { | ||
@@ -392,17 +393,24 @@ // the current potential soft match has a potential id set match with the remaining new | ||
return null; | ||
} else if (isSoftMatch(newChild, potentialSoftMatch)) { | ||
} | ||
// if we have a soft match with the current node, return it | ||
if (isSoftMatch(newChild, potentialSoftMatch)) { | ||
return potentialSoftMatch; | ||
} else if (isSoftMatch(nextSibling, potentialSoftMatch)) { | ||
} | ||
if (isSoftMatch(nextSibling, potentialSoftMatch)) { | ||
// the next new node has a soft match with this node, so | ||
// increment | ||
// increment the count of future soft matches | ||
siblingSoftMatchCount++; | ||
nextSibling = nextSibling.nextSibling; | ||
// If there are two future soft matches, bail to allow the siblings to soft match | ||
// so that we don't consume future soft matches for the sake of the current node | ||
if (siblingSoftMatchCount >= 2) { | ||
// with two soft matches, bail to allow the siblings to soft match | ||
return null; | ||
} | ||
nextSibling = nextSibling.nextSibling; | ||
} else { | ||
// advanced to the next old content child | ||
potentialSoftMatch = potentialSoftMatch.nextSibling; | ||
} | ||
// advanced to the next old content child | ||
potentialSoftMatch = potentialSoftMatch.nextSibling; | ||
} | ||
@@ -409,0 +417,0 @@ |
@@ -1,1 +0,1 @@ | ||
(function(e,t){if(typeof define==="function"&&define.amd){define([],t)}else{e.Idiomorph=e.Idiomorph||t()}})(typeof self!=="undefined"?self:this,function(){return function(){"use strict";let o=new Set;function e(r,e,t={}){if(typeof e==="string"){e=h(e)}let i=m(e);let o=n(r,i,t);if(t.morphStyle==="innerHTML"){l(i,r,o);return r.children}else if(t.morphStyle==="outerHTML"||t.morphStyle==null){let e=g(i,r,o);let t=e?.previousSibling;let n=e?.nextSibling;let l=u(r,e,o);if(e){return b(t,l,n)}else{return[]}}else{throw"Do not understand how to morph style "+t.morphStyle}}function u(e,t,n){if(t==null){n.callbacks.beforeNodeRemoved(e);e.remove();n.callbacks.afterNodeRemoved(e);return null}else if(!a(e,t)){n.callbacks.beforeNodeRemoved(e);n.callbacks.beforeNodeAdded(t);e.parentElement.replaceChild(t,e);n.callbacks.afterNodeAdded(t);n.callbacks.afterNodeRemoved(e);return t}else{n.callbacks.beforeNodeMorphed(e,t);r(t,e);l(t,e,n);n.callbacks.afterNodeMorphed(e,t);return e}}function l(n,l,r){let e=n.firstChild;let i=l.firstChild;while(e){let t=e;e=t.nextSibling;if(i==null){r.callbacks.beforeNodeAdded(t);l.appendChild(t);r.callbacks.afterNodeAdded(t)}else if(d(t,i,r)){u(i,t,r);i=i.nextSibling}else{let e=c(n,l,t,i,r);if(e){i=s(i,e,r);u(e,t,r)}else{let e=p(n,l,t,i,r);if(e){i=s(i,e,r);u(e,t,r)}else{r.callbacks.beforeNodeAdded(t);l.insertBefore(t,i);r.callbacks.afterNodeAdded(t)}}}w(r,t)}while(i!==null){let e=i;i=i.nextSibling;S(e,r)}}function r(n,l){let e=n.nodeType;if(e===1){const t=n.attributes;const r=l.attributes;for(const i of t){if(l.getAttribute(i.name)!==i.value){l.setAttribute(i.name,i.value)}}for(const o of r){if(!n.hasAttribute(o.name)){l.removeAttribute(o.name)}}}if(e===8||e===3){if(l.nodeValue!==n.nodeValue){l.nodeValue=n.nodeValue}}if(n instanceof HTMLInputElement&&l instanceof HTMLInputElement&&n.type!=="file"){let e=n.value;let t=l.value;f(n,l,"checked");f(n,l,"disabled");if(!n.hasAttribute("value")){l.value="";l.removeAttribute("value")}else if(e!==t){l.setAttribute("value",e);l.value=e}}else if(n instanceof HTMLOptionElement){f(n,l,"selected")}else if(n instanceof HTMLTextAreaElement&&l instanceof HTMLTextAreaElement){let e=n.value;let t=l.value;if(e!==t){l.value=e}if(l.firstChild&&l.firstChild.nodeValue!==e){l.firstChild.nodeValue=e}}}function f(e,t,n){if(e[n]!==t[n]){t[n]=e[n];if(e[n]){t.setAttribute(n,"")}else{t.removeAttribute(n)}}}function i(){}function n(e,t,n){return{idMap:x(e,t),deadIds:new Set,callbacks:Object.assign({beforeNodeAdded:i,afterNodeAdded:i,beforeNodeMorphed:i,afterNodeMorphed:i,beforeNodeRemoved:i,afterNodeRemoved:i},n.callbacks)}}function d(e,t,n){if(e==null||t==null){return false}if(e.nodeType===t.nodeType&&e.tagName===t.tagName){if(e.id!==""&&e.id===t.id){return true}else{return A(n,e,t)>0}}return false}function a(e,t){if(e==null||t==null){return false}return e.nodeType===t.nodeType&&e.tagName===t.tagName}function s(t,e,n){while(t!==e){let e=t;t=t.nextSibling;S(e,n)}w(n,e);return e.nextSibling}function c(n,e,l,r,i){let o=A(i,l,e);let t=null;if(o>0){let e=r;let t=0;while(e!=null){if(d(l,e,i)){return e}t+=A(i,e,n);if(t>o){return null}e=e.nextSibling}}return t}function p(e,t,n,l,r){let i=l;let o=n.nextSibling;let u=0;while(i!=null){if(A(r,i,e)>0){return null}else if(a(n,i)){return i}else if(a(o,i)){u++;if(u>=2){return null}o=o.nextSibling}else{i=i.nextSibling}}return i}function h(e){let t=new DOMParser;let n=t.parseFromString("<body><template>"+e+"</template></body>","text/html");let l=n.body.querySelector("template").content;l.generatedByIdiomorph=true;return l}function m(e){if(e==null){const t=document.createElement("div");return t}else if(e.generatedByIdiomorph){return e}else if(e instanceof Node){const t=document.createElement("div");t.append(e);return t}else{const t=document.createElement("div");for(const n of[...e]){t.append(n)}return t}}function b(e,t,n){let l=[];let r=[];while(e!=null){l.push(e);e=e.previousSibling}while(l.length>0){let e=l.pop();r.push(e);t.parentElement.insertBefore(e,t)}r.push(t);while(n!=null){l.push(n);r.push(n);n=n.nextSibling}while(l.length>0){t.parentElement.insertBefore(l.pop(),t.nextSibling)}return r}function g(e,t,n){let l=null;l=e.firstChild;let r=l;let i=0;while(l){let e=v(l,t,n);if(e>i){r=l;i=e}l=l.nextSibling}return r}function v(e,t,n){if(a(e,t)){return.5+A(n,e,t)}return 0}function S(e,t){w(t,e);t.callbacks.beforeNodeRemoved(e);e.remove();t.callbacks.afterNodeRemoved(e)}function N(e,t){return!e.deadIds.has(t)}function y(e,t,n){let l=e.idMap.get(n)||o;return l.has(t)}function w(e,t){let n=e.idMap.get(t)||o;for(const l of n){e.deadIds.add(l)}}function A(e,t,n){let l=e.idMap.get(t)||o;let r=0;for(const i of l){if(N(e,i)&&y(e,i,n)){++r}}return r}function M(e,n){let l=e.parentElement;let t=e.querySelectorAll("[id]");for(const r of t){let t=r;while(t!==l&&t!=null){let e=n.get(t);if(e==null){e=new Set;n.set(t,e)}e.add(r.id);t=t.parentElement}}}function x(e,t){let n=new Map;M(e,n);M(t,n);return n}return{morph:e}}()});htmx.defineExtension("morph",{isInlineSwap:function(e){return e==="morph"},handleSwap:function(e,t,n){if(e==="morph"||e==="morph:outerHTML"){return Idiomorph.morph(t,n.children)}else if(e==="morph:innerHTML"){return Idiomorph.morph(t,n.children,{morphStyle:"innerHTML"})}}}); | ||
(function(e,t){if(typeof define==="function"&&define.amd){define([],t)}else{e.Idiomorph=e.Idiomorph||t()}})(typeof self!=="undefined"?self:this,function(){return function(){"use strict";let o=new Set;function e(r,e,t={}){if(typeof e==="string"){e=h(e)}let i=m(e);let o=n(r,i,t);if(t.morphStyle==="innerHTML"){l(i,r,o);return r.children}else if(t.morphStyle==="outerHTML"||t.morphStyle==null){let e=g(i,r,o);let t=e?.previousSibling;let n=e?.nextSibling;let l=u(r,e,o);if(e){return b(t,l,n)}else{return[]}}else{throw"Do not understand how to morph style "+t.morphStyle}}function u(e,t,n){if(t==null){n.callbacks.beforeNodeRemoved(e);e.remove();n.callbacks.afterNodeRemoved(e);return null}else if(!a(e,t)){n.callbacks.beforeNodeRemoved(e);n.callbacks.beforeNodeAdded(t);e.parentElement.replaceChild(t,e);n.callbacks.afterNodeAdded(t);n.callbacks.afterNodeRemoved(e);return t}else{n.callbacks.beforeNodeMorphed(e,t);r(t,e);l(t,e,n);n.callbacks.afterNodeMorphed(e,t);return e}}function l(n,l,r){let e=n.firstChild;let i=l.firstChild;while(e){let t=e;e=t.nextSibling;if(i==null){r.callbacks.beforeNodeAdded(t);l.appendChild(t);r.callbacks.afterNodeAdded(t)}else if(d(t,i,r)){u(i,t,r);i=i.nextSibling}else{let e=c(n,l,t,i,r);if(e){i=s(i,e,r);u(e,t,r)}else{let e=p(n,l,t,i,r);if(e){i=s(i,e,r);u(e,t,r)}else{r.callbacks.beforeNodeAdded(t);l.insertBefore(t,i);r.callbacks.afterNodeAdded(t)}}}w(r,t)}while(i!==null){let e=i;i=i.nextSibling;S(e,r)}}function r(n,l){let e=n.nodeType;if(e===1){const t=n.attributes;const r=l.attributes;for(const i of t){if(l.getAttribute(i.name)!==i.value){l.setAttribute(i.name,i.value)}}for(const o of r){if(!n.hasAttribute(o.name)){l.removeAttribute(o.name)}}}if(e===8||e===3){if(l.nodeValue!==n.nodeValue){l.nodeValue=n.nodeValue}}if(n instanceof HTMLInputElement&&l instanceof HTMLInputElement&&n.type!=="file"){let e=n.value;let t=l.value;f(n,l,"checked");f(n,l,"disabled");if(!n.hasAttribute("value")){l.value="";l.removeAttribute("value")}else if(e!==t){l.setAttribute("value",e);l.value=e}}else if(n instanceof HTMLOptionElement){f(n,l,"selected")}else if(n instanceof HTMLTextAreaElement&&l instanceof HTMLTextAreaElement){let e=n.value;let t=l.value;if(e!==t){l.value=e}if(l.firstChild&&l.firstChild.nodeValue!==e){l.firstChild.nodeValue=e}}}function f(e,t,n){if(e[n]!==t[n]){t[n]=e[n];if(e[n]){t.setAttribute(n,"")}else{t.removeAttribute(n)}}}function i(){}function n(e,t,n){return{idMap:x(e,t),deadIds:new Set,callbacks:Object.assign({beforeNodeAdded:i,afterNodeAdded:i,beforeNodeMorphed:i,afterNodeMorphed:i,beforeNodeRemoved:i,afterNodeRemoved:i},n.callbacks)}}function d(e,t,n){if(e==null||t==null){return false}if(e.nodeType===t.nodeType&&e.tagName===t.tagName){if(e.id!==""&&e.id===t.id){return true}else{return A(n,e,t)>0}}return false}function a(e,t){if(e==null||t==null){return false}return e.nodeType===t.nodeType&&e.tagName===t.tagName}function s(t,e,n){while(t!==e){let e=t;t=t.nextSibling;S(e,n)}w(n,e);return e.nextSibling}function c(n,e,l,r,i){let o=A(i,l,e);let t=null;if(o>0){let e=r;let t=0;while(e!=null){if(d(l,e,i)){return e}t+=A(i,e,n);if(t>o){return null}e=e.nextSibling}}return t}function p(e,t,n,l,r){let i=l;let o=n.nextSibling;let u=0;while(i!=null){if(A(r,i,e)>0){return null}if(a(n,i)){return i}if(a(o,i)){u++;o=o.nextSibling;if(u>=2){return null}}i=i.nextSibling}return i}function h(e){let t=new DOMParser;let n=t.parseFromString("<body><template>"+e+"</template></body>","text/html");let l=n.body.querySelector("template").content;l.generatedByIdiomorph=true;return l}function m(e){if(e==null){const t=document.createElement("div");return t}else if(e.generatedByIdiomorph){return e}else if(e instanceof Node){const t=document.createElement("div");t.append(e);return t}else{const t=document.createElement("div");for(const n of[...e]){t.append(n)}return t}}function b(e,t,n){let l=[];let r=[];while(e!=null){l.push(e);e=e.previousSibling}while(l.length>0){let e=l.pop();r.push(e);t.parentElement.insertBefore(e,t)}r.push(t);while(n!=null){l.push(n);r.push(n);n=n.nextSibling}while(l.length>0){t.parentElement.insertBefore(l.pop(),t.nextSibling)}return r}function g(e,t,n){let l=null;l=e.firstChild;let r=l;let i=0;while(l){let e=v(l,t,n);if(e>i){r=l;i=e}l=l.nextSibling}return r}function v(e,t,n){if(a(e,t)){return.5+A(n,e,t)}return 0}function S(e,t){w(t,e);t.callbacks.beforeNodeRemoved(e);e.remove();t.callbacks.afterNodeRemoved(e)}function N(e,t){return!e.deadIds.has(t)}function y(e,t,n){let l=e.idMap.get(n)||o;return l.has(t)}function w(e,t){let n=e.idMap.get(t)||o;for(const l of n){e.deadIds.add(l)}}function A(e,t,n){let l=e.idMap.get(t)||o;let r=0;for(const i of l){if(N(e,i)&&y(e,i,n)){++r}}return r}function M(e,n){let l=e.parentElement;let t=e.querySelectorAll("[id]");for(const r of t){let t=r;while(t!==l&&t!=null){let e=n.get(t);if(e==null){e=new Set;n.set(t,e)}e.add(r.id);t=t.parentElement}}}function x(e,t){let n=new Map;M(e,n);M(t,n);return n}return{morph:e}}()});htmx.defineExtension("morph",{isInlineSwap:function(e){return e==="morph"},handleSwap:function(e,t,n){if(e==="morph"||e==="morph:outerHTML"){return Idiomorph.morph(t,n.children)}else if(e==="morph:innerHTML"){return Idiomorph.morph(t,n.children,{morphStyle:"innerHTML"})}}}); |
@@ -387,2 +387,3 @@ //============================================================================= | ||
while (potentialSoftMatch != null) { | ||
if (getIdIntersectionCount(ctx, potentialSoftMatch, newContent) > 0) { | ||
@@ -392,17 +393,24 @@ // the current potential soft match has a potential id set match with the remaining new | ||
return null; | ||
} else if (isSoftMatch(newChild, potentialSoftMatch)) { | ||
} | ||
// if we have a soft match with the current node, return it | ||
if (isSoftMatch(newChild, potentialSoftMatch)) { | ||
return potentialSoftMatch; | ||
} else if (isSoftMatch(nextSibling, potentialSoftMatch)) { | ||
} | ||
if (isSoftMatch(nextSibling, potentialSoftMatch)) { | ||
// the next new node has a soft match with this node, so | ||
// increment | ||
// increment the count of future soft matches | ||
siblingSoftMatchCount++; | ||
nextSibling = nextSibling.nextSibling; | ||
// If there are two future soft matches, bail to allow the siblings to soft match | ||
// so that we don't consume future soft matches for the sake of the current node | ||
if (siblingSoftMatchCount >= 2) { | ||
// with two soft matches, bail to allow the siblings to soft match | ||
return null; | ||
} | ||
nextSibling = nextSibling.nextSibling; | ||
} else { | ||
// advanced to the next old content child | ||
potentialSoftMatch = potentialSoftMatch.nextSibling; | ||
} | ||
// advanced to the next old content child | ||
potentialSoftMatch = potentialSoftMatch.nextSibling; | ||
} | ||
@@ -409,0 +417,0 @@ |
@@ -1,1 +0,1 @@ | ||
(function(e,t){if(typeof define==="function"&&define.amd){define([],t)}else{e.Idiomorph=e.Idiomorph||t()}})(typeof self!=="undefined"?self:this,function(){return function(){"use strict";let o=new Set;function e(i,e,t={}){if(typeof e==="string"){e=b(e)}let r=m(e);let o=n(i,r,t);if(t.morphStyle==="innerHTML"){l(r,i,o);return i.children}else if(t.morphStyle==="outerHTML"||t.morphStyle==null){let e=g(r,i,o);let t=e?.previousSibling;let n=e?.nextSibling;let l=u(i,e,o);if(e){return h(t,l,n)}else{return[]}}else{throw"Do not understand how to morph style "+t.morphStyle}}function u(e,t,n){if(t==null){n.callbacks.beforeNodeRemoved(e);e.remove();n.callbacks.afterNodeRemoved(e);return null}else if(!a(e,t)){n.callbacks.beforeNodeRemoved(e);n.callbacks.beforeNodeAdded(t);e.parentElement.replaceChild(t,e);n.callbacks.afterNodeAdded(t);n.callbacks.afterNodeRemoved(e);return t}else{n.callbacks.beforeNodeMorphed(e,t);i(t,e);l(t,e,n);n.callbacks.afterNodeMorphed(e,t);return e}}function l(n,l,i){let e=n.firstChild;let r=l.firstChild;while(e){let t=e;e=t.nextSibling;if(r==null){i.callbacks.beforeNodeAdded(t);l.appendChild(t);i.callbacks.afterNodeAdded(t)}else if(d(t,r,i)){u(r,t,i);r=r.nextSibling}else{let e=c(n,l,t,r,i);if(e){r=s(r,e,i);u(e,t,i)}else{let e=p(n,l,t,r,i);if(e){r=s(r,e,i);u(e,t,i)}else{i.callbacks.beforeNodeAdded(t);l.insertBefore(t,r);i.callbacks.afterNodeAdded(t)}}}A(i,t)}while(r!==null){let e=r;r=r.nextSibling;N(e,i)}}function i(n,l){let e=n.nodeType;if(e===1){const t=n.attributes;const i=l.attributes;for(const r of t){if(l.getAttribute(r.name)!==r.value){l.setAttribute(r.name,r.value)}}for(const o of i){if(!n.hasAttribute(o.name)){l.removeAttribute(o.name)}}}if(e===8||e===3){if(l.nodeValue!==n.nodeValue){l.nodeValue=n.nodeValue}}if(n instanceof HTMLInputElement&&l instanceof HTMLInputElement&&n.type!=="file"){let e=n.value;let t=l.value;f(n,l,"checked");f(n,l,"disabled");if(!n.hasAttribute("value")){l.value="";l.removeAttribute("value")}else if(e!==t){l.setAttribute("value",e);l.value=e}}else if(n instanceof HTMLOptionElement){f(n,l,"selected")}else if(n instanceof HTMLTextAreaElement&&l instanceof HTMLTextAreaElement){let e=n.value;let t=l.value;if(e!==t){l.value=e}if(l.firstChild&&l.firstChild.nodeValue!==e){l.firstChild.nodeValue=e}}}function f(e,t,n){if(e[n]!==t[n]){t[n]=e[n];if(e[n]){t.setAttribute(n,"")}else{t.removeAttribute(n)}}}function r(){}function n(e,t,n){return{idMap:M(e,t),deadIds:new Set,callbacks:Object.assign({beforeNodeAdded:r,afterNodeAdded:r,beforeNodeMorphed:r,afterNodeMorphed:r,beforeNodeRemoved:r,afterNodeRemoved:r},n.callbacks)}}function d(e,t,n){if(e==null||t==null){return false}if(e.nodeType===t.nodeType&&e.tagName===t.tagName){if(e.id!==""&&e.id===t.id){return true}else{return w(n,e,t)>0}}return false}function a(e,t){if(e==null||t==null){return false}return e.nodeType===t.nodeType&&e.tagName===t.tagName}function s(t,e,n){while(t!==e){let e=t;t=t.nextSibling;N(e,n)}A(n,e);return e.nextSibling}function c(n,e,l,i,r){let o=w(r,l,e);let t=null;if(o>0){let e=i;let t=0;while(e!=null){if(d(l,e,r)){return e}t+=w(r,e,n);if(t>o){return null}e=e.nextSibling}}return t}function p(e,t,n,l,i){let r=l;let o=n.nextSibling;let u=0;while(r!=null){if(w(i,r,e)>0){return null}else if(a(n,r)){return r}else if(a(o,r)){u++;if(u>=2){return null}o=o.nextSibling}else{r=r.nextSibling}}return r}function b(e){let t=new DOMParser;let n=t.parseFromString("<body><template>"+e+"</template></body>","text/html");let l=n.body.querySelector("template").content;l.generatedByIdiomorph=true;return l}function m(e){if(e==null){const t=document.createElement("div");return t}else if(e.generatedByIdiomorph){return e}else if(e instanceof Node){const t=document.createElement("div");t.append(e);return t}else{const t=document.createElement("div");for(const n of[...e]){t.append(n)}return t}}function h(e,t,n){let l=[];let i=[];while(e!=null){l.push(e);e=e.previousSibling}while(l.length>0){let e=l.pop();i.push(e);t.parentElement.insertBefore(e,t)}i.push(t);while(n!=null){l.push(n);i.push(n);n=n.nextSibling}while(l.length>0){t.parentElement.insertBefore(l.pop(),t.nextSibling)}return i}function g(e,t,n){let l=null;l=e.firstChild;let i=l;let r=0;while(l){let e=v(l,t,n);if(e>r){i=l;r=e}l=l.nextSibling}return i}function v(e,t,n){if(a(e,t)){return.5+w(n,e,t)}return 0}function N(e,t){A(t,e);t.callbacks.beforeNodeRemoved(e);e.remove();t.callbacks.afterNodeRemoved(e)}function S(e,t){return!e.deadIds.has(t)}function y(e,t,n){let l=e.idMap.get(n)||o;return l.has(t)}function A(e,t){let n=e.idMap.get(t)||o;for(const l of n){e.deadIds.add(l)}}function w(e,t,n){let l=e.idMap.get(t)||o;let i=0;for(const r of l){if(S(e,r)&&y(e,r,n)){++i}}return i}function k(e,n){let l=e.parentElement;let t=e.querySelectorAll("[id]");for(const i of t){let t=i;while(t!==l&&t!=null){let e=n.get(t);if(e==null){e=new Set;n.set(t,e)}e.add(i.id);t=t.parentElement}}}function M(e,t){let n=new Map;k(e,n);k(t,n);return n}return{morph:e}}()}); | ||
(function(e,t){if(typeof define==="function"&&define.amd){define([],t)}else{e.Idiomorph=e.Idiomorph||t()}})(typeof self!=="undefined"?self:this,function(){return function(){"use strict";let o=new Set;function e(i,e,t={}){if(typeof e==="string"){e=b(e)}let r=m(e);let o=n(i,r,t);if(t.morphStyle==="innerHTML"){l(r,i,o);return i.children}else if(t.morphStyle==="outerHTML"||t.morphStyle==null){let e=g(r,i,o);let t=e?.previousSibling;let n=e?.nextSibling;let l=u(i,e,o);if(e){return h(t,l,n)}else{return[]}}else{throw"Do not understand how to morph style "+t.morphStyle}}function u(e,t,n){if(t==null){n.callbacks.beforeNodeRemoved(e);e.remove();n.callbacks.afterNodeRemoved(e);return null}else if(!a(e,t)){n.callbacks.beforeNodeRemoved(e);n.callbacks.beforeNodeAdded(t);e.parentElement.replaceChild(t,e);n.callbacks.afterNodeAdded(t);n.callbacks.afterNodeRemoved(e);return t}else{n.callbacks.beforeNodeMorphed(e,t);i(t,e);l(t,e,n);n.callbacks.afterNodeMorphed(e,t);return e}}function l(n,l,i){let e=n.firstChild;let r=l.firstChild;while(e){let t=e;e=t.nextSibling;if(r==null){i.callbacks.beforeNodeAdded(t);l.appendChild(t);i.callbacks.afterNodeAdded(t)}else if(d(t,r,i)){u(r,t,i);r=r.nextSibling}else{let e=c(n,l,t,r,i);if(e){r=s(r,e,i);u(e,t,i)}else{let e=p(n,l,t,r,i);if(e){r=s(r,e,i);u(e,t,i)}else{i.callbacks.beforeNodeAdded(t);l.insertBefore(t,r);i.callbacks.afterNodeAdded(t)}}}A(i,t)}while(r!==null){let e=r;r=r.nextSibling;N(e,i)}}function i(n,l){let e=n.nodeType;if(e===1){const t=n.attributes;const i=l.attributes;for(const r of t){if(l.getAttribute(r.name)!==r.value){l.setAttribute(r.name,r.value)}}for(const o of i){if(!n.hasAttribute(o.name)){l.removeAttribute(o.name)}}}if(e===8||e===3){if(l.nodeValue!==n.nodeValue){l.nodeValue=n.nodeValue}}if(n instanceof HTMLInputElement&&l instanceof HTMLInputElement&&n.type!=="file"){let e=n.value;let t=l.value;f(n,l,"checked");f(n,l,"disabled");if(!n.hasAttribute("value")){l.value="";l.removeAttribute("value")}else if(e!==t){l.setAttribute("value",e);l.value=e}}else if(n instanceof HTMLOptionElement){f(n,l,"selected")}else if(n instanceof HTMLTextAreaElement&&l instanceof HTMLTextAreaElement){let e=n.value;let t=l.value;if(e!==t){l.value=e}if(l.firstChild&&l.firstChild.nodeValue!==e){l.firstChild.nodeValue=e}}}function f(e,t,n){if(e[n]!==t[n]){t[n]=e[n];if(e[n]){t.setAttribute(n,"")}else{t.removeAttribute(n)}}}function r(){}function n(e,t,n){return{idMap:M(e,t),deadIds:new Set,callbacks:Object.assign({beforeNodeAdded:r,afterNodeAdded:r,beforeNodeMorphed:r,afterNodeMorphed:r,beforeNodeRemoved:r,afterNodeRemoved:r},n.callbacks)}}function d(e,t,n){if(e==null||t==null){return false}if(e.nodeType===t.nodeType&&e.tagName===t.tagName){if(e.id!==""&&e.id===t.id){return true}else{return w(n,e,t)>0}}return false}function a(e,t){if(e==null||t==null){return false}return e.nodeType===t.nodeType&&e.tagName===t.tagName}function s(t,e,n){while(t!==e){let e=t;t=t.nextSibling;N(e,n)}A(n,e);return e.nextSibling}function c(n,e,l,i,r){let o=w(r,l,e);let t=null;if(o>0){let e=i;let t=0;while(e!=null){if(d(l,e,r)){return e}t+=w(r,e,n);if(t>o){return null}e=e.nextSibling}}return t}function p(e,t,n,l,i){let r=l;let o=n.nextSibling;let u=0;while(r!=null){if(w(i,r,e)>0){return null}if(a(n,r)){return r}if(a(o,r)){u++;o=o.nextSibling;if(u>=2){return null}}r=r.nextSibling}return r}function b(e){let t=new DOMParser;let n=t.parseFromString("<body><template>"+e+"</template></body>","text/html");let l=n.body.querySelector("template").content;l.generatedByIdiomorph=true;return l}function m(e){if(e==null){const t=document.createElement("div");return t}else if(e.generatedByIdiomorph){return e}else if(e instanceof Node){const t=document.createElement("div");t.append(e);return t}else{const t=document.createElement("div");for(const n of[...e]){t.append(n)}return t}}function h(e,t,n){let l=[];let i=[];while(e!=null){l.push(e);e=e.previousSibling}while(l.length>0){let e=l.pop();i.push(e);t.parentElement.insertBefore(e,t)}i.push(t);while(n!=null){l.push(n);i.push(n);n=n.nextSibling}while(l.length>0){t.parentElement.insertBefore(l.pop(),t.nextSibling)}return i}function g(e,t,n){let l=null;l=e.firstChild;let i=l;let r=0;while(l){let e=v(l,t,n);if(e>r){i=l;r=e}l=l.nextSibling}return i}function v(e,t,n){if(a(e,t)){return.5+w(n,e,t)}return 0}function N(e,t){A(t,e);t.callbacks.beforeNodeRemoved(e);e.remove();t.callbacks.afterNodeRemoved(e)}function S(e,t){return!e.deadIds.has(t)}function y(e,t,n){let l=e.idMap.get(n)||o;return l.has(t)}function A(e,t){let n=e.idMap.get(t)||o;for(const l of n){e.deadIds.add(l)}}function w(e,t,n){let l=e.idMap.get(t)||o;let i=0;for(const r of l){if(S(e,r)&&y(e,r,n)){++i}}return i}function k(e,n){let l=e.parentElement;let t=e.querySelectorAll("[id]");for(const i of t){let t=i;while(t!==l&&t!=null){let e=n.get(t);if(e==null){e=new Set;n.set(t,e)}e.add(i.id);t=t.parentElement}}}function M(e,t){let n=new Map;k(e,n);k(t,n);return n}return{morph:e}}()}); |
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"homepage": "https://github.com/bigskysoftware/idiomorph", | ||
@@ -10,0 +10,0 @@ "bugs": { |
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
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
76164
1042