DocumentOrShadowRoot mixin of the Shadow DOM API provides APIs that are shared between documents and shadow roots. The following features are included in both Document and ShadowRoot .

特性

DocumentOrShadowRoot.activeElement 只读
返回 元素 within the shadow tree that has focus.
DocumentOrShadowRoot.fullscreenElement 只读
返回 元素 that's currently in full screen mode for this document.
DocumentOrShadowRoot.pointerLockElement 只读
Returns the element set as the target for mouse events while the pointer is locked. It returns null if lock is pending, the pointer is unlocked, or if the target is in another document.
DocumentOrShadowRoot.styleSheets 只读
返回 StyleSheetList of CSSStyleSheet objects for stylesheets explicitly linked into, or embedded in a document.

方法

DocumentOrShadowRoot.caretPositionFromPoint()
返回 CaretPosition object containing the DOM node containing the caret, and caret's character offset within that node.
DocumentOrShadowRoot.elementFromPoint()

Returns the topmost element at the specified coordinates.

DocumentOrShadowRoot.elementsFromPoint()

Returns an array of all elements at the specified coordinates.

DocumentOrShadowRoot.getSelection()
返回 Selection 对象,表示用户选择的文本范围或 ^ 插入符号的当前位置。
DocumentOrShadowRoot.nodeFromPoint()

Returns the topmost node at the specified coordinates.

DocumentOrShadowRoot.nodesFromPoint()

Returns an array of all nodes at the specified coordinates.

规范

规范 状态 注释
Shadow DOM
The definition of 'DocumentOrShadowRoot' in that specification.
过时 Implementation in Shadow DOM.
DOM
The definition of 'DocumentOrShadowRoot' in that specification.
实时标准 初始定义。

浏览器兼容性

The compatibility table in 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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
DocumentOrShadowRoot Chrome 53 Edge 12 Firefox Yes IE Yes Opera 40 Safari Yes WebView Android 53 Chrome Android 53 Firefox Android Yes Opera Android 41 Safari iOS Yes Samsung Internet Android 6.0
activeElement Chrome 53 Edge 12 Firefox 63 IE 4 Opera 40 Safari 4 WebView Android 53 Chrome Android 53 Firefox Android 63 Opera Android 41 Safari iOS 3.2 Samsung Internet Android 6.0
adoptedStyleSheets Chrome 73 Edge 79 Firefox No IE No Opera 60 Safari No WebView Android 73 Chrome Android 73 Firefox Android No Opera Android 50 Safari iOS No Samsung Internet Android 11.0
caretPositionFromPoint Chrome No Edge No Firefox 20 IE No Opera No Safari Yes WebView Android No Chrome Android No Firefox Android 20 Opera Android No Safari iOS Yes Samsung Internet Android No
elementFromPoint Chrome 53
53
Before Chrome 66, this method returned null when the element was a child of a host node. See issue 759947 .
Edge 12 Firefox 63 IE Yes Opera 40 Safari Yes WebView Android 53
53
Before WebView 66, this method returned null when the element was a child of a host node. See issue 759947 .
Chrome Android 53
53
Before Chrome 66, this method returned null when the element was a child of a host node. See issue 759947 .
Firefox Android 63 Opera Android 41 Safari iOS Yes Samsung Internet Android 6.0
6.0
Before Samsung Internet 9.0, this method returned null when the element was a child of a host node. See issue 759947 .
elementsFromPoint Chrome 53
53
Before Chrome 66, this method returned null when the element was a child of a host node. See issue 759947 .
Edge 12 Alternate Name
12 Alternate Name
返回 NodeList instead of an array. See the MSDN documentation 。返回 null when the point provided has no elements beneath it (e.g., when given a point outside the document).
Alternate Name Uses the non-standard name: msElementsFromPoint
Firefox 63 IE 10 Alternate Name
10 Alternate Name
返回 NodeList instead of an array. See the MSDN documentation 。返回 null when the point provided has no elements beneath it (e.g., when given a point outside the document).
Alternate Name Uses the non-standard name: msElementsFromPoint
Opera 40 Safari 12 WebView Android 53
53
Before WebView 66, this method returned null when the element was a child of a host node. See issue 759947 .
Chrome Android 53
53
Before Chrome 66, this method returned null when the element was a child of a host node. See issue 759947 .
Firefox Android 63 Opera Android 41 Safari iOS 12 Samsung Internet Android 6.0
6.0
Before Samsung Internet 9.0, this method returned null when the element was a child of a host node. See issue 759947 .
fullscreenElement Chrome 53 Prefixed
53 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge ≤18 Prefixed
≤18 Prefixed
Prefixed Implemented with the vendor prefix: webkit
12 Prefixed
Prefixed Implemented with the vendor prefix: ms
Firefox 64
64
不支持 47 — 65 Disabled
Disabled From version 47 until version 65 (exclusive): this feature is behind the full-screen-api.unprefix.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
不支持 9 — 65 Alternate Name
Alternate Name Uses the non-standard name: mozFullScreenElement
IE Yes Prefixed
Yes Prefixed
Prefixed Implemented with the vendor prefix: ms
Opera 40 Prefixed
40 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari Yes Prefixed
Yes Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android 53 Prefixed
53 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android 53 Prefixed
53 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 64
64
不支持 47 — 65 Disabled
Disabled From version 47 until version 65 (exclusive): this feature is behind the full-screen-api.unprefix.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
不支持 9 — 65 Alternate Name
Alternate Name Uses the non-standard name: mozFullScreenElement
Opera Android 41 Prefixed
41 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari iOS 部分支持 12 Alternate Name
部分支持 12 Alternate Name
Full-screen mode is only supported on the iPad.
Alternate Name Uses the non-standard name: webkitFullscreenElement
Samsung Internet Android 6.0 Prefixed
6.0 Prefixed
Prefixed Implemented with the vendor prefix: webkit
getSelection Chrome 53 Edge 12 Firefox 63 IE Yes Opera 40 Safari Yes WebView Android 53 Chrome Android 53 Firefox Android 63 Opera Android 41 Safari iOS Yes Samsung Internet Android 6.0
nodeFromPoint 非标 Chrome No Edge No Firefox No
不支持 No
Implemented in Firefox but currently only works in chrome code.
IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android No
不支持 No
Implemented in Firefox but currently only works in chrome code.
Opera Android No Safari iOS No Samsung Internet Android No
nodesFromPoint 非标 Chrome No Edge No Firefox No
不支持 No
Implemented in Firefox but currently only works in chrome code.
IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android No
不支持 No
Implemented in Firefox but currently only works in chrome code.
Opera Android No Safari iOS No Samsung Internet Android No
pointerLockElement Chrome 53 Edge 12 Firefox 63 IE Yes Opera 40 Safari Yes WebView Android 53 Chrome Android 53 Firefox Android 63 Opera Android 41 Safari iOS Yes Samsung Internet Android 6.0
styleSheets Chrome 53 Edge 12 Firefox 63 IE Yes Opera 40 Safari Yes WebView Android 53 Chrome Android 53 Firefox Android 63 Opera Android 41 Safari iOS Yes Samsung Internet Android 6.0

图例

完整支持

完整支持

部分支持

部分支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

使用非标名称。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

[1] This interface's features are still implemented on the Document 对象。

元数据

  • 最后修改: