The design language that makes your AI harness better at design.
JavaScript
Read one alignment keyword per axis for a centred initial
Paul Bakaus2a2a428139e0
diff --git a/crates/html/src/decorative_text.rs b/crates/html/src/decorative_text.rsindex d3d5659eb..9fe009815 100644--- a/crates/html/src/decorative_text.rs+++ b/crates/html/src/decorative_text.rs@@ -91,7 +91,16 @@ fn centred(host: &StaticElement<'_>, el: &StaticElement<'_>, height: f64) -> boo// A flex or grid box centres its text only when it says so on both axes:// `justify-content: flex-start` or `align-items: flex-start` leaves an// initial in a corner of the painted box.- let is_center = |prop: &str| js::to_lower_case(sv(style, prop)).split_whitespace().any(|t| t == "center");+ // One alignment keyword per axis. `place-items: var(--x)` reaches both+ // longhands whole, so a two-value result (`center stretch`) is read as+ // its first value for align-items and its last for justify-items;+ // `safe` and `unsafe` only qualify the keyword after them.+ let is_center = |prop: &str| {+ let value = js::to_lower_case(sv(style, prop));+ let tokens: Vec<&str> = value.split_whitespace().filter(|t| *t != "safe" && *t != "unsafe").collect();+ let token = if prop == "alignItems" { tokens.first() } else { tokens.last() };+ token == Some(&"center")+ };if matches!(display, "flex" | "inline-flex") && is_center("justifyContent") && is_center("alignItems") {return true;}diff --git a/crates/html/tests/low_contrast_advisory.rs b/crates/html/tests/low_contrast_advisory.rsindex 9455bd961..db78d3cd8 100644--- a/crates/html/tests/low_contrast_advisory.rs+++ b/crates/html/tests/low_contrast_advisory.rs@@ -172,6 +172,7 @@ fn an_initial_is_decorative_only_when_its_box_centres_it() {assert_eq!(scan_box("display: flex; align-items: center; justify-content: center;"), "advisory");assert_eq!(scan_box("display: grid; place-items: center;"), "advisory");assert_eq!(scan_box("--a: center; display: grid; place-items: var(--a);"), "advisory");+ assert_eq!(scan_box("--a: center stretch; display: grid; place-items: var(--a);"), "warning");// A flex or grid box that leaves the initial in a corner.assert_eq!(scan_box("display: flex; align-items: center; justify-content: flex-start;"), "warning");assert_eq!(scan_box("display: flex; align-items: flex-start; justify-content: center;"), "warning");