/** * @file * * Mocks of the class, attribute, text and lookup helpers Obsidian adds to `Element.prototype`. */ /** * Adds one or more CSS classes to the element. * * @param classes - The class names to add. */ export declare function addClass(this: Element, ...classes: string[]): void; /** * Adds a list of CSS classes to the element. * * @param classes - The class names to add. */ export declare function addClasses(this: Element, classes: string[]): void; /** * Finds the first descendant matching a selector. * * @param selector - The CSS selector to match. * @returns The first matching element, or `null` when nothing matches. */ export declare function find(this: Element, selector: string): Element | null; /** * Finds every descendant matching a selector. * * @param selector - The CSS selector to match. * @returns The matching elements, in document order. */ export declare function findAll(this: Element, selector: string): HTMLElement[]; /** * Finds every element matching a selector, including the element itself. * * @param selector - The CSS selector to match. * @returns The element itself first when it matches, followed by the matching descendants. The mock throws when * the element matches but is not an `HTMLElement`. */ export declare function findAllSelf(this: Element, selector: string): HTMLElement[]; /** * Reads an attribute, like `getAttribute`. * * @param qualifiedName - The attribute name. * @returns The attribute's value, or `null` when it is absent. */ export declare function getAttr(this: Element, qualifiedName: string): null | string; /** * Reads a CSS property from the element's computed style. * * @param property - The CSS property name, such as `--font-text-size`. * @param pseudoElement - The pseudo-element to read from, such as `::before`. * @returns The computed value, or an empty string when the property is not set. */ export declare function getCssPropertyValue(this: Element, property: string, pseudoElement?: string): string; /** * Reads the element's text. * * @returns The element's `textContent`. */ export declare function getText(this: Element): string; /** * Checks whether the element has a CSS class. * * @param cls - The class name to check. * @returns `true` when the element has the class. */ export declare function hasClass(this: Element, cls: string): boolean; /** * Checks whether the element has focus. The mock compares against the global `document.activeElement`, so an * element in a pop-out document never counts as active. * * @returns `true` when the element is the active element. */ export declare function isActiveElement(this: Element): boolean; /** * Finds the nearest element matching a selector, as Obsidian does: the element itself is checked first, then each * ancestor in turn. * * @param selector - The CSS selector to match. * @param lastParent - An ancestor to stop at; it is still checked, but nothing above it is. * @returns The element itself or the nearest matching ancestor, or `null` when none matches. */ export declare function matchParent(this: Element, selector: string, lastParent?: Element): Element | null; /** * Removes one or more CSS classes from the element. * * @param classes - The class names to remove. */ export declare function removeClass(this: Element, ...classes: string[]): void; /** * Removes a list of CSS classes from the element. * * @param classes - The class names to remove. */ export declare function removeClasses(this: Element, classes: string[]): void; /** * Sets an attribute, or removes it when the value is `null`. * * @param qualifiedName - The attribute name. * @param value - The value to set, converted to a string; `null` removes the attribute. */ export declare function setAttr(this: Element, qualifiedName: string, value: boolean | null | number | string): void; /** * Sets several attributes at once, as {@link setAttr} does for each entry. * * @param $object - Attribute names mapped to their values; a `null` value removes that attribute. */ export declare function setAttrs(this: Element, $object: Record): void; /** * Replaces the element's children with text or a fragment. * * @param value - The new text, or a fragment whose nodes are moved into the element. */ export declare function setText(this: Element, value: DocumentFragment | string): void; /** * Adds or removes CSS classes depending on a flag. * * @param classes - A class name or a list of class names. * @param value - `true` to add the classes, `false` to remove them. */ export declare function toggleClass(this: Element, classes: string | string[], value: boolean): void;