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 white space shorthand

ldm075651a960b10
diff --git a/moli-renderer-v8/src/native_bridge/element/styles/declaration/parse.rs b/moli-renderer-v8/src/native_bridge/element/styles/declaration/parse.rs
index 03fa13e14..93a527b6e 100644
--- a/moli-renderer-v8/src/native_bridge/element/styles/declaration/parse.rs
+++ b/moli-renderer-v8/src/native_bridge/element/styles/declaration/parse.rs
@@ -1998,6 +1998,7 @@ fn cssom_style_shorthand_query_uses_pdb(name: &str) -> bool {
| "text-decoration"
| "text-emphasis"
| "transition"
+ | "white-space"
| "font"
| "font-variant"
| "-webkit-text-stroke"
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 fa4537a5d..fdb818e1b 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
@@ -13304,6 +13304,37 @@ fn css_style_declaration_serializes_animation_shorthand_from_longhands() {
);
}
+#[test]
+fn css_style_declaration_serializes_white_space_shorthand() {
+ let mut vm = new_storage_test_vm("https://css-style-white-space-shorthand.test/");
+
+ let result = vm
+ .eval(
+ r#"
+(() => {
+ const element = document.createElement('div');
+ const values = ['normal', 'pre', 'nowrap', 'pre-wrap', 'pre-line', 'inherit'];
+ const attributeValues = values.map(value => {
+ element.setAttribute('style', `white-space: ${value}`);
+ return [element.style.whiteSpace, element.style.getPropertyValue('white-space')].join('|');
+ });
+ const propertyValues = values.map(value => {
+ element.style.cssText = '';
+ element.style.whiteSpace = value;
+ return [element.style.whiteSpace, element.style.getPropertyValue('white-space')].join('|');
+ });
+ return [attributeValues.join(','), propertyValues.join(',')].join('/');
+})()
+"#,
+ )
+ .expect("white-space shorthand serialization should evaluate");
+
+ assert_eq!(
+ result,
+ "normal|normal,pre|pre,nowrap|nowrap,pre-wrap|pre-wrap,pre-line|pre-line,inherit|inherit/normal|normal,pre|pre,nowrap|nowrap,pre-wrap|pre-wrap,pre-line|pre-line,inherit|inherit"
+ );
+}
+
#[test]
fn css_style_declaration_shorthand_common_serialization_checks() {
let mut vm = new_storage_test_vm("https://css-style-shorthand-common.test/");