DomComponent(attributesopt)

new DomComponent(attributesopt)

An abstract class that all other DOM components can extend.

Parameters:
Name Type Attributes Description
attributes object | undefined <optional>

The instance attributes.

Source:

Extends

Members

className :string

The className attribute. Used for CSS.

Type:
  • string
Source:

el :HTMLElement

The el attribute.

Type:
  • HTMLElement
Source:

events :object

The events attribute.

Type:
  • object
Inherited From:
Source:

language :object

Get the language attribute.

Type:
  • object
Source:

name :string

Get the name attribute.

Type:
  • string
Inherited From:
Source:

parent :DomComponent

The parent attribute. Parent is set when DomComponent instances are mounted.

Type:
Source:

theme :object

The theme attribute.

Type:
  • object
Source:

Methods

(static) translate()

Alias to translate(string);

Source:

callback(fn) → {*}

Helper method to execute the callback() function.

Parameters:
Name Type Description
fn function

The callback function.

Inherited From:
Source:
Returns:
  • Returns the executed callback function.
Type
*

emit(key) → {Component}

Emit an event.

Parameters:
Name Type Description
key string

The event id/key.

Inherited From:
Source:
Returns:
  • Returns this instance.
Type
Component

getAttribute(key) → {*}

Get an attribute. Returns null if no attribute is defined.

Parameters:
Name Type Description
key string

The attribute name.

Inherited From:
Source:
Returns:
  • The attribute value.
Type
*

getAttributes() → {object}

Get all the atttributes for this instance.

Inherited From:
Source:
Returns:
  • The attribute dictionary.
Type
object

getPublicAttributes() → {object}

Get only public the atttributes for this instance. Omits any attribute that starts with $, which is used internally.

Inherited From:
Source:
Returns:
  • The attribute dictionary.
Type
object

mount(parent, beforeopt) → {HTMLElement}

Mount a DOM component to a parent node.

Parameters:
Name Type Attributes Default Description
parent HTMLElement

The parent DOM node.

before false | HTMLElement <optional>
false

If false, element is appended to the parent node. If an instance of an HTMLElement, the component will be inserted before the specified element.

Source:
Returns:
  • The el attribute.
Type
HTMLElement

off(key, fn) → {Component}

Stop listening to an event.

Parameters:
Name Type Description
key string

The event id/key.

fn function | undefined

The listener callback function. If no function is defined, all events with the specified id/key will be removed. Otherwise, only the event listeners matching the id/key AND callback will be removed.

Inherited From:
Source:
Returns:
  • Returns this instance.
Type
Component

on(key, fn, onceopt) → {Component}

Start listening to an event.

Parameters:
Name Type Attributes Default Description
key string

The event id/key.

fn function

The listener callback function.

once boolean <optional>
false

Should the event handler be fired a single time.

Inherited From:
Source:
Returns:
  • Returns this instance.
Type
Component

once(key, fn) → {Component}

Listen to an event only one time.

Parameters:
Name Type Description
key string

The event id/key.

fn function

The listener callback function.

Inherited From:
Source:
Returns:
  • Returns this instance.
Type
Component

render() → {HTMLElement}

Render the DOM component.

Source:
Returns:
  • The el attribute.
Type
HTMLElement

setAttribute(key, value) → {void}

Set an attribute key and value.

Parameters:
Name Type Description
key string

The attribute name.

value *

The attribute value.

Inherited From:
Source:
Returns:
Type
void

setAttributes(values) → {void}

Set an attributes by object of key/value pairs.

Parameters:
Name Type Description
values object

The object dictionary.

Inherited From:
Source:
Returns:
Type
void

translate(string) → {string}

Translate a string.

Parameters:
Name Type Description
string string

The string to translate.

Source:
Returns:
  • The translated string. If no tranlation found, the untranslated string is returned.
Type
string