Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@doars/doars-morph

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@doars/doars-morph - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

4

CHANGELOG.md
# CHANGELOG.md
## 2.1.0
- Add outer modifier.
## 2.0.0
- Initial release.

37

dst/doars-morph.iife.js

@@ -58,2 +58,9 @@ (() => {

var fromString = (string) => {
const stringStart = string.substring(0, 15).toLowerCase();
const isDocument = stringStart.startsWith("<!doctype html>") || stringStart.startsWith("<html>");
if (isDocument) {
const html = document.createElement("html");
html.innerHTML = string;
return html;
}
const template = document.createElement("template");

@@ -274,16 +281,24 @@ template.innerHTML = string;

}
if (element.children.length === 0) {
element.appendChild(document.createElement("div"));
} else if (element.children.length > 1) {
for (let i = element.children.length - 1; i >= 1; i--) {
element.children[i].remove();
if (modifiers.outer) {
morphTree(element, html);
} else {
if (element.children.length === 0) {
element.appendChild(document.createElement("div"));
} else if (element.children.length > 1) {
for (let i = element.children.length - 1; i >= 1; i--) {
element.children[i].remove();
}
}
const root = morphTree(element.children[0], html);
if (!element.children[0].isSameNode(root)) {
element.children[0].remove();
element.appendChild(root);
}
}
const root = morphTree(element.children[0], html);
if (!element.children[0].isSameNode(root)) {
element.children[0].remove();
element.appendChild(root);
}
};
const result = processExpression(component, attribute, attribute.getValue());
const result = processExpression(
component,
attribute,
attribute.getValue()
);
attribute.setData(result);

@@ -290,0 +305,0 @@ if (isPromise(result)) {

@@ -1,2 +0,2 @@

(()=>{var d=(t,e)=>{let r=t.attributes,o=e.attributes,i=null,u=null,s=null,l=null,n=null;for(let c=o.length-1;c>=0;--c)n=o[c],l=n.name,i=n.namespaceURI,u=n.value,i?(l=n.localName||l,s=t.getAttributeNS(i,l),s!==u&&t.setAttributeNS(i,l,u)):t.hasAttribute(l)?(s=t.getAttribute(l),s!==u&&(u==="null"||u==="undefined"?t.removeAttribute(l):t.setAttribute(l,u))):t.setAttribute(l,u);for(let c=r.length-1;c>=0;--c)n=r[c],n.specified!==!1&&(l=n.name,i=n.namespaceURI,i?(l=n.localName||l,e.hasAttributeNS(i,l)||t.removeAttributeNS(i,l)):e.hasAttributeNS(null,l)||t.removeAttribute(l))};var A=t=>{let e=document.createElement("template");return e.innerHTML=t,e.content.childNodes[0]};var p=(t,e)=>t.isSameNode&&t.isSameNode(e)?!0:t.type===3?t.nodeValue===e.nodeValue:t.tagName===e.tagName;var j=(t,e)=>{let r=e.nodeType,o=e.nodeName;r===1&&d(t,e),(r===3||r===8)&&t.nodeValue!==e.nodeValue&&(t.nodeValue=e.nodeValue),o==="INPUT"?y(t,e):o==="OPTION"?m(t,e,"selected"):o==="TEXTAREA"&&O(t,e)},a=(t,e,r)=>{if(typeof t!="object")throw new Error("Existing tree should be an object.");if(typeof e=="string")e=A(e);else if(typeof e!="object")throw new Error("New tree should be an object.");return r&&r.childrenOnly||e.nodeType===11?(v(t,e),t):f(t,e)},y=(t,e)=>{let r=e.value,o=t.value;m(t,e,"checked"),m(t,e,"disabled"),t.indeterminate!==e.indeterminate&&(t.indeterminate=e.indeterminate),t.type!=="file"&&(o!==r&&(t.setAttribute("value",r),t.value=r),r==="null"&&(t.value="",t.removeAttribute("value")),e.hasAttributeNS(null,"value")?t.type==="range"&&(t.value=r):t.removeAttribute("value"))},O=(t,e)=>{let r=e.value;t.value!==r&&(t.value=r),t.firstChild&&t.firstChild.nodeValue!==r&&(t.firstChild.nodeValue=r)},m=(t,e,r)=>{t[r]!==e[r]&&(t[r]=e[r],e[r]?t.setAttribute(r,""):t.removeAttribute(r))},f=(t,e)=>t?e?t.isSameNode&&t.isSameNode(e)?t:t.tagName!==e.tagName?e:(j(t,e),v(t,e),t):null:e,v=(t,e)=>{let r,o,i,u,s=0;for(let l=0;r=t.childNodes[l],o=e.childNodes[l-s],!(!r&&!o);l++)if(!o)t.removeChild(r),l--;else if(!r)t.appendChild(o),s++;else if(p(r,o))i=f(r,o),i!==r&&(t.replaceChild(i,r),s++);else{u=null;for(let n=l;n<t.childNodes.length;n++)if(p(t.childNodes[n],o)){u=t.childNodes[n];break}u?(i=f(u,o),i!==u&&s++,t.insertBefore(i,r)):!o.id&&!r.id?(i=f(r,o),i!==r&&(t.replaceChild(i,r),s++)):(t.insertBefore(o,r),s++)}};var h={name:"$morph",create:()=>({value:a})};var P={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"'},V=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;var E=t=>typeof t!="string"?t:t.replaceAll(V,e=>P[e]);var q=Function.prototype.toString.call(Function).replace("Function","Promise").replace(/\(.*\)/,"()");var S=t=>t&&Object.prototype.toString.call(t)==="[object Promise]";var b={name:"morph",update:(t,e,{processExpression:r})=>{let o=e.getElement(),i=e.getModifiers(),u=l=>{if(i.decode&&typeof l=="string"&&(l=E(l)),o.children.length===0)o.appendChild(document.createElement("div"));else if(o.children.length>1)for(let c=o.children.length-1;c>=1;c--)o.children[c].remove();let n=a(o.children[0],l);o.children[0].isSameNode(n)||(o.children[0].remove(),o.appendChild(n))},s=r(t,e,e.getValue());e.setData(s),S(s)?Promise.resolve(s).then(l=>{e.getData()===s&&u(l)}):u(s)}};function C(t){let e=!1,r=()=>{t.addContexts(0,h),t.addDirectives(-1,b)},o=()=>{t.removeContexts(h),t.removeDirectives(b)};this.disable=()=>{!t.getEnabled()&&e&&(e=!1,t.removeEventListener("enabling",r),t.removeEventListener("disabling",o))},this.enable=()=>{e||(e=!0,t.addEventListener("enabling",r),t.addEventListener("disabling",o))},this.enable()}window.DoarsMorph=C;})();
(()=>{var d=(t,e)=>{let r=t.attributes,o=e.attributes,i=null,s=null,u=null,l=null,n=null;for(let c=o.length-1;c>=0;--c)n=o[c],l=n.name,i=n.namespaceURI,s=n.value,i?(l=n.localName||l,u=t.getAttributeNS(i,l),u!==s&&t.setAttributeNS(i,l,s)):t.hasAttribute(l)?(u=t.getAttribute(l),u!==s&&(s==="null"||s==="undefined"?t.removeAttribute(l):t.setAttribute(l,s))):t.setAttribute(l,s);for(let c=r.length-1;c>=0;--c)n=r[c],n.specified!==!1&&(l=n.name,i=n.namespaceURI,i?(l=n.localName||l,e.hasAttributeNS(i,l)||t.removeAttributeNS(i,l)):e.hasAttributeNS(null,l)||t.removeAttribute(l))};var A=t=>{let e=t.substring(0,15).toLowerCase();if(e.startsWith("<!doctype html>")||e.startsWith("<html>")){let i=document.createElement("html");return i.innerHTML=t,i}let o=document.createElement("template");return o.innerHTML=t,o.content.childNodes[0]};var p=(t,e)=>t.isSameNode&&t.isSameNode(e)?!0:t.type===3?t.nodeValue===e.nodeValue:t.tagName===e.tagName;var j=(t,e)=>{let r=e.nodeType,o=e.nodeName;r===1&&d(t,e),(r===3||r===8)&&t.nodeValue!==e.nodeValue&&(t.nodeValue=e.nodeValue),o==="INPUT"?y(t,e):o==="OPTION"?m(t,e,"selected"):o==="TEXTAREA"&&D(t,e)},f=(t,e,r)=>{if(typeof t!="object")throw new Error("Existing tree should be an object.");if(typeof e=="string")e=A(e);else if(typeof e!="object")throw new Error("New tree should be an object.");return r&&r.childrenOnly||e.nodeType===11?(v(t,e),t):a(t,e)},y=(t,e)=>{let r=e.value,o=t.value;m(t,e,"checked"),m(t,e,"disabled"),t.indeterminate!==e.indeterminate&&(t.indeterminate=e.indeterminate),t.type!=="file"&&(o!==r&&(t.setAttribute("value",r),t.value=r),r==="null"&&(t.value="",t.removeAttribute("value")),e.hasAttributeNS(null,"value")?t.type==="range"&&(t.value=r):t.removeAttribute("value"))},D=(t,e)=>{let r=e.value;t.value!==r&&(t.value=r),t.firstChild&&t.firstChild.nodeValue!==r&&(t.firstChild.nodeValue=r)},m=(t,e,r)=>{t[r]!==e[r]&&(t[r]=e[r],e[r]?t.setAttribute(r,""):t.removeAttribute(r))},a=(t,e)=>t?e?t.isSameNode&&t.isSameNode(e)?t:t.tagName!==e.tagName?e:(j(t,e),v(t,e),t):null:e,v=(t,e)=>{let r,o,i,s,u=0;for(let l=0;r=t.childNodes[l],o=e.childNodes[l-u],!(!r&&!o);l++)if(!o)t.removeChild(r),l--;else if(!r)t.appendChild(o),u++;else if(p(r,o))i=a(r,o),i!==r&&(t.replaceChild(i,r),u++);else{s=null;for(let n=l;n<t.childNodes.length;n++)if(p(t.childNodes[n],o)){s=t.childNodes[n];break}s?(i=a(s,o),i!==s&&u++,t.insertBefore(i,r)):!o.id&&!r.id?(i=a(r,o),i!==r&&(t.replaceChild(i,r),u++)):(t.insertBefore(o,r),u++)}};var h={name:"$morph",create:()=>({value:f})};var O={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"'},P=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;var E=t=>typeof t!="string"?t:t.replaceAll(P,e=>O[e]);var q=Function.prototype.toString.call(Function).replace("Function","Promise").replace(/\(.*\)/,"()");var S=t=>t&&Object.prototype.toString.call(t)==="[object Promise]";var b={name:"morph",update:(t,e,{processExpression:r})=>{let o=e.getElement(),i=e.getModifiers(),s=l=>{if(i.decode&&typeof l=="string"&&(l=E(l)),i.outer)f(o,l);else{if(o.children.length===0)o.appendChild(document.createElement("div"));else if(o.children.length>1)for(let c=o.children.length-1;c>=1;c--)o.children[c].remove();let n=f(o.children[0],l);o.children[0].isSameNode(n)||(o.children[0].remove(),o.appendChild(n))}},u=r(t,e,e.getValue());e.setData(u),S(u)?Promise.resolve(u).then(l=>{e.getData()===u&&s(l)}):s(u)}};function C(t){let e=!1,r=()=>{t.addContexts(0,h),t.addDirectives(-1,b)},o=()=>{t.removeContexts(h),t.removeDirectives(b)};this.disable=()=>{!t.getEnabled()&&e&&(e=!1,t.removeEventListener("enabling",r),t.removeEventListener("disabling",o))},this.enable=()=>{e||(e=!0,t.addEventListener("enabling",r),t.addEventListener("disabling",o))},this.enable()}window.DoarsMorph=C;})();
//# sourceMappingURL=doars-morph.iife.min.js.map

@@ -57,2 +57,9 @@ // ../common/src/utilities/Attribute.js

var fromString = (string) => {
const stringStart = string.substring(0, 15).toLowerCase();
const isDocument = stringStart.startsWith("<!doctype html>") || stringStart.startsWith("<html>");
if (isDocument) {
const html = document.createElement("html");
html.innerHTML = string;
return html;
}
const template = document.createElement("template");

@@ -273,16 +280,24 @@ template.innerHTML = string;

}
if (element.children.length === 0) {
element.appendChild(document.createElement("div"));
} else if (element.children.length > 1) {
for (let i = element.children.length - 1; i >= 1; i--) {
element.children[i].remove();
if (modifiers.outer) {
morphTree(element, html);
} else {
if (element.children.length === 0) {
element.appendChild(document.createElement("div"));
} else if (element.children.length > 1) {
for (let i = element.children.length - 1; i >= 1; i--) {
element.children[i].remove();
}
}
const root = morphTree(element.children[0], html);
if (!element.children[0].isSameNode(root)) {
element.children[0].remove();
element.appendChild(root);
}
}
const root = morphTree(element.children[0], html);
if (!element.children[0].isSameNode(root)) {
element.children[0].remove();
element.appendChild(root);
}
};
const result = processExpression(component, attribute, attribute.getValue());
const result = processExpression(
component,
attribute,
attribute.getValue()
);
attribute.setData(result);

@@ -289,0 +304,0 @@ if (isPromise(result)) {

@@ -1,2 +0,2 @@

var d=(t,e)=>{let r=t.attributes,l=e.attributes,i=null,u=null,s=null,o=null,n=null;for(let c=l.length-1;c>=0;--c)n=l[c],o=n.name,i=n.namespaceURI,u=n.value,i?(o=n.localName||o,s=t.getAttributeNS(i,o),s!==u&&t.setAttributeNS(i,o,u)):t.hasAttribute(o)?(s=t.getAttribute(o),s!==u&&(u==="null"||u==="undefined"?t.removeAttribute(o):t.setAttribute(o,u))):t.setAttribute(o,u);for(let c=r.length-1;c>=0;--c)n=r[c],n.specified!==!1&&(o=n.name,i=n.namespaceURI,i?(o=n.localName||o,e.hasAttributeNS(i,o)||t.removeAttributeNS(i,o)):e.hasAttributeNS(null,o)||t.removeAttribute(o))};var A=t=>{let e=document.createElement("template");return e.innerHTML=t,e.content.childNodes[0]};var p=(t,e)=>t.isSameNode&&t.isSameNode(e)?!0:t.type===3?t.nodeValue===e.nodeValue:t.tagName===e.tagName;var C=(t,e)=>{let r=e.nodeType,l=e.nodeName;r===1&&d(t,e),(r===3||r===8)&&t.nodeValue!==e.nodeValue&&(t.nodeValue=e.nodeValue),l==="INPUT"?j(t,e):l==="OPTION"?m(t,e,"selected"):l==="TEXTAREA"&&y(t,e)},a=(t,e,r)=>{if(typeof t!="object")throw new Error("Existing tree should be an object.");if(typeof e=="string")e=A(e);else if(typeof e!="object")throw new Error("New tree should be an object.");return r&&r.childrenOnly||e.nodeType===11?(v(t,e),t):f(t,e)},j=(t,e)=>{let r=e.value,l=t.value;m(t,e,"checked"),m(t,e,"disabled"),t.indeterminate!==e.indeterminate&&(t.indeterminate=e.indeterminate),t.type!=="file"&&(l!==r&&(t.setAttribute("value",r),t.value=r),r==="null"&&(t.value="",t.removeAttribute("value")),e.hasAttributeNS(null,"value")?t.type==="range"&&(t.value=r):t.removeAttribute("value"))},y=(t,e)=>{let r=e.value;t.value!==r&&(t.value=r),t.firstChild&&t.firstChild.nodeValue!==r&&(t.firstChild.nodeValue=r)},m=(t,e,r)=>{t[r]!==e[r]&&(t[r]=e[r],e[r]?t.setAttribute(r,""):t.removeAttribute(r))},f=(t,e)=>t?e?t.isSameNode&&t.isSameNode(e)?t:t.tagName!==e.tagName?e:(C(t,e),v(t,e),t):null:e,v=(t,e)=>{let r,l,i,u,s=0;for(let o=0;r=t.childNodes[o],l=e.childNodes[o-s],!(!r&&!l);o++)if(!l)t.removeChild(r),o--;else if(!r)t.appendChild(l),s++;else if(p(r,l))i=f(r,l),i!==r&&(t.replaceChild(i,r),s++);else{u=null;for(let n=o;n<t.childNodes.length;n++)if(p(t.childNodes[n],l)){u=t.childNodes[n];break}u?(i=f(u,l),i!==u&&s++,t.insertBefore(i,r)):!l.id&&!r.id?(i=f(r,l),i!==r&&(t.replaceChild(i,r),s++)):(t.insertBefore(l,r),s++)}};var h={name:"$morph",create:()=>({value:a})};var O={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"'},P=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;var E=t=>typeof t!="string"?t:t.replaceAll(P,e=>O[e]);var M=Function.prototype.toString.call(Function).replace("Function","Promise").replace(/\(.*\)/,"()");var S=t=>t&&Object.prototype.toString.call(t)==="[object Promise]";var b={name:"morph",update:(t,e,{processExpression:r})=>{let l=e.getElement(),i=e.getModifiers(),u=o=>{if(i.decode&&typeof o=="string"&&(o=E(o)),l.children.length===0)l.appendChild(document.createElement("div"));else if(l.children.length>1)for(let c=l.children.length-1;c>=1;c--)l.children[c].remove();let n=a(l.children[0],o);l.children[0].isSameNode(n)||(l.children[0].remove(),l.appendChild(n))},s=r(t,e,e.getValue());e.setData(s),S(s)?Promise.resolve(s).then(o=>{e.getData()===s&&u(o)}):u(s)}};function $(t){let e=!1,r=()=>{t.addContexts(0,h),t.addDirectives(-1,b)},l=()=>{t.removeContexts(h),t.removeDirectives(b)};this.disable=()=>{!t.getEnabled()&&e&&(e=!1,t.removeEventListener("enabling",r),t.removeEventListener("disabling",l))},this.enable=()=>{e||(e=!0,t.addEventListener("enabling",r),t.addEventListener("disabling",l))},this.enable()}export{$ as default};
var d=(t,e)=>{let r=t.attributes,l=e.attributes,i=null,s=null,u=null,o=null,n=null;for(let c=l.length-1;c>=0;--c)n=l[c],o=n.name,i=n.namespaceURI,s=n.value,i?(o=n.localName||o,u=t.getAttributeNS(i,o),u!==s&&t.setAttributeNS(i,o,s)):t.hasAttribute(o)?(u=t.getAttribute(o),u!==s&&(s==="null"||s==="undefined"?t.removeAttribute(o):t.setAttribute(o,s))):t.setAttribute(o,s);for(let c=r.length-1;c>=0;--c)n=r[c],n.specified!==!1&&(o=n.name,i=n.namespaceURI,i?(o=n.localName||o,e.hasAttributeNS(i,o)||t.removeAttributeNS(i,o)):e.hasAttributeNS(null,o)||t.removeAttribute(o))};var A=t=>{let e=t.substring(0,15).toLowerCase();if(e.startsWith("<!doctype html>")||e.startsWith("<html>")){let i=document.createElement("html");return i.innerHTML=t,i}let l=document.createElement("template");return l.innerHTML=t,l.content.childNodes[0]};var p=(t,e)=>t.isSameNode&&t.isSameNode(e)?!0:t.type===3?t.nodeValue===e.nodeValue:t.tagName===e.tagName;var C=(t,e)=>{let r=e.nodeType,l=e.nodeName;r===1&&d(t,e),(r===3||r===8)&&t.nodeValue!==e.nodeValue&&(t.nodeValue=e.nodeValue),l==="INPUT"?j(t,e):l==="OPTION"?m(t,e,"selected"):l==="TEXTAREA"&&y(t,e)},f=(t,e,r)=>{if(typeof t!="object")throw new Error("Existing tree should be an object.");if(typeof e=="string")e=A(e);else if(typeof e!="object")throw new Error("New tree should be an object.");return r&&r.childrenOnly||e.nodeType===11?(v(t,e),t):a(t,e)},j=(t,e)=>{let r=e.value,l=t.value;m(t,e,"checked"),m(t,e,"disabled"),t.indeterminate!==e.indeterminate&&(t.indeterminate=e.indeterminate),t.type!=="file"&&(l!==r&&(t.setAttribute("value",r),t.value=r),r==="null"&&(t.value="",t.removeAttribute("value")),e.hasAttributeNS(null,"value")?t.type==="range"&&(t.value=r):t.removeAttribute("value"))},y=(t,e)=>{let r=e.value;t.value!==r&&(t.value=r),t.firstChild&&t.firstChild.nodeValue!==r&&(t.firstChild.nodeValue=r)},m=(t,e,r)=>{t[r]!==e[r]&&(t[r]=e[r],e[r]?t.setAttribute(r,""):t.removeAttribute(r))},a=(t,e)=>t?e?t.isSameNode&&t.isSameNode(e)?t:t.tagName!==e.tagName?e:(C(t,e),v(t,e),t):null:e,v=(t,e)=>{let r,l,i,s,u=0;for(let o=0;r=t.childNodes[o],l=e.childNodes[o-u],!(!r&&!l);o++)if(!l)t.removeChild(r),o--;else if(!r)t.appendChild(l),u++;else if(p(r,l))i=a(r,l),i!==r&&(t.replaceChild(i,r),u++);else{s=null;for(let n=o;n<t.childNodes.length;n++)if(p(t.childNodes[n],l)){s=t.childNodes[n];break}s?(i=a(s,l),i!==s&&u++,t.insertBefore(i,r)):!l.id&&!r.id?(i=a(r,l),i!==r&&(t.replaceChild(i,r),u++)):(t.insertBefore(l,r),u++)}};var h={name:"$morph",create:()=>({value:f})};var O={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"'},P=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;var E=t=>typeof t!="string"?t:t.replaceAll(P,e=>O[e]);var F=Function.prototype.toString.call(Function).replace("Function","Promise").replace(/\(.*\)/,"()");var S=t=>t&&Object.prototype.toString.call(t)==="[object Promise]";var b={name:"morph",update:(t,e,{processExpression:r})=>{let l=e.getElement(),i=e.getModifiers(),s=o=>{if(i.decode&&typeof o=="string"&&(o=E(o)),i.outer)f(l,o);else{if(l.children.length===0)l.appendChild(document.createElement("div"));else if(l.children.length>1)for(let c=l.children.length-1;c>=1;c--)l.children[c].remove();let n=f(l.children[0],o);l.children[0].isSameNode(n)||(l.children[0].remove(),l.appendChild(n))}},u=r(t,e,e.getValue());e.setData(u),S(u)?Promise.resolve(u).then(o=>{e.getData()===u&&s(o)}):s(u)}};function k(t){let e=!1,r=()=>{t.addContexts(0,h),t.addDirectives(-1,b)},l=()=>{t.removeContexts(h),t.removeDirectives(b)};this.disable=()=>{!t.getEnabled()&&e&&(e=!1,t.removeEventListener("enabling",r),t.removeEventListener("disabling",l))},this.enable=()=>{e||(e=!0,t.addEventListener("enabling",r),t.addEventListener("disabling",l))},this.enable()}export{k as default};
//# sourceMappingURL=doars-morph.min.js.map

@@ -15,3 +15,3 @@ {

],
"version": "2.0.2",
"version": "2.1.0",
"license": "MIT",

@@ -50,4 +50,4 @@ "type": "module",

"dependencies": {
"@doars/common": "^1.0.1"
"@doars/common": "^1.1.0"
}
}
}

@@ -92,2 +92,7 @@ <div align="center">

```HTML
<!-- Morph the outer HTML of the element, changing this element in the process. -->
<div d-html.outer="'<h1>Hello world!</h1>'"></div>
```
```HTML
<!-- Morph the inner HTML of the element to a value from the state. -->

@@ -94,0 +99,0 @@ <div d-morph="$state.message"></div>

@@ -27,16 +27,21 @@ // Import utilities.

// Ensure element only has one child.
if (element.children.length === 0) {
element.appendChild(document.createElement('div'))
} else if (element.children.length > 1) {
for (let i = element.children.length - 1; i >= 1; i--) {
element.children[i].remove()
if (modifiers.outer) {
// Morph the element as well.
morphTree(element, html)
} else {
// Ensure element only has one child.
if (element.children.length === 0) {
element.appendChild(document.createElement('div'))
} else if (element.children.length > 1) {
for (let i = element.children.length - 1; i >= 1; i--) {
element.children[i].remove()
}
}
}
// Morph first child to given element tree.
const root = morphTree(element.children[0], html)
if (!element.children[0].isSameNode(root)) {
element.children[0].remove()
element.appendChild(root)
// Morph first child to given element tree.
const root = morphTree(element.children[0], html)
if (!element.children[0].isSameNode(root)) {
element.children[0].remove()
element.appendChild(root)
}
}

@@ -46,3 +51,7 @@ }

// Execute value and retrieve result.
const result = processExpression(component, attribute, attribute.getValue())
const result = processExpression(
component,
attribute,
attribute.getValue(),
)

@@ -49,0 +58,0 @@ // Store results.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc