Instance Properties
-
instance.length {Number}
-
- Default Value:
- 0
Methods
-
instance.add
-
- Parameters:
-
Name Type Optional Description item HTMLElement|Object No
The item to add to the Collection. insertBefore HTMLElement Yes
Existing item used as a reference to insert the new item before. If the value is null
, then the new item will be added at the end. - Fires:
- Returns:
-
the item added. {HTMLElement}
-
instance.clear
-
- Returns:
-
an Array with all the removed items. {Array.<HTMLElement>}
-
instance.first
-
- Returns:
-
the first item of the collection. {HTMLElement}
-
instance.getAll
-
- Returns:
-
an Array with all the items inside the collection. {Array.<HTMLElement>}
-
instance.last
-
- Returns:
-
the last item of the collection. {HTMLElement}
-
instance.remove
-
- Parameters:
-
Name Type Description item HTMLElement The item to add to the Collection. - Fires:
- Returns:
-
the item removed. {HTMLElement}
HTMLElement
or an Object with the item
properties. If the index is not provided the element appended to the end. If options.onItemAdded
was
provided, it will be called after the element is added from the DOM.
HTMLElement
.
options.onItemRemoved
was provided, it will be called
after the element is removed from the DOM.
Type Definitions
-
instance.filter
-
- Parameters:
-
Name Type Description element HTMLElement The item to check whether it should be part of the collection. - Returns:
-
true if should be part of the collection, otherwise false. {Boolean}
-
instance.onCollectionChange
-
- Parameters:
-
Name Type Description addedNodes Array.<HTMLElement> An array that contains the items that were added to the collection. removedNodes Array.<HTMLElement> An array that contains the items that were removed from the collection.
-
instance.onItemAdded
-
- Parameters:
-
Name Type Description item HTMLElement The item that was added to the collection.
-
instance.onItemRemoved
-
- Parameters:
-
Name Type Description item HTMLElement The item that was added to the collection.
true
for the given element it will be part of the collection, otherwise it will be excluded.
Events
-
coral-collection:add
-
- Callback Parameters:
-
Name Type Description event Object Event object.
Name Type Description event.detail.item HTMLElement The item that was added.
-
coral-collection:remove
-
- Callback Parameters:
-
Name Type Description event Object Event object.
Name Type Description event.detail.item HTMLElement The item that was removed.