mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
Fix has
on non-inherent fields (#2745)
This commit is contained in:
parent
07ae4fb923
commit
e5470401f4
@ -731,12 +731,18 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream {
|
||||
quote! {
|
||||
<#elem as #model::ElementFields>::Fields::#name => None,
|
||||
}
|
||||
} else {
|
||||
} else if field.inherent() {
|
||||
quote! {
|
||||
<#elem as #model::ElementFields>::Fields::#name => Some(
|
||||
::typst::eval::IntoValue::into_value(self.#field_ident.clone())
|
||||
),
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
<#elem as #model::ElementFields>::Fields::#name => {
|
||||
self.#field_ident.clone().map(::typst::eval::IntoValue::into_value)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 24 KiB |
@ -1,3 +1,17 @@
|
||||
// Tests for field introspection.
|
||||
|
||||
---
|
||||
// Verify that non-inherent fields are hidden if not set.
|
||||
#show figure: it => [
|
||||
`repr(it)`: #repr(it) \
|
||||
`it.has("gap"): `#repr(it.has("gap")) \
|
||||
]
|
||||
|
||||
#figure[]
|
||||
|
||||
#figure([], gap: 1pt)
|
||||
|
||||
---
|
||||
// Integrated test for content fields.
|
||||
|
||||
#let compute(equation, ..vars) = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user