Dollarsign

Dollarsign

The Dollarsign object represents a collection of DOM elements grouped by the given `selector`. Wraps basic browser functionality into a more consistent and concise API. The implementation of this class contains only the bare minimum necessary to implement all of Dollarsign's functionality, and the rest of it is implemented in various modules.

Constructor

new Dollarsign(scope, selector)

Query the given DOM object (or scope) for elements matching selector.
Source:
Parameters:
Name Type Description
scope Element | Document DOM object to manipulate
selector string Element query

Classes

Dollarsign

Members

(readonly) elements

All elements matching the given `selector`. This is calculated using `querySelectorAll()` if a string selector is given. Otherwise, we assume the selector is a wrapped element and return it as a single-position Array.
Source:

(readonly) length

Counts results in the query. As this depends on `this.elements`, it is also read-only and is calculated based on the value of that computed attribute.
Source:

Methods

each(callback) → {Dollarsign}

Iterate over every element with the given callback function.
Source:
Parameters:
Name Type Description
callback elementIterator Function to call on each iteration.
Returns:
Type:
Dollarsign
this object

(generator) iterator()

Allow iteration over this object using `for..of` loops. This is also used to iterate over objects with `this.each()`, but with that function we provide a bit more functionality. This will only iterate over the elements and not change the `this` or wrap each element in a Dollarsign object.
Source:

toString()

This allows us to identify Dollarsign objects without needing to use `instanceof`. In bundled environments, `instanceof` doesn't work because the class names can change.
Source:

Type Definitions

elementIterator(element, index)

Function executed when iterating over a collection of DOM elements.
Source:
Parameters:
Name Type Description
element Dollarsign Each element selected from the DOM.
index Number Index number of each element in the Array.

eventListener(event)

Function executed when a DOM event is triggered.
Source:
Parameters:
Name Type Description
event Event Triggered event object.