Module: webcomponents

Classes

webcomponents.WebComponent

Methods

(protected, inner) addCssClass(idOrClassName, className)

Add a given class to a given element.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

className string

the class name to add.

Source:

(protected, inner) connectedCallback()

Called every time the element is inserted into the DOM.

Source:

(protected, inner) disconnectedCallback()

Called every time the element is removed from the DOM.

Source:

(protected, inner) emit(type, data, elem) → {boolean}

Emit a custom event.

Parameters:
Name Type Description
type string

the event type.

data Object | null

any data structure to pass along with the event.

elem Node | null

the element to attach the event to.

Source:
Returns:

returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

Type
boolean

(protected, inner) externalScripts() → {Array.<string>}

A list of scripts URL.

Source:
Returns:

an array of URL.

Type
Array.<string>

(protected, inner) externalStyles() → {Array.<string>}

A list of stylesheets URL.

Source:
Returns:

an array of URL.

Type
Array.<string>

(protected, inner) getAllCssClasses(idOrClassName) → {Array.<string>}

Get all classes associated to a given element.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

Source:
Returns:

the class names.

Type
Array.<string>

(protected, inner) getAttributeOrDefault(attr, defaultValue) → {string|null}

Returns the component attribute value or a default value if none was found.

Parameters:
Name Type Description
attr string

the attribute to get.

defaultValue string | null

the default value.

Source:
Returns:

the attribute value if any, defaultValue otherwise.

Type
string | null

(protected, inner) getComputedStyle(idOrClassName) → {CSSStyleDeclaration|null}

Get the actual computed style associated to a given element.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

Source:
Returns:

the element computed style.

Type
CSSStyleDeclaration | null

(protected, inner) getElement(idOrClassName) → {Element|null}

Returns the first element with a given identifier or class name.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

Source:
Returns:

an HTML element.

Type
Element | null

(protected, inner) getPageElement(idOrClassName) → {Element|null}

Get the first page element with a given identifier or class name.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

Source:
Returns:

an HTML element.

Type
Element | null

(protected, inner) getStyle(idOrClassName) → {CSSStyleDeclaration|null}

Get the style associated to a given element.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

Source:
Returns:

the element style.

Type
CSSStyleDeclaration | null

(protected, inner) includesCssClass(idOrClassName, className)

Check if a given element has a given class.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

className string

the class name to search.

Source:
Returns:

true if the element contains the given class, false otherwise.

(protected, inner) removeCssClass(idOrClassName, className)

Remove a given class from a given element.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

className string

the class name to remove.

Source:

(protected, inner) renderedCallback()

Called after the template has been added to the DOM.

Source:

(protected, inner) replaceAllCssClasses(idOrClassName, classes)

Replace all classes associated to a given element.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

classes Array.<string> | string

the class names.

Source:

(protected, inner) replaceContent(idOrClassName, element)

Append an element to a given element.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

element Element

the element to append.

Source:

(protected, inner) setHtml(idOrClassName, html)

Set the HTML associated to a given element.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

html string

the html to set.

Source:

(protected, inner) setText(idOrClassName, text)

Set the text associated to a given element.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

text string

the text to set.

Source:

(protected, inner) template() → {string}

Returns the component HTML template.

Source:
Returns:

the HTML.

Type
string

(protected, inner) toggleCssClass(idOrClassName, className)

Add a class if it does not already exist on a given element, remove it otherwise.

Parameters:
Name Type Description
idOrClassName string

the identifier or class name to match.

className string

the class name to toggle.

Source: