Fix field access on styled element

Fixes #1197
This commit is contained in:
Laurenz 2023-05-22 13:49:09 +02:00
parent 3d83960322
commit 8aa0ae197d
2 changed files with 8 additions and 1 deletions

View File

@ -177,7 +177,7 @@ impl Content {
pub fn field(&self, name: &str) -> Option<Value> {
if let (Some(iter), "children") = (self.to_sequence(), name) {
Some(Value::Array(iter.cloned().map(Value::Content).collect()))
} else if let (Some((child, _)), "child") = (self.to_styled(), "child") {
} else if let (Some((child, _)), "child") = (self.to_styled(), name) {
Some(Value::Content(child.clone()))
} else {
self.field_ref(name).cloned()

View File

@ -56,3 +56,10 @@ _Visible_
---
// Test that incomplete label is text.
1 < 2 is #if 1 < 2 [not] a label.
---
// Test label on text, styled, and sequence.
// Ref: false
#test([Hello<hi>].label, <hi>)
#test([#[A *B* C]<hi>].label, <hi>)
#test([#text(red)[Hello]<hi>].label, <hi>)