XPathResult: invalidIteratorState プロパティ

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.

invalidIteratorStateXPathResult インターフェイスの読み取り専用プロパティで、イテレーターが不正な状態になったことを示します。 XPathResult.resultTypeUNORDERED_NODE_ITERATOR_TYPE または ORDERED_NODE_ITERATOR_TYPE で、この結果を返してから文書が変更された場合は true です。

メモ: この機能はウェブワーカー内で利用可能です。

イテレーターが不正になったかどうかを示す論理値。

次の例では invalidIteratorState プロパティを使用しています。

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 state
document.querySelector("div").remove();
document.querySelector("output").textContent = result.invalidIteratorState
  ? "invalid"
  : "valid";

結果

仕様書

Specification
DOM
# dom-xpathresult-invaliditeratorstate

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
invalidIteratorState

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support