From 28042c2e928024b48234827d3d8f871201f95dac Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 11 Nov 2026 09:47:33 -0800 Subject: [PATCH] JavaScript: test that new XML copies a list item's attributes and children The test for new XML with a one-item list now starts from an item that has a parent, an attribute and a child. It checks that the copy has no parent and that changing the copy's attribute and child leaves the original unchanged, so a copy that drops or shares the children fails. --- crates/js/src/xml_tests.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/js/src/xml_tests.rs b/crates/js/src/xml_tests.rs index bdcf79917..dce24d9d9 100644 --- a/crates/js/src/xml_tests.rs +++ b/crates/js/src/xml_tests.rs @@ -290,8 +290,10 @@ fn the_constructors_keep_identity_or_copy_as_specified() { truth("XML().nodeKind() === 'text' && XML(null) == '' && XML(undefined) == ''"); truth("var x = ; XML(x) === x && new XML(x) !== x && new XML(x) == x"); truth("var l = <>; XML(l) === l[0]"); - truth("var l = <>; var y = new XML(l); y !== l[0] && y == l[0] && y.parent() === null"); - truth("var l = <>; var y = new XML(l); y.@p = '1'; y.appendChild(); l[0].@p.length() === 0 && l[0].*.length() === 0"); + truth("var p =

; var l = p.a; var y = new XML(l); y !== l[0] && y == l[0] && y.parent() === null && l[0].parent() === p"); + truth( + "var p =

; var l = p.a; var y = new XML(l); y.@q = '2'; y.c.@r = '3'; l[0].@q == '1' && l[0].c.@r.length() === 0 && y.c.@r == '3'", + ); assert_eq!(thrown_name("XML(<>)"), "TypeError"); assert_eq!(thrown_name("XML('')"), "SyntaxError"); assert_eq!(thrown_name("XML('')"), "SyntaxError");