import Collection from 'elementify/lib/collection.js'
Collection
Class for handling a collection of any HtmlElement (or extended) objects.
A collection is pretty straight forwarding. All methods from HtmlElement class are mapped to a collection to let iterate a call on items from collection itself.
Test:
Constructor Summary
Public Constructor | ||
public |
A new Collection can be instantiated though it's more likely the result of a query in the DOM. |
Member Summary
Public Members | ||
public get |
Merge all elements in collection under a DocumentFragment Element |
version 1.0.0 since 1.0.0 |
public |
Array of elements contained in the collection (could be empty) |
since 1.0.0 |
public get |
Number of elements in the collection |
since 1.0.0 |
public get |
|
version 1.0.0 since 1.0.0 |
Method Summary
Public Methods | ||
public |
forEach(callback: ForEachCallback): void Run a callback on each element in the collection. |
version 1.0.0 since 1.0.0 |
public |
push(element: Element | HtmlElement): this Push an element into the collection |
version 1.0.0 since 1.0.0 |
Public Constructors
public constructor(): Collection source
A new Collection can be instantiated though it's more likely the result of a query in the DOM.
Public Members
public get element: HtmlElement version 1.0.0 since 1.0.0 source
Merge all elements in collection under a DocumentFragment Element
Public Methods
public forEach(callback: ForEachCallback): void version 1.0.0 since 1.0.0 source
Run a callback on each element in the collection. This method is an alias to this.elements.forEach.
Params:
Name | Type | Attribute | Description |
callback | ForEachCallback | Callback to run on each element |
Return:
void |
public push(element: Element | HtmlElement): this version 1.0.0 since 1.0.0 source
Push an element into the collection
Params:
Name | Type | Attribute | Description |
element | Element | HtmlElement | Element (enhanced ot not) to insert into the collection |
Return:
this | Chainable |
Throw:
Throw an error if the argument is not an Element or an HtmlElement |