The type of the nodes held in the list.
The type of the nodes held in the list.
Optional...values: (Type | NodeListType<Type>)[]Optional initial value(s) to populate the list with.
Delegate fired whenever an entry is added to or removed from the list, including entries from nested TurboNodeLists, HTMLCollections, and NodeListOf instances.
Whether to observe added HTMLCollections and NodeListOf instances for DOM mutations, automatically firing onChanged when nodes are added or removed from the DOM.
The number of resolved unique entries in this list. For the number of slots, see slotCount.
The number of slots in this list. Individual entries, HTMLCollections, NodeListOf instances, and nested TurboNodeLists each count as one slot, regardless of how many entries they contain. For the number of resolved entries, see size.
ProtectedisProtected FunctionisTurboNodeList
The value to check.
Whether the value is a TurboNodeList.
Type guard — returns true if the given value is a TurboNodeList.
ProtectedisProtected FunctionisDomList
The value to check.
Whether the value is a DOM list.
Type guard — returns true if the given value is an HTMLCollection or NodeListOf.
ProtectedisProtectedisProtected FunctionisEntry
The value to check.
Whether the value is an individual entry.
Type guard — returns true if the given value is an individual node entry (i.e. not a TurboNodeList, DOM list, Set, array, or WeakRef).
ProtectedresolveFunctionresolveSlot
The slot to resolve.
Resolves a slot WeakRef into its constituent entries. Yields all entries from sub-lists and DOM lists, or the single entry for individual node slots. Yields nothing if the referent has been garbage collected.
OptionalthisArg: anyFunctionadd
The entries to add.
Itself, allowing for method chaining.
Adds one or more entries to the end of the list. Entries may be individual nodes, arrays, Sets, HTMLCollections, NodeListOf instances, or nested TurboNodeLists.
FunctionaddAt
The resolved entry index to insert at.
The entries to add.
Itself, allowing for method chaining.
Adds one or more entries at the given resolved size index. The index refers to the position among resolved unique entries, not slots. Arrays and Sets are expanded inline.
FunctionaddAtSlot
The slot index to insert at.
The entries to add.
Itself, allowing for method chaining.
Adds one or more entries at the given slot index. Subsequent entries are inserted consecutively after the previous one. Arrays and Sets are expanded inline, each item occupying the next slot index.
Functionremove
The entries to remove.
Itself, allowing for method chaining.
Removes one or more entries from the list. Entries may be individual nodes, arrays, Sets, HTMLCollections, NodeListOf instances, or nested TurboNodeLists.
FunctionremoveAtSlot
The slot index to start removing from.
Optionalcount: number = 1The number of consecutive slots to remove.
Itself, allowing for method chaining.
Removes one or more slots starting at the given slot index. Each slot removed may correspond to an individual entry, a DOM list, or a nested TurboNodeList.
Functionmove
The entry to move.
The resolved entry index to move the entry to.
Itself, allowing for method chaining.
Moves an existing entry to the given resolved size index. If the entry is a member of a nested TurboNodeList, it is moved within that sub-list. If it belongs to a DOM list, it is repositioned in the DOM accordingly.
FunctionmoveToSlot
The entry to move.
The slot index to move the entry to.
Itself, allowing for method chaining.
Functionhas
The entry or entries to check.
Whether the entry or entries are present in the list.
Checks whether the given entry or entries are present in the list.
Functionclear
Itself, allowing for method chaining.
Clears all entries from the list, firing onChanged for every resolved entry.
ProtectedaddFunctionaddEntry
The entry to add.
Optionalindex: numberThe slot index to insert at. Defaults to the end of the slot array.
The next available slot index after this insertion, for consecutive chaining.
ProtectedremoveProtectedinsertFunctioninsertOrRemoveSlot
The slot value to insert or remove.
Whether to insert or remove the slot.
Optionalindex: numberSlot index for insertion. Ignored on removal.
The next available slot index after the operation, for consecutive chaining.
ProtectedattachFunctionattachObserver
The DOM list to observe.
Attaches a MutationObserver to the parent of the first node in the given DOM list, firing onChanged when nodes matching the list are added to or removed from the DOM. Does nothing if an observer is already attached for this list, or if no parent node is found.
ProtectedsizeProtectedfindProtected FunctionfindContainingSlot
The entry to locate.
The containing slot, or undefined if not found.
Finds the slot that directly contains or resolves to the given entry. Returns the slot itself if the entry is a direct slot, the nested TurboNodeList that contains it, or the DOM list that contains it.
TurboNodeList
Description
A composable, Set-like collection for managing nodes. Supports individual nodes, live DOM collections (HTMLCollection or NodeListOf), and nested TurboNodeList instances as sub-lists. Changes to sub-lists and live DOM collections propagate automatically on iteration.