HoverPopover
Mock of Obsidian’s HoverPopover.
Nothing is shown and no timer runs: the popover owns a detached HoverPopover.hoverEl and its state stays where it was set.
Import:
import { HoverPopover } from 'obsidian-test-mocks/obsidian';Signature:
export class HoverPopover extends ComponentExtends: Component
Constructor
new HoverPopover(parent: HoverParent, targetEl: HTMLElement | null, waitTime?: number | undefined, staticPos?: Point | null | undefined)Creates a popover for a hover parent.
Properties
| Property | Type | Description |
|---|---|---|
| _children | Component[] | The child components, unloaded when this component unloads. (Inherited from Component) |
| _events | EventRefOriginal[] | The event refs registered with Component.registerEvent, detached when this component unloads. (Inherited from Component) |
| _loaded | boolean | Whether this component is currently loaded. (Inherited from Component) |
| cleanups__ | (() => unknown)[] | Mock-only: the callbacks registered with Component.register, run in reverse order on unload. (Inherited from Component) |
| hoverEl | HTMLElement | The popover's element, which holds the preview content. |
| intervals__ | number[] | Mock-only: the interval ids registered with Component.registerInterval, cleared on unload. (Inherited from Component) |
| state | PopoverStateOriginal | The popover's lifecycle state (showing, hiding and so on); starts at 0. |
Methods
| Method | Returns | Description |
|---|---|---|
| addChild(component) | T | Adds a child component, loading it if this component is already loaded. (Inherited from Component) |
| asOriginalType__() | ComponentOriginal | Mock-only: views this mock as Obsidian's Component type.(Inherited from Component) |
| asOriginalType2__() | HoverPopoverOriginal | Mock-only: views this mock as Obsidian's HoverPopover type. |
| constructor__() | void | Mock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(Component.prototype, 'constructor__').(Inherited from Component) |
| constructor2__(_parent, _targetEl, _waitTime?, _staticPos?) | void | Mock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(HoverPopover.prototype, 'constructor2__'). |
| load() | void | Loads this component and then its children; does nothing if it is already loaded. (Inherited from Component) |
| onload() | void | Called when the component loads; override it to set the component up. A no-op by default. (Inherited from Component) |
| onunload() | void | Called when the component unloads; override it to tear the component down. A no-op by default. (Inherited from Component) |
| register(callback) | void | Registers a callback to run when this component unloads. (Inherited from Component) |
| registerDomEvent(el, type, callback, options?) | void | Adds a DOM event listener, and registers a cleanup that removes it when this component unloads. (Inherited from Component) |
| registerEvent(ref) | void | Registers an event ref to be detached, through its owning Events object's offref, when this component unloads.(Inherited from Component) |
| registerInterval(id) | number | Registers an interval to be cleared with clearInterval when this component unloads.(Inherited from Component) |
| removeChild(component) | T | Removes a child component, if present, and unloads it. (Inherited from Component) |
| unload() | void | Unloads this component: unloads and forgets its children, runs its registered cleanups, clears the tracked events and intervals, then calls Component.onunload. Does nothing if it is not loaded. (Inherited from Component) |
| static create__() | Component | Mock-only factory: creates a component, spyable via vi.spyOn(Component, 'create__').(Inherited from Component) |
| static create2__(parent, targetEl, waitTime?, staticPos?) | HoverPopover | Mock-only factory: creates a hover popover, spyable via vi.spyOn(HoverPopover, 'create2__'). The subclass variant of Component.create__. |
| static forLeaf__(_leaf) | HoverPopover | null | Mock-only: looks up the hover popover open for a leaf. The mock tracks none, so it always returns null. |
| static fromOriginalType__(value) | Component | Mock-only: views a value typed as Obsidian's Component as this mock.(Inherited from Component) |
| static fromOriginalType2__(value) | HoverPopover | Mock-only: views a value typed as Obsidian's HoverPopover as this mock. |
Links to this page: