html-element
Obsidian-runtime-agnostic helpers for working with HTML elements.
Several helpers here mirror behavior that the Obsidian runtime injects onto the DOM prototypes (createEl/createDiv/createSpan/createSvg/createFragment, Node.prototype.instanceOf, Element.prototype.setText/setAttrs). To stay independent of the Obsidian runtime, that behavior is reimplemented here in standard DOM, ported from Obsidian’s own implementation in obsidian.asar/enhance.js. See the obsidian-versions project; revalidate the port when Obsidian changes enhance.js (there is a reminder in CLAUDE.md).
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| ValidatorElement | A HTML element that can be validated. |
Functions
Section titled “Functions”| Function | Description |
|---|---|
| createDivAsync | Creates a div asynchronously. |
| createElAsync | Creates an element asynchronously. |
| createFragmentAsync | Creates a DocumentFragment asynchronously. |
| createSpanAsync | Creates a span asynchronously. |
| createSvgAsync | Creates a svg asynchronously. |
| ensureLoaded | Ensures that the given element is loaded. |
| getZIndex | Gets the z-index of the given element. |
| isElementVisibleInOffsetParent | Checks if the element is visible in the offset parent. |
| isLoaded | Checks if the element is loaded. |
| onAncestorScrollOrResize | Adds an event listener to the ancestor nodes of the given node. |
| toPx | Converts a number to a string with ‘px’ appended. |
| waitUntilConnected | Waits until the given element is connected to the DOM. |