module:MHTMLDataElement

module:MHTMLDataElement

Class to operate on HTMLElements that contains data.

Constructor

new (require("MHTMLDataElement"))(id, remove)

Description:
  • Constructor.

Parameters:
Name Type Description
id string

ID of the HTML element that will be operated on.

remove boolean

Remove the element from the dom.

Methods

isValid() → {boolean}

Description:
  • Whether HTML element found and ready to operate on.

Returns:

Result.

Type
boolean

getDataAttributeValue(attributeName, defaultValue) → {string}

Description:
  • Get data attribute value for given attributeName.

    data- should not be provided in attributeName as it will be added by the method.

Parameters:
Name Type Description
attributeName string

Attribute name without data- at the beginning.

defaultValue *

Default value to be returned if the value of the given attributeName couldn't be obtained.

Returns:

Value.

Type
string

getDataAttributeValueAsBoolean(attributeName) → {boolean}

Description:
  • Get data attribute value as boolean for given attributeName.

    data- should not be provided in attributeName as it will be added by the method.

Parameters:
Name Type Description
attributeName string

Attribute name without data- at the beginning.

Returns:

Value.

Type
boolean

getDataAttributeValueAsJSON(attributeName, defaultValue) → {null|JSON}

Description:
  • Get data attribute as JSON object for given attributeName.

    data- should not be provided in attributeName as it will be added by the method.

Parameters:
Name Type Description
attributeName string

Attribute name without data- at the beginning.

defaultValue *

Default value to be returned if the value of the given attributeName couldn't be obtained.

Returns:

Value.

Type
null | JSON