aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris2023-02-19 13:23:19 +0100
committerJoris2023-02-19 13:25:52 +0100
commit46950ed9e9f513c37366347e8eb7cc5295591864 (patch)
treef496ad6ee322906b6ccd4b5148519646b40dab4b
parent0267049f29374f0114bef23a5982c930c4d2bedb (diff)
downloadrx-46950ed9e9f513c37366347e8eb7cc5295591864.tar.gz
rx-46950ed9e9f513c37366347e8eb7cc5295591864.tar.bz2
rx-46950ed9e9f513c37366347e8eb7cc5295591864.zip
Fix setting an attribute to false
-rw-r--r--src/example.ts16
-rw-r--r--src/rx.ts10
2 files changed, 23 insertions, 3 deletions
diff --git a/src/example.ts b/src/example.ts
index 229d3a0..0870f4e 100644
--- a/src/example.ts
+++ b/src/example.ts
@@ -185,9 +185,23 @@ const seq =
)
)
+const indirectCheckbox =
+ withState(false, checked => [
+ checkboxComponent({
+ label: 'C1',
+ isChecked: checked,
+ onCheck: (b: boolean) => checked.update(_ => b)
+ }),
+ checkboxComponent({
+ label: 'C2',
+ isChecked: checked,
+ onCheck: (b: boolean) => checked.update(_ => b)
+ })
+ ])
+
const view = h('main',
h('h1', 'Rx'),
- chrono
+ indirectCheckbox
)
mount(view)
diff --git a/src/rx.ts b/src/rx.ts
index a83c915..221dcfc 100644
--- a/src/rx.ts
+++ b/src/rx.ts
@@ -463,11 +463,17 @@ function appendNode(base: Element, node: Node, lastAdded?: Node) {
}
function setAttribute(state: State, element: Element, key: string, attribute: AttributeValue) {
- if (attribute === undefined || attribute === false) {
+ if (attribute === undefined) {
// Do nothing
} else if (attribute === true) {
// @ts-ignore
- element[key] = "true"
+ element[key] = 'true'
+ } else if (attribute === false) {
+ // @ts-ignore
+ if (key in element) {
+ // @ts-ignore
+ element[key] = false
+ }
} else if (typeof attribute === "number") {
// @ts-ignore
element[key] = attribute.toString()