ShadowRoot.webidl (2917B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * The origin of this IDL file is 7 * https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html 8 * 9 * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C 10 * liability, trademark and document use rules apply. 11 */ 12 13 // https://dom.spec.whatwg.org/#enumdef-shadowrootmode 14 enum ShadowRootMode { 15 "open", 16 "closed" 17 }; 18 19 enum SlotAssignmentMode { "manual", "named" }; 20 21 // https://dom.spec.whatwg.org/#shadowroot 22 [Exposed=Window] 23 interface ShadowRoot : DocumentFragment 24 { 25 // Shadow DOM v1 26 readonly attribute ShadowRootMode mode; 27 readonly attribute boolean delegatesFocus; 28 readonly attribute SlotAssignmentMode slotAssignment; 29 readonly attribute boolean clonable; 30 readonly attribute boolean serializable; 31 readonly attribute Element host; 32 attribute EventHandler onslotchange; 33 34 [Pref="dom.shadowdom.referenceTarget.enabled"] 35 attribute DOMString referenceTarget; 36 37 Element? getElementById(DOMString elementId); 38 39 // https://w3c.github.io/DOM-Parsing/#the-innerhtml-mixin 40 [CEReactions, SetterThrows, SetterNeedsSubjectPrincipal=NonSystem] 41 attribute (TrustedHTML or [LegacyNullToEmptyString] DOMString) innerHTML; 42 43 // When JS invokes importNode or createElement, the binding code needs to 44 // create a reflector, and so invoking those methods directly on the content 45 // document would cause the reflector to be created in the content scope, 46 // at which point it would be difficult to move into the UA Widget scope. 47 // As such, these methods allow UA widget code to simultaneously create nodes 48 // and associate them with the UA widget tree, so that the reflectors get 49 // created in the right scope. 50 [CEReactions, Throws, Func="IsChromeOrUAWidget"] 51 Node importNodeAndAppendChildAt(Node parentNode, Node node, optional boolean deep = false); 52 53 [CEReactions, Throws, Func="IsChromeOrUAWidget"] 54 Node createElementAndAppendChildAt(Node parentNode, DOMString localName); 55 56 // For triggering UA Widget scope in tests. 57 [ChromeOnly] 58 undefined setIsUAWidget(); 59 [ChromeOnly] 60 boolean isUAWidget(); 61 }; 62 63 // Sanitizer API, https://wicg.github.io/sanitizer-api/ 64 partial interface ShadowRoot { 65 [Throws, Pref="dom.security.sanitizer.enabled"] 66 undefined setHTML(DOMString aInnerHTML, optional SetHTMLOptions options = {}); 67 }; 68 69 partial interface ShadowRoot { 70 // https://html.spec.whatwg.org/#dom-shadowroot-sethtmlunsafe 71 [NeedsSubjectPrincipal=NonSystem, Throws] 72 undefined setHTMLUnsafe((TrustedHTML or DOMString) html, optional SetHTMLUnsafeOptions options = {}); 73 DOMString getHTML(optional GetHTMLOptions options = {}); 74 }; 75 76 ShadowRoot includes DocumentOrShadowRoot;