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.
La propriété host
est une propriété en lecture seule, rattachée à l'interface ShadowRoot
et qui représente une référence à l'élément du DOM auquel la racine ShadowRoot
est attachée.
Syntaxe
js
var element = shadowRoot.host;
Valeur
Un élément du DOM sous la forme d'un objet Element
.
Exemples
js
let customElem = document.querySelector('mon-element-shadow-dom');
let shadow = customElem.shadowRoot;
...
// renvoie l'élément hôte
let hostElem = shadow.host;
Spécifications
Specification |
---|
DOM # dom-shadowroot-host |
Compatibilité des navigateurs
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
host |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.