mirror of
https://codeberg.org/setop/elm-scripting
synced 2025-11-08 21:49:57 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5916566385 | |||
| 0758e1e9b4 |
42
dom.js
42
dom.js
@@ -14,7 +14,7 @@ function Node(parent, tag) {
|
||||
this.replaceChild = (newNode, domNode) => {
|
||||
this.children[domNode.pos-1] = newNode;
|
||||
newNode.pos = domNode.pos;
|
||||
};
|
||||
};
|
||||
if (parent != null) {
|
||||
this.pos = parent.children.push(this);
|
||||
}
|
||||
@@ -24,17 +24,17 @@ function Node(parent, tag) {
|
||||
this.replaceData = (offset, count, data) => {
|
||||
this.text = data; // elm runtime will always replace the whole text
|
||||
}
|
||||
this.dump = (d=0) => {
|
||||
if (this.text != null) {
|
||||
print(this.text);
|
||||
return
|
||||
}
|
||||
if (this.innerHTML) {
|
||||
print(this.innerHTML);
|
||||
return
|
||||
}
|
||||
std.printf("<%s", this.tagName)
|
||||
// Set.difference(other) is not avalable in qjs
|
||||
this.dump = (d=0) => {
|
||||
if (this.text != null) {
|
||||
print(this.text);
|
||||
return
|
||||
}
|
||||
if (this.innerHTML) {
|
||||
print(this.innerHTML);
|
||||
return
|
||||
}
|
||||
std.printf("<%s", this.tagName)
|
||||
// Set.difference(other) is not avalable in qjs
|
||||
for (a of Object.keys(this)) {
|
||||
if (!NodeKeys.has(a)) {
|
||||
std.printf(' %s="%s"', a, this[a])
|
||||
@@ -43,18 +43,18 @@ function Node(parent, tag) {
|
||||
if (this.children.length==0) {
|
||||
print("/>")
|
||||
} else {
|
||||
print(">")
|
||||
for (c of this.children) {
|
||||
c.dump(d+1)
|
||||
}
|
||||
print("</"+this.tagName+">");
|
||||
print(">")
|
||||
for (c of this.children) {
|
||||
c.dump(d+1)
|
||||
}
|
||||
print("</"+this.tagName+">");
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
var document = new Node(null, "document");
|
||||
var target = new Node(document, "target");
|
||||
const document = new Node(null, "document");
|
||||
const target = new Node(document, "target");
|
||||
const NodeKeys = new Set(Object.keys(target));
|
||||
|
||||
// getElementById is only used once, to get node Elm must hook into.
|
||||
@@ -67,6 +67,6 @@ document.createTextNode = (text) => { t = new Node(null, "#text" ); t.text = tex
|
||||
|
||||
|
||||
// workaround for elm-explorations/markdown Markdown.toHtml
|
||||
global = {};
|
||||
const global = {};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user