Skip to content

Commit

Permalink
fix input.value set; tag 0.1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Jul 29, 2024
1 parent 8828505 commit 402fef7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion respo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "respo"
version = "0.1.9"
version = "0.1.10"
edition = "2021"
description = "a tiny virtual DOM library migrated from ClojureScript"
license = "Apache-2.0"
Expand Down
27 changes: 16 additions & 11 deletions respo/src/app/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::sync::RwLock;

use wasm_bindgen::{JsCast, JsValue};
use web_sys::console::{error_1, warn_1};
use web_sys::{HtmlElement, HtmlLabelElement, Node};
use web_sys::{HtmlElement, HtmlLabelElement, HtmlTextAreaElement, Node};

use crate::app::diff::{collect_effects_outside_in_as, diff_tree};
use crate::app::patch::{attach_event, patch_tree};
Expand Down Expand Up @@ -240,16 +240,21 @@ where
let element = document.create_element(name)?;
for (key, value) in attrs {
let key = key.as_ref();
if key == "style" {
warn_1(&"style is handled outside attrs".into());
} else if key == "innerText" {
element.dyn_ref::<HtmlElement>().expect("into html element").set_inner_text(value);
} else if key == "innerHTML" {
element.set_inner_html(value);
} else if key == "htmlFor" {
element.dyn_ref::<HtmlLabelElement>().ok_or("to label element")?.set_html_for(value);
} else {
element.set_attribute(key, value)?;
match key {
"style" => warn_1(&"style is handled outside attrs".into()),
"innerText" => element.dyn_ref::<HtmlElement>().expect("into html element").set_inner_text(value),
"innerHTML" => element.set_inner_html(value),
"htmlFor" => element
.dyn_ref::<HtmlLabelElement>()
.expect("into label element")
.set_html_for(value),
"value" if &**name == "textarea" || &**name == "input" => element
.dyn_ref::<HtmlTextAreaElement>()
.expect("into html element")
.set_value(value),
_ => {
element.set_attribute(key, value)?;
}
}
}
if !style.is_empty() {
Expand Down

0 comments on commit 402fef7

Please sign in to comment.