# Helpers

# Element.create

Create a new HTML DOM Element

# Parameters

  • type string

  • parameters ...Object ...Function

# Return Value

Element

  Element.create('div', attributes, callback);
1

# Example

  // Create a new "button" element with a type 
  // of "submit" and a class of "btn-primary".

  Element.create('button', {
      'type': 'submit',
      'class': 'btn-primary'
  });

  // Create a new "div" element and append it to a parent element.

  Element.create('div', element => parent.appendChild(element));

  // Create a new "button" with a class of "btn-primary", 
  // add an event listener and append it to a parent element.

  Element.create('button', { 'class' : 'btn-primary' }, element => {
      element.addEventListener('click', event => handle);
      parent.appendChild(element);
  });
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

# Keyboard.transform

Transform a KeyboardEvent into a custom event.

# Parameters

  • event KeyboardEvent

# Return Value

Event

  Keyboard.transform(event);
1

# Example

element.addEventListener('keydown', event => {
    element.dispatchEvent(Keyboard.transform(event));
});
1
2
3