diff options
Diffstat (limited to 'files/zh-cn/web/api/documentorshadowroot/index.html')
-rw-r--r-- | files/zh-cn/web/api/documentorshadowroot/index.html | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/documentorshadowroot/index.html b/files/zh-cn/web/api/documentorshadowroot/index.html new file mode 100644 index 0000000000..0e3dd27717 --- /dev/null +++ b/files/zh-cn/web/api/documentorshadowroot/index.html @@ -0,0 +1,78 @@ +--- +title: DocumentOrShadowRoot +slug: Web/API/DocumentOrShadowRoot +tags: + - API + - DocumentOrShadowRoot + - Interface + - NeedsTranslation + - Reference + - TopicStub + - shadow dom +translation_of: Web/API/DocumentOrShadowRoot +--- +<div>{{APIRef("Web Components")}}</div> + +<p><span class="seoSummary"><a href="/zh-CN/docs/Web/Web_Components/Using_shadow_DOM">Shadow DOM API</a> 的 <strong><code>DocumentOrShadowRoot</code></strong> 接口提供了 documents 与 shadow roots 之间共享的 API。The following features are included in both {{DOMxRef("Document")}} and {{DOMxRef("ShadowRoot")}}.</span></p> + +<h2 id="属性">属性</h2> + +<dl> + <dt>{{DOMxRef("DocumentOrShadowRoot.activeElement")}}{{ReadOnlyInline}}</dt> + <dd>Returns the {{DOMxRef('Element')}} within the shadow tree that has focus.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.fullscreenElement")}}{{ReadOnlyInline}}</dt> + <dd>Returns the {{DOMxRef('Element')}} that's currently in full screen mode for this document.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.pointerLockElement")}} {{Experimental_Inline}}{{ReadOnlyInline}}</dt> + <dd>Returns the element set as the target for mouse events while the pointer is locked. It returns <code>null</code> if lock is pending, the pointer is unlocked, or if the target is in another document.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.styleSheets")}}{{ReadOnlyInline}}</dt> + <dd>Returns a {{DOMxRef('StyleSheetList')}} of {{DOMxRef('CSSStyleSheet')}} objects for stylesheets explicitly linked into, or embedded in a document.</dd> +</dl> + +<h2 id="方法">方法</h2> + +<dl> + <dt>{{DOMxRef("DocumentOrShadowRoot.caretPositionFromPoint()")}}</dt> + <dd>Returns a {{DOMxRef('CaretPosition')}} object containing the DOM node containing the caret, and caret's character offset within that node.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.elementFromPoint()")}}</dt> + <dd>Returns the topmost element at the specified coordinates.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.elementsFromPoint()")}}</dt> + <dd>Returns an array of all elements at the specified coordinates.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.getSelection()")}}</dt> + <dd>Returns a {{DOMxRef('Selection')}} object representing the range of text selected by the user, or the current position of the caret.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.nodeFromPoint()")}} {{non-standard_inline}}</dt> + <dd>Returns the topmost node at the specified coordinates.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.nodesFromPoint()")}} {{non-standard_inline}}</dt> + <dd>Returns an array of all nodes at the specified coordinates.</dd> +</dl> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('Shadow DOM','#extensions-to-the-documentorshadowroot-mixin','DocumentOrShadowRoot')}}</td> + <td>{{Spec2('Shadow DOM')}}</td> + <td>Implementation in Shadow DOM.</td> + </tr> + <tr> + <td>{{SpecName('DOM WHATWG','#mixin-documentorshadowroot','DocumentOrShadowRoot')}}</td> + <td>{{Spec2('DOM WHATWG')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("api.DocumentOrShadowRoot")}}</p> + +<p>[1] This interface's features are still implemented on the {{DOMxRef("Document")}} object.</p> |