@serenity-is/corelib / PrefixedContext
Class: PrefixedContext
Defined in: src/ui/widgets/prefixedcontext.ts:9
Provides a scoped context for resolving elements and widgets by an id prefix within a given DOM node. Useful for panels and dialogs that need to look up their child elements and widgets by short, prefix-relative ids.
Constructors
Constructor
new PrefixedContext(
prefixOrWidget,context?):PrefixedContext
Defined in: src/ui/widgets/prefixedcontext.ts:23
Creates a new prefixed context.
Parameters
prefixOrWidget
Either a string id prefix, or an object exposing
idPrefix and domNode (such as a widget) from which the prefix and
context are derived.
string | { domNode: HTMLElement; idPrefix: string; }
context?
HTMLElement
Optional DOM node to scope lookups to; defaults to the
domNode of prefixOrWidget when an object is provided.
Returns
PrefixedContext
Properties
context
readonlycontext:HTMLElement
Defined in: src/ui/widgets/prefixedcontext.ts:13
The DOM node that acts as the scope for lookups.
idPrefix
readonlyidPrefix:string
Defined in: src/ui/widgets/prefixedcontext.ts:11
The id prefix used to resolve child element ids.
Methods
byId()
byId(
id):Fluent
Defined in: src/ui/widgets/prefixedcontext.ts:45
Resolves an element by its prefix-relative id.
Parameters
id
string
The id relative to the context's id prefix.
Returns
A Fluent wrapper for the matching element, or an empty Fluent object if no element matches.
initialize()
protectedinitialize():void
Defined in: src/ui/widgets/prefixedcontext.ts:36
Hook for subclasses to perform additional initialization.
Returns
void
w()
w<
TWidget>(id,type):TWidget
Defined in: src/ui/widgets/prefixedcontext.ts:55
Resolves a widget by its prefix-relative id and expected type.
Type Parameters
TWidget
TWidget
Parameters
id
string
The id relative to the context's id prefix.
type
(...args) => TWidget
The widget type to look up.
Returns
TWidget
The matching widget instance.