This specification describes the additions to existing
specifications which will make it possible for web authors
to programmatically express semantics for Web Components.
Note: this is analogous to creating an "immutable class variable" -
these semantic properties are associated with
the custom element definition,
not with each custom element instance.
The semantics they define apply to all instances
of the custom element.
1.1.2. Defining per-instance custom element semantics
A custom element author may use the ElementInternals object,
created via createInternals(),
to modify the semantic state of an instance of a custom element
in response to user interaction.
Note: this is analogous to setting an "instance variable" -
a copy of these semantic properties is created for each instance
of the custom element.
The semantics defined in each
apply only to their associated custom element instance object.
A custom element may have semantics defined when the custom element is defined. Otherwise, an autonomous custom element does not have any special meaning: it represents its children. A customized built-in element inherits the semantics of the element that it extends.
[...]
A custom element definition [includes]:
A set of default values for semantic properties (optional)
If the key exists in options,
add an entry to semantics with that key
and the value provided in options.
If semantics is empty, set it to null.
Let definition be
a new custom element definition with name name,
local name local name,
constructor constructor,
observed attributes observedAttributes,
lifecycle callbacks lifecycleCallbacks,
and, if semantics is non-null, semantic propertiessemantics.
In general, the precedence of semantic properties is that
any ARIA property set directly on the Element (either via setting an attribute or via the associated reflected property)
overrides a value for the same property on
the Element's ElementInternals object,
and any ARIA property set either on the Element or the ElementInternals object
will override a value set via the CustomElementRegistry.define() method.
2.2. Mapping semantics to the accessibility tree
This section represents changes which should be made to [[html-aam-1.0#mapping-html-to-accessibility-apis]].
If an element is custom,
for each key in the element’s ElementInternals object,
the associated value must be mapped to accessibility APIs
as if they were a property set on the element.
If the element’s custom element definition includes semantics,
the value of each property in semantics must be mapped to accessibility APIs as if they were set on the element,
unless there is a conflicting value for the same property
in the element’s ElementInternals object,
or in a property set on the element.
Conformance
Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology.
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL”
in the normative parts of this document
are to be interpreted as described in RFC 2119.
However, for readability,
these words do not appear in all uppercase letters in this specification.
All of the text of this specification is normative
except sections explicitly marked as non-normative, examples, and notes. [RFC2119]
Examples in this specification are introduced with the words “for example”
or are set apart from the normative text with class="example", like this:
This is an example of an informative example.
Informative notes begin with the word “Note”
and are set apart from the normative text with class="note", like this: