ShadowRoot: thuộc tính 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.
Thuộc tính chỉ đọc host của ShadowRoot trả về tham chiếu đến phần tử DOM mà ShadowRoot được gắn vào.
Giá trị
Một Element DOM.
Ví dụ
js
const customElem = document.querySelector("my-shadow-dom-element");
const shadow = customElem.shadowRoot;
// …
// trả về phần tử host gốc sau một thời gian
const hostElem = shadow.host;
Thông số kỹ thuật
| Specification |
|---|
| DOM> # dom-shadowroot-host> |
Tương thích trình duyệt
Xem thêm
- Thuộc tính HTML
partvàexportparts - Các phần tử HTML
<template>và<slot> - Các pseudo-class CSS
:host,:host(), và:host-context() - Các pseudo-element CSS
::partvà::slotted