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! {
|
quote! {
|
||||||
<#elem as #foundations::ElementFields>::Fields::#name => None,
|
<#elem as #foundations::ElementFields>::Fields::#name => None,
|
||||||
}
|
}
|
||||||
} else if field.inherent() {
|
} else if field.inherent() || (field.synthesized && field.default.is_some()) {
|
||||||
quote! {
|
quote! {
|
||||||
<#elem as #foundations::ElementFields>::Fields::#name => Some(
|
<#elem as #foundations::ElementFields>::Fields::#name => Some(
|
||||||
#foundations::IntoValue::into_value(self.#field_ident.clone())
|
#foundations::IntoValue::into_value(self.#field_ident.clone())
|
||||||
@ -748,7 +748,7 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream {
|
|||||||
quote! {
|
quote! {
|
||||||
<#elem as #foundations::ElementFields>::Fields::#name => false,
|
<#elem as #foundations::ElementFields>::Fields::#name => false,
|
||||||
}
|
}
|
||||||
} else if field.inherent() {
|
} else if field.inherent() || (field.synthesized && field.default.is_some()) {
|
||||||
quote! {
|
quote! {
|
||||||
<#elem as #foundations::ElementFields>::Fields::#name => true,
|
<#elem as #foundations::ElementFields>::Fields::#name => true,
|
||||||
}
|
}
|
||||||
@ -867,6 +867,14 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream {
|
|||||||
quote! { ::ecow::EcoString::inline(#name).into() }
|
quote! { ::ecow::EcoString::inline(#name).into() }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if field.synthesized && field.default.is_some() {
|
||||||
|
quote! {
|
||||||
|
fields.insert(
|
||||||
|
#field_call,
|
||||||
|
#foundations::IntoValue::into_value(self.#field_ident.clone())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
quote! {
|
quote! {
|
||||||
if let Some(value) = &self.#field_ident {
|
if let Some(value) = &self.#field_ident {
|
||||||
fields.insert(
|
fields.insert(
|
||||||
@ -875,6 +883,7 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let location = element
|
let location = element
|
||||||
|
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