Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

fix(cssom): serialize computed flex flow

ldm0e5a78a355dcc
diff --git a/moli-renderer-v8/src/native_bridge/element/styles/declaration/values.rs b/moli-renderer-v8/src/native_bridge/element/styles/declaration/values.rs
index 1ba3c973e..587706668 100644
--- a/moli-renderer-v8/src/native_bridge/element/styles/declaration/values.rs
+++ b/moli-renderer-v8/src/native_bridge/element/styles/declaration/values.rs
@@ -2368,6 +2368,13 @@ fn computed_style_property_value_after_style_update(
if property == "transition" {
return computed_transition_shorthand_value(runtime, handle, context);
}
+ if property == "flex-flow" {
+ let direction =
+ computed_style_property_value_with_context(runtime, handle, "flex-direction", context);
+ let wrap =
+ computed_style_property_value_with_context(runtime, handle, "flex-wrap", context);
+ return format!("{direction} {wrap}");
+ }
if property == "text-decoration" {
return computed_text_decoration_shorthand_value(runtime, handle, context);
}
diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/cssom.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/cssom.rs
index 09c173892..fa4537a5d 100644
--- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/cssom.rs
+++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/cssom.rs
@@ -4997,6 +4997,40 @@ fn computed_css_style_declaration_is_read_only() {
"true|NoModificationAllowedError:7|NoModificationAllowedError:7|NoModificationAllowedError:7|NoModificationAllowedError:7|NoModificationAllowedError:7"
);
}
+
+#[test]
+fn computed_flex_flow_serializes_direction_and_wrap() {
+ let mut vm = new_storage_test_vm("https://computed-flex-flow.test/");
+
+ let result = vm
+ .eval(
+ r#"
+(() => {
+ const target = document.createElement('div');
+ (document.body || document.documentElement || document).appendChild(target);
+ const values = [
+ 'initial',
+ 'column',
+ 'wrap',
+ 'column wrap-reverse',
+ 'row-reverse wrap'
+ ];
+ return values.map(value => {
+ target.style.flexFlow = value;
+ const computed = getComputedStyle(target);
+ return [computed.flexFlow, computed.flexDirection, computed.flexWrap].join('|');
+ }).join('/');
+})()
+"#,
+ )
+ .expect("computed flex-flow serialization should evaluate");
+
+ assert_eq!(
+ result,
+ "row nowrap|row|nowrap/column nowrap|column|nowrap/row wrap|row|wrap/column wrap-reverse|column|wrap-reverse/row-reverse wrap|row-reverse|wrap"
+ );
+}
+
#[test]
fn css_media_rule_exposes_mutable_media_list() {
let mut vm = new_storage_test_vm("https://css-media-list.test/");