ShadowRoot.activeElement

activeElementShadowRoot インターフェイスの読み取り専用プロパティで、シャドウツリー内でフォーカスを持っている要素を返します。

構文

js

shadowRoot.activeElement

現在フォーカスを持っている Element、またはフォーカスを持っている要素がなければ null です。

js

let customElem = document.querySelector('my-shadow-dom-element');
let shadow = customElem.shadowRoot;
let focusedElem = shadow.activeElement;

仕様書

Specification
HTML Standard
# dom-documentorshadowroot-activeelement-dev

ブラウザーの互換性

BCD tables only load in the browser

関連情報