Class XDomUtils


  • public final class XDomUtils
    extends Object
    Helper for DOM related features.
    • Method Detail

      • dataAttrDashStyle

        public static String dataAttrDashStyle​(String name)
        Takes a data attribute name using dash style notation (eg. `fooBarBaz`) and converts it to dash style notation (e.g. `data-foo-bar-baz`).

        The HTML living standard defines the conversion as follows:

        W3C DOM dataset

        To set the value of a new named property or set the value of an existing named property for a DOMStringMap, given a property name and a new value, run the following steps:

        1. If name contains a U+002D HYPHEN-MINUS character (-) followed by an ASCII lower alpha, then throw a "SyntaxError" DOMException.
        2. For each ASCII upper alpha in name, insert a U+002D HYPHEN-MINUS character (-) before the character and replace * the character with the same character converted to ASCII lowercase.
        3. Insert the string `data-` at the front of name.
        4. If name does not match the XML Name production, throw an "InvalidCharacterError" DOMException.
        5. Set an attribute value for the DOMStringMap's associated element using name and value.
        Parameters:
        name - Name of the data attribute using camel case notation.
        Returns:
        Name of the data attribute using camel case notation.
        Throws:
        IllegalArgumentException - When the given name is invalid.