Skip to content

Commit

Permalink
Input demo
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-gu committed Jan 28, 2024
1 parent 4bd4518 commit b8235ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 14 additions & 1 deletion examples/demo.basic
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
val = ""

1 CLEAR
OPEN h1
PRINT "This is a demo app!"
CLOSE

OPEN p
PRINT "You typed: "
PRINT val
CLOSE
OPEN input
BIND value val
ATTRIBUTE onchange GOTO 1
CLOSE


i = 1
10 IF i = 11 THEN 20
10 IF i = 21 THEN 20
OPEN p
PRINT "Line #"
PRINT i
Expand Down
6 changes: 5 additions & 1 deletion runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,18 @@ function renderNode(
};
}
}
res.onchange = (e) => {
const last = res.onchange;
res.onchange = function (e) {
for (const [key, value] of node.bindings.entries()) {
const v: string = (e.target as any)[key];
value({
type: "string",
value: v,
});
}
if (last !== null) {
(last as any)(e);
}
};
res.replaceChildren(...node.content.map((n) => renderNode(prog, ctx, n)));
return res;
Expand Down

0 comments on commit b8235ea

Please sign in to comment.