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 {
|
match node {
|
||||||
TaggedRsx::Elem(_, Elem { tag, attrs, inner }) => {
|
TaggedRsx::Elem(_, Elem { tag, attrs, inner }) => {
|
||||||
self.impl_code.extend(quote! {
|
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();
|
let el = document().create_element(#tag).unwrap();
|
||||||
el
|
el
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ impl Visitor {
|
||||||
TaggedRsx::Code(_, expr) => {
|
TaggedRsx::Code(_, expr) => {
|
||||||
self.impl_code.extend(quote! {
|
self.impl_code.extend(quote! {
|
||||||
#[inline]
|
#[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");
|
let el = document().create_element("span").expect("shouldn't fail");
|
||||||
el.set_attribute("id", #node_id);
|
el.set_attribute("id", #node_id);
|
||||||
el
|
el
|
||||||
|
@ -167,10 +167,12 @@ impl Visitor {
|
||||||
TaggedRsx::Text(_, literal) => {
|
TaggedRsx::Text(_, literal) => {
|
||||||
self.impl_code.extend(quote! {
|
self.impl_code.extend(quote! {
|
||||||
#[inline]
|
#[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");
|
use stdweb::unstable::TryFrom;
|
||||||
el.set_text_content(#literal);
|
let string: Value = #literal.into();
|
||||||
el
|
let reference = Reference::try_from(string).unwrap();
|
||||||
|
let node = TextNode::try_from(reference).unwrap();
|
||||||
|
node
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ extern crate stdweb;
|
||||||
|
|
||||||
mod backend;
|
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};
|
use crate::backend::{Backend, Web};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue