ShadowRoot.host
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
host
は ShadowRoot
の読み取り専用プロパティで、 ShadowRoot
が取り付けられている DOM 要素の参照を返します。
構文
js
const someElement = shadowRoot.host;
値
DOM の Element
です。
例
js
let customElem = document.querySelector('my-shadow-dom-element');
let shadow = customElem.shadowRoot;
...
// 後で、元のホスト要素を返す
let hostElem = shadow.host;
仕様書
Specification |
---|
DOM Standard # dom-shadowroot-host |
ブラウザーの互換性
BCD tables only load in the browser