Fix attribute value in macro (#577)

* create into AttributeValue trait to allow arbitraty attribute values

* allow attributevalue in non-template macro
This commit is contained in:
Demonthos authored and GitHub committed 2022-10-12 20:43:37 -07:00
1 parent e8c48d46cf
commit ab10d327ac
4 files changed
+156 -40

No files matched your search

+5 -17
View File
@@ -421,10 +421,7 @@ impl TemplateBuilder {
element_tag: el.name.clone(),
name: AttributeName::Ident(name),
value: TemplateAttributeValue::Dynamic(
self.dynamic_context.add_attr(quote!(AttributeValue::Text(
dioxus::core::exports::bumpalo::format!(in __bump, "{}", #value)
.into_bump_str()
))),
self.dynamic_context.add_attr(quote!(#value)),
),
})
}
@@ -443,10 +440,7 @@ impl TemplateBuilder {
element_tag: el.name.clone(),
name: AttributeName::Str(name),
value: TemplateAttributeValue::Dynamic(
self.dynamic_context.add_attr(quote!(AttributeValue::Text(
dioxus::core::exports::bumpalo::format!(in __bump, "{}", #value)
.into_bump_str()
))),
self.dynamic_context.add_attr(quote!(#value)),
),
})
}
@@ -456,10 +450,7 @@ impl TemplateBuilder {
element_tag: el.name.clone(),
name: AttributeName::Ident(name),
value: TemplateAttributeValue::Dynamic(
self.dynamic_context.add_attr(quote!(AttributeValue::Text(
dioxus::core::exports::bumpalo::format!(in __bump, "{}", #value)
.into_bump_str()
))),
self.dynamic_context.add_attr(quote!(#value)),
),
})
}
@@ -468,10 +459,7 @@ impl TemplateBuilder {
element_tag: el.name.clone(),
name: AttributeName::Str(name),
value: TemplateAttributeValue::Dynamic(
self.dynamic_context.add_attr(quote!(AttributeValue::Text(
dioxus::core::exports::bumpalo::format!(in __bump, "{}", #value)
.into_bump_str()
))),
self.dynamic_context.add_attr(quote!(#value)),
),
})
}
@@ -879,7 +867,7 @@ impl ToTokens for DynamicTemplateContextBuilder {
TemplateContext {
nodes: __cx.bump().alloc([#(#nodes),*]),
text_segments: __cx.bump().alloc([#(&*dioxus::core::exports::bumpalo::format!(in __bump, "{}", #text).into_bump_str()),*]),
attributes: __cx.bump().alloc([#(#attributes),*]),
attributes: __cx.bump().alloc([#({#attributes}.into_value(__cx.bump())),*]),
listeners: __cx.bump().alloc([#(dioxus_elements::on::#listeners_names(__cx, #listeners_exprs)),*]),
key: #key,
}