DOM

DOM

Source

Any web platform API using promises to represent operations that can be aborted must adhere to
the following:

APIs not using promises should still adhere to the above as much as possible.

In its original sense, "The DOM" is an API for
accessing and manipulating documents (in particular, HTML and XML
documents). In this specification, the term "document" is used for any
markup-based resource, ranging from short static documents to long essays or
reports with rich multimedia, as well as to fully-fledged interactive
applications.

Each such document is represented as a node tree. Some of the nodes in a tree can have children, while others are always leaves.

To illustrate, consider this HTML document:


<!DOCTYPE html>
<html class=e> <head><title>Aliens?</title></head> <body>Why yes.</body>
</html>

It is represented as follows:

Note that, due to the magic that is HTML parsing, not all ASCII whitespace were turned into Text nodes, but the general concept is
clear. Markup goes in, a is a node tree whose root is a document.

The document element of a document is the element whose parent is that document, if it exists; otherwise null.

Per the node tree constraints, there can be only one such element.

An element is in a document tree if its root is a document.

An element is in a document if it is in a document tree. The term in a document is no longer supposed to be used. It indicates that
the standard using it has not been updated to account for shadow trees.

A shadow tree is a node tree whose root is a shadow root.

A shadow root is always attached to another node tree through its host. A shadow tree is therefore never alone. The node tree of a shadow root’s host is sometimes
referred to as the light tree.

A shadow tree’s corresponding light tree can be a shadow tree itself.

An element is connected if its shadow-including root is a document.

Element/slot

In all current engines.

Firefox63+Safari10+Chrome53+ Opera40+Edge79+ Edge (Legacy)NoneIENone Firefox for Android63+iOS Safari10+Chrome for Android53+Android WebView53+Samsung Internet6.0+Opera Mobile41+

A shadow tree contains zero or more elements that are slots.

A slot can only be created through HTML’s slot element.

A slot has an associated name (a string). Unless stated
otherwise it is the empty string.

Use these attribute change steps to update a slot’s name:

  1. If element is a slot, localName is name, and namespace is null, then:

    1. If value is oldValue, then return.

    2. If value is null and oldValue is the empty string, then return.

    3. If value is the empty string and oldValue is null, then return.

    4. If value is null or the empty string, then set element’s name to the empty string.

    5. Otherwise, set element’s name to value.

    6. Run assign slottables for a tree with element’s root.

The first slot in a shadow tree, in tree order, whose name is the empty string, is sometimes known as the "default slot".

A slot has an associated assigned nodes (a list of slottables). Unless stated otherwise it is empty.

Element and Text nodes are slottables.

A slot can be a slottable.

A slottable has an associated name (a
string). Unless stated otherwise it is the empty string.

Use these attribute change steps to update a slottable’s name:

  1. If localName is slot and namespace is null, then:

    1. If value is oldValue, then return.

    2. If value is null and oldValue is the empty string, then return.

    3. If value is the empty string and oldValue is null, then return.

    4. If value is null or the empty string, then set element’s name to the empty string.

    5. Otherwise, set element’s name to value.

    6. If element is assigned, then run assign slottables for element’s assigned slot.

    7. Run assign a slot for element.

A slottable has an associated assigned slot (null or a slot).
Unless stated otherwise it is null. A slottable is assigned if its assigned slot is
non-null.

A slottable has an associated manual slot assignment (null
or a slot). Unless stated otherwise, it is null.

A slottable’s manual slot assignment can be implemented using a weak
reference to the slot, because this variable is not directly accessible from script.

To find a slot for a given slottable slottable and an optional open flag (unset unless stated otherwise), run these
steps:

To find slottables for a given slot slot, run these steps:

To find flattened slottables for a given slot slot, run these steps:

To assign slottables for a slot slot,
run these steps:

To assign slottables for a tree, given a node root, run assign slottables for each slot slot in root’s inclusive descendants, in tree order.

To assign a slot, given a slottable slottable, run these
steps:

Each similar-origin window agent has signal slots (a set of slots), which is initially empty. [HTML]

To signal a slot change, for a slot slot, run these steps:

To ensure pre-insertion validity of a node into a parent before a child, run these steps:



Read Next page

Report Page