Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<meta charset="UTF-8">
<title>XPathResult singleNodeValue should be nullable</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div id="div">
<span id="exist"></span>
</div>
<script>
test(() => {
const div = document.getElementById('div');
const isNull = document.evaluate(
'//non-span',
div,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null
);
assert_equals(isNull.singleNodeValue, null);
const isNotNull = document.evaluate(
'//span',
div,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null
);
assert_not_equals(isNotNull.singleNodeValue, null);
}, 'singleNodeValue should be nullable');
</script>
</body>