1
0
mirror of https://codeberg.org/setop/elm-scripting synced 2025-11-08 21:49:57 +00:00

feat: can pass content as flags

This commit is contained in:
2025-10-15 12:19:11 +02:00
parent 6050fb02a3
commit a7b1b206be
10 changed files with 117 additions and 74 deletions

8
dom.js
View File

@@ -5,6 +5,11 @@ function Node(parent, tag) {
this.text = null;
// attributes are stored directly on the node object
// see https://github.com/elm/virtual-dom/blob/master/src/Elm/Kernel/VirtualDom.js#L511
// but Html.Attributes.attribute/2 uses Element.setAttribute
this.setAttribute = (key, val) => {
// as of now, there is no check if key conflict with the ones defined by Dom implementation
this[key] = val;
}
this.children = []; // List of Node
this.replaceChild = (newNode, domNode) => {
this.children[domNode.pos-1] = newNode;
@@ -16,6 +21,9 @@ function Node(parent, tag) {
this.appendChild = (node) => {
node.pos = this.children.push(node);
}
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);