Skip to content
Idan Goldman edited this page Sep 8, 2019 · 2 revisions

Classes

Element

Wrapper class for DOM elements, initiate by passing a selector.

Functions

eventNamesValidation(eventNames, eventNamesList)Array

Match event names against given event names list.

findReverseBranch(leaf, tree)Array

Searches an EventsList array for a specific item and returns the trail from it.

Typedefs

HTMLElement : Object

DOM instance of an element.

QuerySelector : String

A CSS selector string

EventsList : Array

A nested list of 3 levels deep, with a unique structure.

Element

Wrapper class for DOM elements, initiate by passing a selector.

Kind: global class

new Element(selector)

Creates an element instance of the query selector passed in.

Throws:

  • When no query selector passed.
  • When no HTML elements were found via passed query selector.
Param Type Description
selector String DOM query selector

element.raw ⇒ HTMLElement

Get the instance of DOM element.

Kind: instance property of Element

element.toString ⇒ QuerySelector

Get the query selector string.

Kind: instance property of Element

eventNamesValidation(eventNames, eventNamesList) ⇒ Array

Match event names against given event names list.

Kind: global function
Returns: Array - Array of valid event names.
Throws:

  • When event name is not part of event names list.
Param Type Description
eventNames String String of event names separated by space.
eventNamesList EventsList Nested array of event names.

Example

const eventNames = 'click mouseover';

eventNamesValidation(eventNames, DOM_EVENTS_LIST);
// ['click', 'mouseover']

findReverseBranch(leaf, tree) ⇒ Array

Searches an EventsList array for a specific item and returns the trail from it.

Kind: global function
Returns: Array - Flat array that indicates the path to the leaf in reverse.

Param Type Description
leaf String String value to be found in the array
tree EventsList Nested array of string values.

Example

const tree = [['branch_1', ['leaf_1_1', 'leaf_1_2']], ['branch_2', ['leaf_2_1']], 'leaf_0'];
const leaf = 'leaf_1_2';

console.log(
  'The branch is:', findReverseBranch(leaf, tree)
);

// ['leaf_1_2', 'branch_1']

HTMLElement : Object

DOM instance of an element.

Kind: global typedef

QuerySelector : String

A CSS selector string

Kind: global typedef

EventsList : Array

A nested list of 3 levels deep, with a unique structure.

Kind: global typedef
Example

// [[key, [...values]], ...values]
const eventsList = [
 ['keys', ['keypress', 'keyup', 'keydown']],
 ['clicks', ['click', 'dblclick']],
 'resize',
 'reset'
];