mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
parent
9926a594e7
commit
7f10d3282e
@ -723,7 +723,7 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream {
|
||||
quote! {
|
||||
<#elem as #foundations::ElementFields>::Fields::#name => None,
|
||||
}
|
||||
} else if field.inherent() {
|
||||
} else if field.inherent() || (field.synthesized && field.default.is_some()) {
|
||||
quote! {
|
||||
<#elem as #foundations::ElementFields>::Fields::#name => Some(
|
||||
#foundations::IntoValue::into_value(self.#field_ident.clone())
|
||||
@ -748,7 +748,7 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream {
|
||||
quote! {
|
||||
<#elem as #foundations::ElementFields>::Fields::#name => false,
|
||||
}
|
||||
} else if field.inherent() {
|
||||
} else if field.inherent() || (field.synthesized && field.default.is_some()) {
|
||||
quote! {
|
||||
<#elem as #foundations::ElementFields>::Fields::#name => true,
|
||||
}
|
||||
@ -867,13 +867,22 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream {
|
||||
quote! { ::ecow::EcoString::inline(#name).into() }
|
||||
};
|
||||
|
||||
quote! {
|
||||
if let Some(value) = &self.#field_ident {
|
||||
if field.synthesized && field.default.is_some() {
|
||||
quote! {
|
||||
fields.insert(
|
||||
#field_call,
|
||||
#foundations::IntoValue::into_value(value.clone())
|
||||
#foundations::IntoValue::into_value(self.#field_ident.clone())
|
||||
);
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
if let Some(value) = &self.#field_ident {
|
||||
fields.insert(
|
||||
#field_call,
|
||||
#foundations::IntoValue::into_value(value.clone())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
9
tests/typ/bugs/2821-missing-fields.typ
Normal file
9
tests/typ/bugs/2821-missing-fields.typ
Normal file
@ -0,0 +1,9 @@
|
||||
// Issue #2821: Setting a figure's supplement to none removes the field
|
||||
// Ref: false
|
||||
|
||||
---
|
||||
#show figure.caption: it => {
|
||||
assert(it.has("supplement"))
|
||||
assert(it.supplement == none)
|
||||
}
|
||||
#figure([], caption: [], supplement: none)
|
Loading…
x
Reference in New Issue
Block a user