From 844abbc132b1b35546d40a55335c94f214ac6cb3 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Mon, 2 Dec 2024 14:12:18 +1300 Subject: [PATCH] Preserve more style state when flushing pseudo-elements --- packages/blitz-dom/src/layout/construct.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/blitz-dom/src/layout/construct.rs b/packages/blitz-dom/src/layout/construct.rs index 77bf8bac..c2e0243b 100644 --- a/packages/blitz-dom/src/layout/construct.rs +++ b/packages/blitz-dom/src/layout/construct.rs @@ -345,20 +345,12 @@ fn flush_pseudo_elements(doc: &mut Document, node_id: usize) { // TODO: Update content let mut node_styles = doc.nodes[pe_node_id].stylo_element_data.borrow_mut(); + let node_styles = &mut node_styles.as_mut().unwrap(); + let primary_styles = &mut node_styles.styles.primary; - if &**(*node_styles) - .as_ref() - .unwrap() - .styles - .primary - .as_ref() - .unwrap() as *const _ - != &*pe_style as *const _ - { - let mut element_data = ElementData::default(); - element_data.styles.primary = Some(pe_style); - element_data.set_restyled(); - *node_styles = Some(element_data); + if &**primary_styles.as_ref().unwrap() as *const _ != &*pe_style as *const _ { + *primary_styles = Some(pe_style); + node_styles.set_restyled(); } } }