XPathResult: invalidIteratorState property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is available inWeb Workers.
The read-onlyinvalidIteratorState property of theXPathResult interface signifies that the iterator has become invalid. Itistrue ifXPathResult.resultType isUNORDERED_NODE_ITERATOR_TYPE orORDERED_NODE_ITERATOR_TYPE andthe document has been modified since this result was returned.
In this article
Value
A boolean value indicating whether the iterator has become invalid.
Examples
The following example shows the use of theinvalidIteratorState property.
HTML
html
<div>XPath example</div><p>Iterator state: <output></output></p>JavaScript
js
const xpath = "//div";const result = document.evaluate( xpath, document, null, XPathResult.ANY_TYPE, null,);// Invalidates the iterator statedocument.querySelector("div").remove();document.querySelector("output").textContent = result.invalidIteratorState ? "invalid" : "valid";Result
Specifications
| Specification |
|---|
| DOM> # dom-xpathresult-invaliditeratorstate> |