.hasAttribute()

Method to check whether a token has a specified attribute. The method can check for attributes with a value and for empty attributes.

The method .hasAttribute() is located in the file token.jsxinc.

Usage

Check whether an attribute exists and that the attribute has a value:

token.hasAttribute("style");

Check whether an attribute exits, even when the attribute is empty:

token.hasAttribute("style", true);

Parameters

Parameter Data type Required Description
attribute String The name of the attribute to check.
empty Boolean   If true, the method will also return true for empty attributes. Default is false.

Return values

Value Meaning
null Method encountered an error.
true The token has the specified attribute.
false The token does not have the specified attribute.