domu/document

Functions

pub fn body(
  document: EventTargetLike(TagNode(TagDocument(a))),
) -> EventTargetLike(
  TagNode(
    TagElement(TagHTMLElement(TagHTMLBodyElement(Concrete))),
  ),
)

Returns the document.body as an HTMLBodyElement .

Note that document.body itself returns null when the <body> tag hasn’t been loaded yet. This function is defined for convenience.

For safer handling, use body_option instead.

MDN Reference

pub fn body_option(
  document: EventTargetLike(TagNode(TagDocument(a))),
) -> Option(
  EventTargetLike(
    TagNode(
      TagElement(TagHTMLElement(TagHTMLBodyElement(Concrete))),
    ),
  ),
)

Returns the document.body as an Option(HTMLBodyElement) .

This function safely handles the case where document.body is null .

MDN Reference

pub fn create_element(
  document: EventTargetLike(TagNode(TagDocument(a))),
  tag_name: String,
) -> EventTargetLike(
  TagNode(TagElement(TagHTMLElement(Concrete))),
)
pub fn create_element_a(
  document: EventTargetLike(TagNode(TagDocument(a))),
) -> EventTargetLike(
  TagNode(
    TagElement(TagHTMLElement(TagHTMLAnchorElement(Concrete))),
  ),
)
pub fn document() -> EventTargetLike(
  TagNode(TagDocument(Concrete)),
)
pub fn of_node(
  node: EventTargetLike(TagNode(a)),
) -> Option(EventTargetLike(TagNode(TagDocument(Concrete))))

Downcasts Node to Document if possible.

Search Document