elements-are-parents-of-their-attributes.html (1376B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Relationship between elements and their attributes</title> 5 <link rel="author" title="Simon Wülker" href="mailto:simon.wuelker@arcor.de"> 6 <link rel="help" href="https://www.w3.org/TR/1999/REC-xpath-19991116/#attribute-nodes"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 </head> 10 <body> 11 <div id="context" foo="bar"></div> 12 <script> 13 const context = document.getElementById("context"); 14 15 test(() => { 16 const result = document.evaluate( 17 "@foo/parent::*", 18 context, 19 null, 20 XPathResult.ORDERED_NODE_ITERATOR_TYPE, 21 null 22 ); 23 24 assert_equals(result.iterateNext(), context); 25 assert_equals(result.iterateNext(), null); 26 }, "Elements are parents of their attributes"); 27 28 test(() => { 29 const result = document.evaluate( 30 "node()", 31 context, 32 null, 33 XPathResult.ORDERED_NODE_ITERATOR_TYPE, 34 null 35 ); 36 37 assert_equals(result.iterateNext(), null); 38 }, "Attributes are not children of their parents"); 39 </script> 40 </body> 41 </html>