Element

Element

new Element(nameParam) → {Element}

A BetterElement element.

Parameters:
Name Type Description
nameParam String

The name of the BetterElement (what will be inside of the <>s)

Source:
Returns:
Type
Element

Members

attributes :Array.<Attribute>

The attributes of a BetterElement.

Type:
Source:

(constant) name :String

The name of the BetterElement. For example, in a tag would be 'clock'.

Type:
  • String
Source:

toExecuteOnRead :function

A callback for when an element is read. Called once for each element.

Type:
  • function
Source:

Methods

addAttribute(attribute, required, verify, value) → {Attribute}

Adds an attribute to this.attributes.

Parameters:
Name Type Description
attribute Attribute | String

The attribute itself, or a string for it's name.

required Boolean

Weather or not it is required.

verify function

The verification function, called on each attribute's contents.

value String

The value of the attribute. Currently unused.

Source:
Returns:

The finished attribute.

Type
Attribute

delAttribute(attributename) → {Attribute}

Deletes an attribute from this.attributes.

Parameters:
Name Type Description
attributename String

The attribute name to find and delete.

Source:
Returns:

The deleted attribute

Type
Attribute

getElements() → {HTMLCollection}

Fetches all appropiate elements from the DOM.

Source:
Returns:
Type
HTMLCollection

readElements()

Reads all the current elements and parses them.


Note: Soon this may be split into seperate functions.

Source:
Throws:
  • Error if readElements is run without a toExecuteOnRead

  • Error if an attribute is missing that is marked as required.

  • Error if attribute verification failed.