xpath-result-single-node-value-nullable.html (832B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>XPathResult singleNodeValue should be nullable</title> 4 <link rel=help href="https://dom.spec.whatwg.org/#dom-xpathresult-singlenodevalue"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <body> 8 <div id="div"> 9 <span id="exist"></span> 10 </div> 11 <script> 12 test(() => { 13 const div = document.getElementById('div'); 14 15 const isNull = document.evaluate( 16 '//non-span', 17 div, 18 null, 19 XPathResult.FIRST_ORDERED_NODE_TYPE, 20 null 21 ); 22 assert_equals(isNull.singleNodeValue, null); 23 24 const isNotNull = document.evaluate( 25 '//span', 26 div, 27 null, 28 XPathResult.FIRST_ORDERED_NODE_TYPE, 29 null 30 ); 31 assert_not_equals(isNotNull.singleNodeValue, null); 32 }, 'singleNodeValue should be nullable'); 33 </script> 34 </body>