attributes-namednodemap-cross-document.window.js (1133B)
1 "use strict"; 2 3 test(() => { 4 const element = document.createElement("div"); 5 element.setAttribute("x", "first"); 6 const attribute = element.attributes[0]; 7 assert_equals(attribute.ownerDocument, document); 8 9 const otherDocument = new Document(); 10 const otherElement = otherDocument.createElement("other"); 11 assert_throws_dom("InUseAttributeError", () => otherElement.attributes.setNamedItem(attribute)); 12 13 element.removeAttribute("x"); 14 otherElement.attributes.setNamedItem(attribute); 15 assert_equals(attribute.ownerDocument, otherDocument); 16 }, "Moving an attribute between documents"); 17 18 test(() => { 19 const element = document.createElement("div"); 20 element.setAttribute("x", "first"); 21 const attribute = element.attributes[0]; 22 element.removeAttribute("x"); 23 24 const otherDocument = new Document(); 25 const otherElement = otherDocument.createElement("other"); 26 otherElement.setAttribute("x", "second"); 27 28 otherElement.attributes.setNamedItem(attribute); 29 assert_equals(attribute.ownerDocument, otherDocument); 30 assert_equals(otherElement.getAttribute("x"), "first"); 31 }, "Replacing an attribute across documents");