aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.ffi.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime.ffi.mjs')
-rw-r--r--src/runtime.ffi.mjs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/runtime.ffi.mjs b/src/runtime.ffi.mjs
index 03e741a..45b05bf 100644
--- a/src/runtime.ffi.mjs
+++ b/src/runtime.ffi.mjs
@@ -42,11 +42,15 @@ function createElement(prev, curr, ns, dispatch, parent = null) {
el.$lustre = {};
let attr = curr[1];
+ let dangerousUnescapedHtml = "";
+
while (attr.head) {
if (attr.head[0] === "class") {
morphAttr(el, attr.head[0], `${el.className} ${attr.head[1]}`);
} else if (attr.head[0] === "style") {
morphAttr(el, attr.head[0], `${el.style.cssText} ${attr.head[1]}`);
+ } else if (attr.head[0] === "dangerous-unescaped-html") {
+ dangerousUnescapedHtml += attr.head[1];
} else {
morphAttr(el, attr.head[0], attr.head[1], dispatch);
}
@@ -73,6 +77,8 @@ function createElement(prev, curr, ns, dispatch, parent = null) {
el.appendChild(morph(null, child.head, dispatch, el));
child = child.tail;
}
+ } else if (dangerousUnescapedHtml) {
+ el.innerHTML = dangerousUnescapedHtml;
} else {
let child = curr[2];
while (child.head) {
@@ -106,6 +112,14 @@ function morphElement(prev, curr, ns, dispatch, parent) {
currAttr.head[0],
`${currAttrs.get("style")} ${currAttr.head[1]}`
);
+ } else if (
+ currAttr.head[0] === "dangerous-unescaped-html" &&
+ currAttrs.has("dangerous-unescaped-html")
+ ) {
+ currAttrs.set(
+ currAttr.head[0],
+ `${currAttrs.get("dangerous-unescaped-html")} ${currAttr.head[1]}`
+ );
} else {
currAttrs.set(currAttr.head[0], currAttr.head[1]);
}
@@ -159,6 +173,8 @@ function morphElement(prev, curr, ns, dispatch, parent) {
prev.appendChild(morph(null, currChild.head, dispatch, prev));
currChild = currChild.tail;
}
+ } else if (currAttrs.has("dangerous-unescaped-html")) {
+ prev.innerHTML = currAttrs.get("dangerous-unescaped-html");
} else {
let prevChild = prev.firstChild;
let currChild = curr[2];