mirror of
https://codeberg.org/setop/elm-scripting
synced 2025-11-08 21:49:57 +00:00
feat: handle innerHTML
This commit is contained in:
9
dom.js
9
dom.js
@@ -2,7 +2,6 @@ function Node(parent, tag) {
|
|||||||
this.parentNode = parent; // Node
|
this.parentNode = parent; // Node
|
||||||
this.pos = 0; // position in siblings list
|
this.pos = 0; // position in siblings list
|
||||||
this.tagName = tag;
|
this.tagName = tag;
|
||||||
this.text = null;
|
|
||||||
// attributes are stored directly on the node object
|
// attributes are stored directly on the node object
|
||||||
// see https://github.com/elm/virtual-dom/blob/master/src/Elm/Kernel/VirtualDom.js#L511
|
// see https://github.com/elm/virtual-dom/blob/master/src/Elm/Kernel/VirtualDom.js#L511
|
||||||
this.children = []; // List of Node
|
this.children = []; // List of Node
|
||||||
@@ -17,10 +16,14 @@ function Node(parent, tag) {
|
|||||||
node.pos = this.children.push(node);
|
node.pos = this.children.push(node);
|
||||||
}
|
}
|
||||||
this.dump = (d=0) => {
|
this.dump = (d=0) => {
|
||||||
if (this.text != null) {
|
if (this.text) {
|
||||||
print(this.text);
|
print(this.text);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (this.innerHTML) {
|
||||||
|
print(this.innerHTML);
|
||||||
|
return
|
||||||
|
}
|
||||||
std.printf("<%s", this.tagName)
|
std.printf("<%s", this.tagName)
|
||||||
// Set.difference(other) is not avalable in qjs
|
// Set.difference(other) is not avalable in qjs
|
||||||
for (a of Object.keys(this)) {
|
for (a of Object.keys(this)) {
|
||||||
@@ -53,6 +56,8 @@ document.getElementById = (_id) => { return target}
|
|||||||
document.createElement = (tag) => new Node(null, tag);
|
document.createElement = (tag) => new Node(null, tag);
|
||||||
document.createTextNode = (text) => { t = new Node(null, "#text" ); t.text = text; return t }
|
document.createTextNode = (text) => { t = new Node(null, "#text" ); t.text = text; return t }
|
||||||
|
|
||||||
|
var global = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// here will come the Elm app code
|
// here will come the Elm app code
|
||||||
|
|||||||
Reference in New Issue
Block a user