goog.dom.dataset
Namespace.get(element, key)
Gets a custom data attribute from an element. The key should be in camelCase format (e.g "keyName" for the "data-key-name" attribute).
element
{Element
}
key
{string
}
string
}
.getAll(element)
Gets all custom data attributes as a string map. The attribute names will be camel cased (e.g., data-foo-bar -> dataset['foobar']). This operation is not safe for attributes having camel-cased names clashing with already existing properties (e.g., data-to-string -> dataset['toString']).
element
{!Element
}
Object
}
.has(element, key)
Checks whether custom data attribute exists on an element. The key should be in camelCase format (e.g "keyName" for the "data-key-name" attribute).
element
{Element
}
key
{string
}
boolean
}
.remove(element, key)
Removes a custom data attribute from an element. The key should be in camelCase format (e.g "keyName" for the "data-key-name" attribute).
element
{Element
}
key
{string
}
.set(element, key, value)
Sets a custom data attribute on an element. The key should be in camelCase format (e.g "keyName" for the "data-key-name" attribute).
element
{Element
}
key
{string
}
value
{string
}