dumb ass tryfrom
This commit is contained in:
parent
028f8805b2
commit
2827ddbec3
2 changed files with 9 additions and 7 deletions
|
@ -147,7 +147,7 @@ impl Visitor {
|
|||
match node {
|
||||
TaggedRsx::Elem(_, Elem { tag, attrs, inner }) => {
|
||||
self.impl_code.extend(quote! {
|
||||
fn #make_node_id(&self) -> impl stdweb::web::IElement {
|
||||
fn #make_node_id(&self) -> impl stdweb::web::INode {
|
||||
let el = document().create_element(#tag).unwrap();
|
||||
el
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ impl Visitor {
|
|||
TaggedRsx::Code(_, expr) => {
|
||||
self.impl_code.extend(quote! {
|
||||
#[inline]
|
||||
fn #make_node_id(&self) -> impl stdweb::web::IElement {
|
||||
fn #make_node_id(&self) -> impl stdweb::web::INode {
|
||||
let el = document().create_element("span").expect("shouldn't fail");
|
||||
el.set_attribute("id", #node_id);
|
||||
el
|
||||
|
@ -167,10 +167,12 @@ impl Visitor {
|
|||
TaggedRsx::Text(_, literal) => {
|
||||
self.impl_code.extend(quote! {
|
||||
#[inline]
|
||||
fn #make_node_id(&self) -> impl stdweb::web::IElement {
|
||||
let el = document().create_element("span").expect("shouldn't fail");
|
||||
el.set_text_content(#literal);
|
||||
el
|
||||
fn #make_node_id(&self) -> impl stdweb::web::INode {
|
||||
use stdweb::unstable::TryFrom;
|
||||
let string: Value = #literal.into();
|
||||
let reference = Reference::try_from(string).unwrap();
|
||||
let node = TextNode::try_from(reference).unwrap();
|
||||
node
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ extern crate stdweb;
|
|||
|
||||
mod backend;
|
||||
|
||||
use stdweb::web::{document, Element, IElement, INode, INonElementParentNode};
|
||||
use stdweb::{web::{document, Element, IElement, INode, TextNode, INonElementParentNode}, Reference, Value};
|
||||
|
||||
use crate::backend::{Backend, Web};
|
||||
|
||||
|
|
Loading…
Reference in a new issue