dom.openOrClosedShadowRoot()
获取指定元素的开放或封闭的影子根。如果影子根未附加到该元素,则返回 null
。
备注:
在 Firefox 中,等效属性是 element.openOrClosedShadowRoot
。该只读属性表示元素所承载的影子 DOM,无论其 mode
是 open
还是 closed
。
使用 Element.attachShadow()
将影子 DOM 添加到元素中。
语法
js
let shadowRoot = browser.dom.openOrClosedShadowRoot(
element, // HTMLElement
)
参数
element
-
HTMLElement
。宿主元素。
返回值
一个 ShadowRoot
对象实例,无论其 mode
设置为 open
还是 closed
,如果没有影子 DOM,则返回 null
。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
openOrClosedShadowRoot |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
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.