Manual Reference Source Test
import Collection from 'elementify/lib/collection.js'
public class | version 1.0.0 | since 1.0.0 | source

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.

Return:

Collection

A collection of [HtmlElement]HtmlElement objects

Test:

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 elements: Array since 1.0.0 source

Array of elements contained in the collection (could be empty)

public get length: Number since 1.0.0 source

Number of elements in the collection

public get node: HtmlElement version 1.0.0 since 1.0.0 source

See:

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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
element Element | HtmlElement

Element (enhanced ot not) to insert into the collection

Return:

this

Chainable

Throw:

TypeError

Throw an error if the argument is not an Element or an HtmlElement

Test: