Skip to main content

Module element

Module element 

Source
Expand description

Element operations: attributes, classList, innerHTML, scoped matching.

Upstream: blitz-script/src/dom/element.rs. See MAPPING.md.

Tolerance is copied from upstream: an operation naming a node that is not an element behaves as though the attribute were simply absent, rather than raising. blitz-script has no NotAnElement case and neither does this.

Functionsยง

class_list_add
element.classList.add(...tokens).
class_list_contains
element.classList.contains(token).
class_list_remove
element.classList.remove(...tokens).
class_list_toggle
element.classList.toggle(token, force), returning whether the token is present afterwards.
closest
element.closest(selector): this node or the nearest ancestor that matches.
get_attribute
element.getAttribute(name).
get_attribute_into
element.getAttribute(name), written into a caller-supplied buffer.
has_attribute
element.hasAttribute(name).
inner_html
element.innerHTML, serialised from the children.
matches
element.matches(selector).
remove_attribute
element.removeAttribute(name).
set_attribute
element.setAttribute(name, value).
set_inner_html
element.innerHTML = html.
tag_name
element.tagName, upper-cased as the DOM specifies.