Skip to content

Truly independent web browser

5.0 KB
Raw Blame
// https://dom.spec.whatwg.org/#element
[Exposed=Window]
interface Element : Node {
    readonly attribute DOMString? namespaceURI;
    readonly attribute DOMString? prefix;
    readonly attribute DOMString localName;
    readonly attribute DOMString tagName;

    [CEReactions, Reflect] attribute DOMString id;
    [CEReactions, Reflect=class] attribute DOMString className;
    [SameObject, PutForwards=value] readonly attribute DOMTokenList classList;
    [CEReactions, Unscopable, Reflect] attribute DOMString slot;

    boolean hasAttributes();
    [SameObject] readonly attribute NamedNodeMap attributes;
    sequence<DOMString> getAttributeNames();
    DOMString? getAttribute(DOMString qualifiedName);
    DOMString? getAttributeNS([FlyString] DOMString? namespace, [FlyString] DOMString localName);
    [CEReactions, ImplementedInBindings] undefined setAttribute(DOMString qualifiedName, (TrustedType or DOMString) value);
    [CEReactions, ImplementedInBindings] undefined setAttributeNS([FlyString] DOMString? namespace, [FlyString] DOMString qualifiedName, (TrustedType or DOMString) value);
    [CEReactions] undefined removeAttribute([FlyString] DOMString qualifiedName);
    [CEReactions] undefined removeAttributeNS([FlyString] DOMString? namespace, [FlyString] DOMString localName);
    [CEReactions] boolean toggleAttribute(DOMString qualifiedName, optional boolean force);
    boolean hasAttribute(DOMString qualifiedName);
    boolean hasAttributeNS([FlyString] DOMString? namespace, [FlyString] DOMString localName);

    Attr? getAttributeNode([FlyString] DOMString qualifiedName);
    Attr? getAttributeNodeNS([FlyString] DOMString? namespace, [FlyString] DOMString localName);
    [CEReactions] Attr? setAttributeNode(Attr attr);
    [CEReactions] Attr? setAttributeNodeNS(Attr attr);
    [CEReactions] Attr removeAttributeNode(Attr attr);

    ShadowRoot attachShadow(ShadowRootInit init);
    [ImplementedAs=open_shadow_root] readonly attribute ShadowRoot? shadowRoot;

    readonly attribute CustomElementRegistry? customElementRegistry;

    Element? closest(DOMString selectors);
    boolean matches(DOMString selectors);
    [ImplementedAs=matches] boolean webkitMatchesSelector(DOMString selectors); // legacy alias of .matches

    HTMLCollection getElementsByTagName([FlyString] DOMString qualifiedName);
    HTMLCollection getElementsByTagNameNS([FlyString] DOMString? namespace, [FlyString] DOMString localName);
    HTMLCollection getElementsByClassName(DOMString classNames);

    [CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // legacy
    undefined insertAdjacentText(DOMString where, DOMString data); // legacy
};

dictionary ShadowRootInit {
    required ShadowRootMode mode;
    boolean delegatesFocus = false;
    SlotAssignmentMode slotAssignment = "named";
    boolean clonable = false;
    boolean serializable = false;
    CustomElementRegistry? customElementRegistry;
};

// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
partial interface Element {
    [CEReactions] undefined setHTML(DOMString html, optional SetHTMLOptions options = {});
    [CEReactions] undefined appendHTML(DOMString html, optional SetHTMLOptions options = {});
    [CEReactions] undefined prependHTML(DOMString html, optional SetHTMLOptions options = {});
    [CEReactions, ImplementedInBindings] undefined setHTMLUnsafe((TrustedHTML or DOMString) html, optional (SetHTMLUnsafeOptions or TrustedHTMLParserOptions) options = {});
    [CEReactions, ImplementedInBindings] undefined appendHTMLUnsafe((TrustedHTML or DOMString) html, optional (SetHTMLUnsafeOptions or TrustedHTMLParserOptions) options = {});
    [CEReactions, ImplementedInBindings] undefined prependHTMLUnsafe((TrustedHTML or DOMString) html, optional (SetHTMLUnsafeOptions or TrustedHTMLParserOptions) options = {});
    DOMString getHTML(optional GetHTMLOptions options = {});

    // FIXME: Only the DOMString variant should have the LegacyNullToEmptyString attribute.
    [CEReactions, LegacyNullToEmptyString, ImplementedInBindings] attribute (TrustedHTML or DOMString) innerHTML;
    // FIXME: Only the DOMString variant should have the LegacyNullToEmptyString attribute.
    [CEReactions, LegacyNullToEmptyString, ImplementedInBindings] attribute (TrustedHTML or DOMString) outerHTML;
    [CEReactions, ImplementedInBindings] undefined insertAdjacentHTML(DOMString position, (TrustedHTML or DOMString) string);
};

dictionary GetHTMLOptions {
    boolean serializableShadowRoots = false;
    sequence<ShadowRoot> shadowRoots = [];
};

// https://w3c.github.io/pointerlock/#requestPointerLock
// FIXME: Move this to a proper home when we have a pointerlock spec folder.
partial interface Element {
    [ImplementedInBindings] Promise<undefined> requestPointerLock(optional PointerLockOptions options = {});
};

dictionary PointerLockOptions {
    boolean unadjustedMovement = false;
};

Element includes Animatable;
Element includes ARIAMixin;
Element includes ChildNode;
Element includes NonDocumentTypeChildNode;
Element includes ParentNode;
Element includes Slottable;