handle keys
This commit is contained in:
1 parent
94169083f5
commit
cef2f52058
2 files changed
+25
-9
No files matched your search
@@ -22,7 +22,7 @@ fn app(cx: Scope) -> Element {
|
|||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
div {
|
div {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "500px",
|
||||||
onclick: move |_| {
|
onclick: move |_| {
|
||||||
count.modify(|count| *count + 10);
|
count.modify(|count| *count + 10);
|
||||||
},
|
},
|
||||||
@@ -34,6 +34,7 @@ fn app(cx: Scope) -> Element {
|
|||||||
height: "50%",
|
height: "50%",
|
||||||
textarea {
|
textarea {
|
||||||
width: "90%",
|
width: "90%",
|
||||||
|
key: "1",
|
||||||
value: {
|
value: {
|
||||||
if rsx_code.get().is_none() {
|
if rsx_code.get().is_none() {
|
||||||
let rsx_text_index: RsxTextIndex = cx.consume_context().unwrap();
|
let rsx_text_index: RsxTextIndex = cx.consume_context().unwrap();
|
||||||
|
|||||||
@@ -203,14 +203,29 @@ fn build_node<'a>(
|
|||||||
}
|
}
|
||||||
let tag = bump.alloc(el.name.to_string());
|
let tag = bump.alloc(el.name.to_string());
|
||||||
if let Some((tag, ns)) = element_to_static_str(tag) {
|
if let Some((tag, ns)) = element_to_static_str(tag) {
|
||||||
Some(factory.raw_element(
|
match el.key {
|
||||||
tag,
|
None => Some(factory.raw_element(
|
||||||
ns,
|
tag,
|
||||||
listeners,
|
ns,
|
||||||
attributes.as_slice(),
|
listeners,
|
||||||
children.as_slice(),
|
attributes.as_slice(),
|
||||||
None,
|
children.as_slice(),
|
||||||
))
|
None,
|
||||||
|
)),
|
||||||
|
Some(lit) => {
|
||||||
|
let ifmt: InterperedIfmt = lit.value().parse().unwrap();
|
||||||
|
let key = bump.alloc(ifmt.resolve(&ctx.captured));
|
||||||
|
|
||||||
|
Some(factory.raw_element(
|
||||||
|
tag,
|
||||||
|
ns,
|
||||||
|
listeners,
|
||||||
|
attributes.as_slice(),
|
||||||
|
children.as_slice(),
|
||||||
|
Some(format_args!("{}", key)),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user