report error on unknown attribute
This commit is contained in:
1 parent
71d31556e5
commit
c614506734
1 file changed
+10
-1
@@ -1,6 +1,7 @@
|
|||||||
use dioxus_core::{Attribute, AttributeValue, NodeFactory, VNode};
|
use dioxus_core::{Attribute, AttributeValue, NodeFactory, VNode};
|
||||||
use dioxus_rsx::{BodyNode, CallBody, ElementAttr, IfmtInput, Segment};
|
use dioxus_rsx::{BodyNode, CallBody, ElementAttr, IfmtInput, Segment};
|
||||||
use quote::ToTokens;
|
use quote::ToTokens;
|
||||||
|
use quote::__private::Span;
|
||||||
use syn::{parse2, parse_str, Expr};
|
use syn::{parse2, parse_str, Expr};
|
||||||
|
|
||||||
use crate::attributes::attrbute_to_static_str;
|
use crate::attributes::attrbute_to_static_str;
|
||||||
@@ -78,13 +79,15 @@ fn build_node<'a>(
|
|||||||
for attr in &el.attributes {
|
for attr in &el.attributes {
|
||||||
match &attr.attr {
|
match &attr.attr {
|
||||||
ElementAttr::AttrText { .. } | ElementAttr::CustomAttrText { .. } => {
|
ElementAttr::AttrText { .. } | ElementAttr::CustomAttrText { .. } => {
|
||||||
let (name, value): (String, InterpertedIfmt) = match &attr.attr {
|
let (name, value, span): (String, InterpertedIfmt, Span) = match &attr.attr
|
||||||
|
{
|
||||||
ElementAttr::AttrText { name, value } => (
|
ElementAttr::AttrText { name, value } => (
|
||||||
name.to_string(),
|
name.to_string(),
|
||||||
InterpertedIfmt(
|
InterpertedIfmt(
|
||||||
IfmtInput::from_str(&value.value())
|
IfmtInput::from_str(&value.value())
|
||||||
.map_err(|err| Error::ParseError(err))?,
|
.map_err(|err| Error::ParseError(err))?,
|
||||||
),
|
),
|
||||||
|
name.span(),
|
||||||
),
|
),
|
||||||
ElementAttr::CustomAttrText { name, value } => (
|
ElementAttr::CustomAttrText { name, value } => (
|
||||||
name.value(),
|
name.value(),
|
||||||
@@ -92,6 +95,7 @@ fn build_node<'a>(
|
|||||||
IfmtInput::from_str(&value.value())
|
IfmtInput::from_str(&value.value())
|
||||||
.map_err(|err| Error::ParseError(err))?,
|
.map_err(|err| Error::ParseError(err))?,
|
||||||
),
|
),
|
||||||
|
name.span(),
|
||||||
),
|
),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
@@ -105,6 +109,11 @@ fn build_node<'a>(
|
|||||||
is_volatile: false,
|
is_volatile: false,
|
||||||
namespace,
|
namespace,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
return Err(Error::ParseError(syn::Error::new(
|
||||||
|
span,
|
||||||
|
"unknown attribute",
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user