ShadowRoot:host 属性
ShadowRoot 的host 只读属性返回一个引用,指向附加了此 ShadowRoot 的 DOM 元素。
值
一个 DOM Element。
示例
js
const customElem = document.querySelector("my-shadow-dom-element");
const shadow = customElem.shadowRoot;
// …
// return the original host element some time later
const hostElem = shadow.host;
规范
| 规范 |
|---|
| DOM # dom-shadowroot-host |
浏览器兼容性
加载中…
另见
part和exportpartsHTML 属性<template>和<slot>HTML 元素:host、:host()和:host-context()CSS 伪类::part和::slottedCSS 伪元素