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 GradumNodeLists, 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 GradumNodeLists each count as one slot, regardless
of how many entries they contain. For the number of resolved entries, see size.
ProtectedisProtected Function
isGradumNodeList
The value to check.
Whether the value is a GradumNodeList.
Type guard — returns true if the given value is a GradumNodeList.
ProtectedisProtected Function
isDomList
The value to check.
Whether the value is a DOM list.
ProtectedisProtectedisProtected Function
isEntry
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
GradumNodeList, DOM list, Set, array, or WeakRef).
ProtectedresolveProtected Function
resolveSlot
The slot to resolve.
The entries this slot resolves to, in order.
Called once per entry.
OptionalthisArg: any
Value to bind as this inside the callback.
Itself, allowing for method chaining.
Function
add
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
GradumNodeLists.
Function
addAt
The resolved entry index to insert at.
The entries to add.
Itself, allowing for method chaining.
Function
addAtSlot
The slot index to insert at.
The entries to add.
Itself, allowing for method chaining.
Function
remove
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
GradumNodeLists.
Function
removeAtSlot
The slot index to start removing from.
Optionalcount: number = 1
The 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 GradumNodeList.
Function
move
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 GradumNodeList, it is moved within that sub-list. If it belongs to a DOM list, it is repositioned in the DOM accordingly.
Function
moveToSlot
The entry to move.
The slot index to move the entry to.
Itself, allowing for method chaining.
Function
has
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.
Sets, returns true only if every item is present.Function
clear
Itself, allowing for method chaining.
Clears all entries from the list, firing onChanged for every resolved entry.
ProtectedaddProtected Function
addEntry
The entry to add.
Optionalindex: number
The slot index to insert at. Defaults to the end of the slot array.
The next available slot index after this insertion, for consecutive chaining.
ProtectedremoveProtected Function
removeEntry
The entry to remove.
ProtectedinsertProtected Function
insertOrRemoveSlot
The slot value to insert or remove.
Whether to insert or remove the slot.
Optionalindex: number
Slot index for insertion. Ignored on removal.
The next available slot index after the operation, for consecutive chaining.
Insert or drop a single slot and announce it, firing onChanged once per entry the slot resolves to. An out-of-range insertion index is clamped to the ends.
ProtectedattachFunction
attachObserver
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.
ProtectedsizeProtected Function
sizeIndexToSlotIndex
The resolved entry index, clamped to the current size.
The matching slot index.
ProtectedfindProtected Function
findContainingSlot
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 GradumNodeList that contains it, or the DOM list that contains it.
GradumNodeList
Description
A composable, Set-like collection of nodes. A single list can mix individual nodes, live DOM collections (HTMLCollection or NodeList), and nested GradumNodeLists. Iteration resolves all of them in order and de-duplicates, so entries added to a sub-list or to the DOM show up without re-registering anything. Entries are held weakly, so a node removed from the document drops out of the list on its own.