Skip to content

Commit

Permalink
handle htmlFor property; alpha tag 0.0.12-a4
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Jun 8, 2022
1 parent 1bfba76 commit 3f831d5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 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.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "respo"
version = "0.0.12-a3"
version = "0.0.12-a4"
edition = "2021"
description = "a tiny virtual DOM library migrated from ClojureScript"
license = "Apache-2.0"
Expand Down Expand Up @@ -44,4 +44,5 @@ features = [
"HtmlCollection",
"CssStyleDeclaration",
"FocusEvent",
"HtmlLabelElement",
]
4 changes: 3 additions & 1 deletion src/respo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::sync::RwLock;

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

pub use alias::*;
pub use app_template::RespoApp;
Expand Down Expand Up @@ -235,6 +235,8 @@ where
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)?;
}
Expand Down
4 changes: 3 additions & 1 deletion src/respo/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::cmp::Ordering;
use std::fmt::Debug;

use wasm_bindgen::prelude::Closure;
use web_sys::{Element, FocusEvent, HtmlElement, HtmlInputElement, InputEvent, KeyboardEvent, MouseEvent, Node};
use web_sys::{Element, FocusEvent, HtmlElement, HtmlInputElement, HtmlLabelElement, InputEvent, KeyboardEvent, MouseEvent, Node};

use wasm_bindgen::JsCast;
use web_sys::console::warn_1;
Expand Down Expand Up @@ -44,6 +44,8 @@ where
el.dyn_ref::<HtmlElement>().ok_or("to html element")?.set_inner_text(v);
} else if k == "innerHTML" {
el.set_inner_html(v);
} else if k == "htmlFor" {
el.dyn_ref::<HtmlLabelElement>().ok_or("to label element")?.set_html_for(v);
} else if k == "value" {
let input_el = el.dyn_ref::<HtmlInputElement>().expect("to input");
let prev_value = input_el.value();
Expand Down

0 comments on commit 3f831d5

Please sign in to comment.