fix(js): preserve inline styles when cloning

This commit is contained in:
SGavrl committed 2026-08-01 15:41:45 +00:00
1 parent c327354911
commit 5d7a02041a
2 files changed
+26

No files matched your search

+22
View File
@@ -1369,6 +1369,28 @@ mod tests {
assert_eq!(out, serde_json::json!("7|0"));
}
#[test]
fn clone_node_copies_js_assigned_inline_styles() {
let mut rt = setup_runtime("<html><body><div id='d'></div></body></html>");
let out = rt
.evaluate(
"(function(){var d=document.getElementById('d');d.style.color='red';d.style.fontSize='12px';var c=d.cloneNode(false);return c.style.color+'|'+c.style.fontSize+'|'+c.style.cssText;})()",
)
.unwrap();
assert_eq!(out, serde_json::json!("red|12px|color: red; font-size: 12px;"));
}
#[test]
fn clone_node_deep_copies_template_content() {
let mut rt = setup_runtime("<html><body></body></html>");
let out = rt
.evaluate(
"(function(){var t=document.createElement('template');t.content.appendChild(document.createElement('option')).textContent='choice';var c=t.cloneNode(true);return c.content.childNodes.length+'|'+c.content.firstChild.tagName+'|'+c.content.firstChild.textContent;})()",
)
.unwrap();
assert_eq!(out, serde_json::json!("1|OPTION|choice"));
}
#[test]
fn test_document_title() {
let mut rt = setup_runtime("<html><head><title>Test</title></head><body></body></html>");