--- title: ShadowRoot.mode slug: Web/API/ShadowRoot/mode translation_of: Web/API/ShadowRoot/mode ---
mode
是 {{domxref("ShadowRoot")}} 的只读属性,它返回 ShadowRoot
创建时的模式 ("open
" 或者 "closed
") 。
当 ShadowRoot
的 mode
是 "closed
" 时, ShadowRoot
的内部实现无法被 JavaScript 访问及修改 — 也就是说将该实现不公开,例如,<video>
标签内部实现无法被 JavaScript 访问及修改。
var mode = shadowRoot.mode
值为 "open
" 或者 "closed
".
Specification | Status | Comment |
---|---|---|
{{SpecName('DOM WHATWG','#dom-shadowroot-mode','ShadowRoot.mode')}} | {{Spec2('DOM WHATWG')}} |
{{CompatibilityTable}}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 53 | {{CompatNo}}[1] | {{CompatNo}}[2] | {{CompatNo}} | 40 | 10 |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 53 | {{CompatNo}}[1] | {{CompatNo}}[2] | {{CompatNo}} | 40 | 10.1 |
[1] This feature is not implemented yet. See the Edge platform status.
[2] This feature is not implemented yet. See {{bug(1205323)}}.