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 2020年1月.
host は ShadowRoot の読み取り専用プロパティで、 ShadowRoot が装着されている DOM 要素の参照を返します。
値
DOM の Element です。
例
js
let customElem = document.querySelector("my-shadow-dom-element");
let shadow = customElem.shadowRoot;
// ...
// 後で、元のホスト要素を返す
let hostElem = shadow.host;
仕様書
| Specification |
|---|
| DOM> # dom-shadowroot-host> |
ブラウザーの互換性
Loading…
関連情報
- HTML の
partおよびexportparts属性 - HTML の
<template>および<slot>要素 - CSS の
:host,:host(),:host-context()擬似クラス - CSS の
::partおよび::slotted擬似クラス