Living
Standard
—
Last
Updated
16
22
February
2023
Some
IDL
attributes
The
building
blocks
for
reflecting
are
as
follows:
A
reflected
target
is
an
element
or
ElementInternals
object.
It
is
typically
clear
from
context
and
typically
identical
to
the
interface
of
the
reflected
IDL
attribute
.
It
is
always
identical
to
that
interface
when
it
is
an
ElementInternals
object.
A reflected IDL attribute is an attribute interface member.
A
reflected
content
attribute
name
is
a
string.
When
the
reflected
target
is
an
element,
it
represents
the
local
name
of
a
content
attribute
whose
namespace
is
null.
When
the
reflected
target
is
an
ElementInternals
object,
it
represents
a
key
of
the
internal
content
attribute
map
.
A
reflected
IDL
attribute
can
be
defined
to
reflect
a
particular
reflected
content
attribute.
This
attribute
name
of
a
reflected
target
.
In
general
this
means
that
on
getting,
the
IDL
attribute
getter
returns
the
current
value
of
the
content
attribute,
and
on
setting,
the
IDL
attribute
setter
changes
the
value
of
the
content
attribute
to
the
given
value.
In
general,
on
getting,
if
If
the
content
attribute
reflected
target
is
not
present,
an
element,
then
the
reflected
IDL
attribute
can
additionally
declare
to
support
ElementInternals
.
This
means
that
the
ElementInternals
interface
also
has
a
reflected
IDL
attribute
,
with
the
same
identifier,
and
that
reflected
IDL
attribute
reflects
the
same
reflected
content
attribute
name
.
The
fooBar
IDL
attribute
must
act
as
if
reflect
the
foobar
content
attribute's
attribute
and
support
ElementInternals
.
Reflected targets have these associated algorithms:
For a reflected target that is an element element , these are defined as follows:
Return element .
Let
attribute
be
the
result
of
running
get
an
attribute
by
namespace
and
on
setting,
if
local
name
given
null,
the
reflected
content
attribute
name
,
and
element
.
If attribute is null, then return null.
Return attribute 's value .
Set an attribute value given element , the reflected content attribute name , and value .
Remove an attribute by namespace and local name given null, the reflected content attribute name , and element .
For
a
reflected
target
that
is
an
ElementInternals
object
elementInternals
,
they
are
defined
as
follows:
Return elementInternals 's target element .
If
elementInternals
's
target
element
's
internal
content
attribute
map
[the
reflected
content
attribute
name
]
does
not
present,
it
must
first
exist
,
then
return
null.
Return elementInternals 's target element 's internal content attribute map [the reflected content attribute name ].
Set elementInternals 's target element 's internal content attribute map [the reflected content attribute name ] to value .
Remove elementInternals 's target element 's internal content attribute map [the reflected content attribute name ].
This
results
in
somewhat
redundant
data
structures
for
ElementInternals
objects
as
their
target
element
's
internal
content
attribute
map
cannot
be
added.
directly
manipulated
and
as
such
reflection
is
only
happening
in
a
single
direction.
This
approach
was
nevertheless
chosen
to
make
it
less
error-prone
to
define
IDL
attributes
that
are
shared
between
reflected
targets
and
benefit
from
common
API
semantics.
IDL
attributes
of
type
DOMString
or
DOMString
?
that
reflect
enumerated
content
attributes
can
be
limited
to
only
known
values
.
Per
the
processing
models
below,
those
will
cause
the
getters
for
such
IDL
attributes
to
only
return
keywords
for
those
enumerated
attributes,
or
the
empty
string
or
null.
If
a
reflecting
reflected
IDL
attribute
has
the
type
DOMString
:
The getter steps are:
If
Let
element
be
the
result
of
running
this
's
get
the
element
.
Let contentAttributeValue be the result of running this 's get the content attribute .
Let attributeDefinition be the attribute definition of element 's content attribute whose namespace is null and local name is the reflected content attribute name .
If
attributeDefinition
indicates
it
is
an
enumerated
attribute
,
and
the
reflected
IDL
attribute
is
defined
to
be
limited
to
only
known
values
:
If
the
content
attribute
is
contentAttributeValue
does
not
in
correspond
to
any
state
(e.g.
the
attribute
of
attributeDefinition
(e.g.,
it
is
missing
null
and
there
is
no
missing
value
default
),
or
the
content
attribute
that
it
is
in
a
state
of
attributeDefinition
with
no
associated
keyword
value,
then
return
the
empty
string.
Return
the
canonical
keyword
for
the
state
of
the
content
attribute.
attributeDefinition
that
contentAttributeValue
corresponds
to.
If contentAttributeValue is null, then return the empty string.
Return
the
content
attribute's
value.
contentAttributeValue
.
The
setter
steps
are
to
run
this
's
set
the
content
attribute's
value
to
attribute
with
the
given
value.
If
a
reflecting
reflected
IDL
attribute
has
the
type
DOMString
?
:
The getter steps are:
Let element be the result of running this 's get the element .
Let contentAttributeValue be the result of running this 's get the content attribute .
Let attributeDefinition be the attribute definition of element 's content attribute whose namespace is null and local name is the reflected content attribute name .
Assert : attributeDefinition indicates it is an enumerated attribute .
Assert : the reflected IDL attribute is limited to only known values .
Assert
:
the
content
attribute
is
in
some
state.
contentAttributeValue
corresponds
to
a
state
of
attributeDefinition
.
If
the
content
attribute
is
in
contentAttributeValue
corresponds
to
a
state
of
attributeDefinition
with
no
associated
keyword
value,
then
return
null.
Return
the
canonical
keyword
for
the
state
of
the
content
attribute.
attributeDefinition
that
contentAttributeValue
corresponds
to.
The setter steps are:
If
the
given
value
is
null,
then
remove
run
this
's
delete
the
content
attribute.
attribute
.
Otherwise,
run
this
's
set
the
content
attribute's
value
to
attribute
with
the
given
value.
If
a
reflecting
reflected
IDL
attribute
has
the
type
USVString
:
The getter steps are:
If
Let
element
be
the
result
of
running
this
's
get
the
element
.
Let contentAttributeValue be the result of running this 's get the content attribute .
Let
attributeDefinition
be
the
attribute
definition
of
element
's
content
attribute
whose
namespace
is
defined
to
contain
null
and
local
name
is
the
reflected
content
attribute
name
.
If attributeDefinition indicates it contains a URL :
If
the
content
attribute
contentAttributeValue
is
absent,
null,
then
return
the
empty
string.
Parse
the
value
of
the
content
attribute
contentAttributeValue
relative
to
the
element's
node
document
.
If
that
is
successful,
does
not
return
failure,
then
return
the
resulting
URL
string
.
Otherwise,
return
the
value
of
the
content
attribute,
converted
to
a
USVString
.
Return
the
value
of
the
content
attribute,
contentAttributeValue
,
converted
to
a
USVString
.
scalar
value
string
.
The
setter
steps
are
to
run
this
's
set
the
content
attribute's
value
to
attribute
with
the
given
value.
If
a
reflecting
reflected
IDL
attribute
is
a
has
the
type
boolean
:
attribute,
then
on
getting
The getter steps are:
Let
contentAttributeValue
be
the
IDL
attribute
must
return
true
if
result
of
running
this
's
get
the
content
attribute
.
If
contentAttributeValue
is
set,
and
false
if
it
null,
then
return
false.
Return true.
The setter steps are:
If
the
given
value
is
absent.
On
setting,
false,
then
run
this
's
delete
the
content
attribute
must
be
removed
if
.
If
the
IDL
attribute
given
value
is
true,
then
run
this
's
set
to
false,
and
must
be
set
to
the
empty
string
if
the
IDL
content
attribute
is
set
to
true.
(This
with
the
empty
string.
This
corresponds
to
the
rules
for
boolean
content
attributes
.)
.
If
a
reflecting
reflected
IDL
attribute
has
a
signed
integer
the
type
(
long
,
optionally
limited
to
only
non-negative
numbers
:)
then,
on
getting,
The getter steps are:
Let
contentAttributeValue
be
the
result
of
running
this
's
get
the
content
attribute
must
.
If contentAttributeValue is not null:
Let
parsedValue
be
parsed
according
to
the
result
of
rules
for
integer
parsing
signed
integers
,
and
contentAttributeValue
if
that
is
successful,
and
the
value
is
in
the
range
of
the
reflected
IDL
attribute's
type,
the
resulting
value
must
be
returned.
If,
on
the
other
hand,
it
fails
or
returns
an
out
of
range
value,
or
if
the
attribute
is
absent,
then
the
default
value
must
be
returned
instead,
or
0
if
there
is
no
default
value.
On
setting,
the
given
value
must
be
converted
not
limited
to
only
non-negative
numbers
;
otherwise
the
shortest
possible
string
representing
the
number
as
a
valid
result
of
non-negative
integer
parsing
contentAttributeValue
.
If
parsedValue
is
not
an
error
and
then
that
string
must
be
used
as
is
within
the
new
content
attribute
value.
long
range,
then
return
parsedValue
.
If
a
reflecting
the
reflected
IDL
attribute
has
a
signed
integer
type
(
default
value,
then
return
it.
If
the
reflected
IDL
attribute
)
that
is
limited
to
only
non-negative
numbers
then,
on
getting,
the
content
attribute
must
be
parsed
according
to
the
rules
for
parsing
non-negative
integers
,
and
if
that
is
successful,
and
the
value
is
in
the
range
of
then
return
−1.
Return 0.
The setter steps are:
If
the
reflected
IDL
attribute's
type,
the
resulting
value
must
be
returned.
If,
on
the
other
hand,
it
fails
or
returns
an
out
of
range
value,
or
if
the
attribute
is
absent,
the
default
value
must
be
returned
instead,
or
−1
if
there
is
no
default
value.
On
setting,
if
limited
to
only
non-negative
numbers
and
the
given
value
is
negative,
the
user
agent
must
then
throw
an
"
IndexSizeError
"
DOMException
.
Otherwise,
Run
this
's
set
the
content
attribute
with
the
given
value
must
be
converted
to
the
shortest
possible
string
representing
the
number
as
a
valid
non-negative
integer
and
then
that
string
must
be
used
as
the
new
content
attribute
value.
.
If
a
reflecting
reflected
IDL
attribute
has
an
unsigned
integer
the
type
(
unsigned
long
,
optionally
limited
to
)
then,
on
getting,
the
content
attribute
must
be
parsed
according
the
rules
for
parsing
only
non-negative
integers
,
and
if
that
is
successful,
and
the
value
is
in
the
range
0
numbers
greater
than
zero
,
limited
to
2147483647
inclusive,
the
resulting
value
must
be
returned.
If,
on
the
other
hand,
it
fails
or
returns
an
out
of
range
value,
or
if
the
attribute
is
absent,
the
default
value
must
be
returned
instead,
only
non-negative
numbers
greater
than
zero
with
fallback
,
or
0
if
there
is
no
default
value.
On
setting,
first,
if
the
new
value
is
in
clamped
to
the
range
0
to
2147483647,
then
let
[
n
be
the
new
value,
otherwise
let
clampedMin
,
n
clampedMax
be
the
default
value,
or
0
if
there
is
no
default
value;
then,
]:
The getter steps are:
Let
n
contentAttributeValue
must
be
converted
to
the
shortest
possible
string
representing
the
number
as
a
valid
non-negative
integer
result
of
running
this
and
that
string
must
be
used
as
's
get
the
new
content
attribute
value.
.
Let minimum be 0.
If
a
reflecting
the
reflected
IDL
attribute
has
an
unsigned
integer
type
(
unsigned
long
)
that
is
limited
to
only
non-negative
numbers
greater
than
zero
,
or
limited
to
only
non-negative
numbers
greater
than
zero
with
fallback
,
then
set
minimum
to
1.
If
the
behavior
reflected
IDL
attribute
is
similar
clamped
to
the
previous
case,
but
zero
range
,
then
set
minimum
to
clampedMin
.
Let
maximum
be
2147483647
if
the
reflected
IDL
attribute
is
not
allowed.
On
getting,
clamped
to
the
content
attribute
must
first
range
;
otherwise
clampedMax
.
If contentAttributeValue is not null:
Let
parsedValue
be
parsed
according
to
the
rules
for
parsing
result
of
non-negative
integers
,
and
if
that
integer
parsing
contentAttributeValue
.
If
parsedValue
is
successful,
not
an
error
and
the
value
is
in
the
range
1
minimum
to
2147483647
maximum
,
inclusive,
the
resulting
value
must
be
returned.
If,
on
the
other
hand,
it
fails
or
returns
then
return
parsedValue
.
If
parsedValue
is
not
an
out
of
range
value,
or
if
error
and
the
reflected
IDL
attribute
is
absent,
clamped
to
the
default
value
must
be
returned
instead,
or
1
if
there
range
:
If
parsedValue
is
no
less
than
minimum
,
then
return
minimum
.
Return maximum .
If
the
reflected
IDL
attribute
has
a
default
value.
On
setting,
if
value,
then
return
it.
Return minimum .
The setter steps are:
If
the
value
reflected
IDL
attribute
is
zero,
limited
to
only
non-negative
numbers
greater
than
zero
and
the
user
agent
must
given
value
is
0,
then
throw
an
"
IndexSizeError
"
DOMException
.
Otherwise,
first,
if
the
new
value
is
in
the
range
1
to
2147483647,
then
let
n
be
the
new
value,
otherwise
let
n
be
the
default
value,
or
1
if
there
is
no
default
value;
then,
Let
n
minimum
must
be
converted
to
the
shortest
possible
string
representing
the
number
as
a
valid
non-negative
integer
and
that
string
must
be
used
as
the
new
content
attribute
value.
0.
If
a
reflecting
the
reflected
IDL
attribute
has
an
unsigned
integer
type
(
unsigned
long
)
that
is
limited
to
only
non-negative
numbers
greater
than
zero
with
fallback
,
then
the
behavior
is
similar
to
the
previous
case,
but
disallowed
values
are
converted
to
the
default
value.
On
getting,
the
content
attribute
must
first
be
parsed
according
or
limited
to
the
rules
for
parsing
only
non-negative
integers
numbers
greater
than
zero
with
fallback
,
and
if
that
is
successful,
and
the
value
is
in
the
range
1
then
set
minimum
to
2147483647
inclusive,
the
resulting
value
must
1.
Let
newValue
be
returned.
If,
on
the
other
hand,
it
fails
or
returns
an
out
of
range
value,
or
if
minimum
.
If
the
reflected
IDL
attribute
is
absent,
the
has
a
default
value
must
be
returned
instead.
On
setting,
first,
if
value,
then
set
newValue
to
it.
If
the
new
given
value
is
in
the
range
1
minimum
to
2147483647,
inclusive,
then
let
n
be
the
new
value,
otherwise
let
set
n
newValue
be
to
it.
Run
this
's
set
the
default
value;
then,
content
attribute
with
n
newValue
must
be
converted
to
the
shortest
possible
string
representing
the
number
as
a
valid
non-negative
integer
.
Clamped
to
the
range
and
that
string
must
be
used
as
has
no
effect
on
the
new
content
attribute
value.
setter
steps.
If
a
reflecting
reflected
IDL
attribute
has
an
unsigned
integer
the
type
(
,
optionally
limited
to
unsigned
long
double
)
that
is
clamped
the
range
[
min
,
numbers
greater
than
zero
:
The getter steps are:
Let
max
contentAttributeValue
],
then
on
getting,
the
content
attribute
must
first
be
parsed
according
to
the
rules
for
parsing
non-negative
integers
,
and
if
that
is
successful,
and
result
of
running
this
's
get
the
value
is
between
content
attribute
.
If
min
contentAttributeValue
and
is
not
null:
Let
max
parsedValue
inclusive,
the
resulting
value
must
be
returned.
If
it
fails,
the
default
value
must
be
returned.
If
it
succeeds
but
the
value
is
less
than
result
of
floating-point
number
parsing
min
,
contentAttributeValue
.
If
min
parsedValue
must
be
returned.
If
it
succeeds
but
the
value
is
not
an
error
and
is
greater
than
0,
then
return
max
,
parsedValue
.
If
max
parsedValue
must
be
returned.
On
setting,
it
behaves
is
not
an
error
and
the
same
as
setting
a
regular
reflected
unsigned
integer.
If
a
reflecting
IDL
attribute
has
a
floating-point
number
type
(
double
or
unrestricted
double
),
then,
on
getting,
the
content
attribute
must
be
parsed
according
to
the
rules
for
parsing
floating-point
number
values
,
and
if
that
is
successful,
the
resulting
value
must
be
returned.
If,
on
the
other
hand,
it
fails,
or
if
the
attribute
is
absent,
the
default
value
must
be
returned
instead,
or
0.0
if
there
is
no
default
value.
On
setting,
the
given
value
must
be
converted
not
limited
to
the
best
representation
of
the
number
as
a
floating-point
number
and
numbers
greater
than
zero
,
then
that
string
must
be
used
as
the
new
content
attribute
value.
return
parsedValue
.
If
a
reflecting
the
reflected
IDL
attribute
has
a
floating-point
number
type
(
default
value,
then
return
it.
Return 0.
The setter steps are:
If
the
reflected
IDL
attribute
)
that
is
limited
to
numbers
greater
than
zero
,
then
the
behavior
is
similar
to
the
previous
case,
but
zero
and
negative
values
are
not
allowed.
On
getting,
the
content
attribute
must
be
parsed
according
to
the
rules
for
parsing
floating-point
number
values
,
and
if
that
is
successful
and
the
given
value
is
not
greater
than
0.0,
the
resulting
value
must
be
returned.
If,
on
the
other
hand,
it
fails
or
returns
an
out
of
range
value,
or
if
the
attribute
is
absent,
the
default
value
must
be
returned
instead,
or
0.0
if
there
is
no
default
value.
On
setting,
if
the
value
is
less
than
or
equal
to
zero,
0,
then
return.
Run
this
's
set
the
value
must
be
ignored.
Otherwise,
content
attribute
with
the
given
value
must
be
value,
converted
to
the
best
representation
of
the
number
as
a
floating-point
number
and
then
that
string
must
be
used
as
the
new
content
attribute
value.
.
The values Infinity and Not-a-Number (NaN) values throw an exception on setting, as defined in Web IDL . [WEBIDL]
If
a
reflecting
reflected
IDL
attribute
has
the
type
DOMTokenList
,
then
on
getting
it
must
its
getter
steps
are
to
return
a
DOMTokenList
object
whose
associated
element
is
the
element
in
question
this
and
whose
associated
attribute's
local
name
is
the
reflected
content
attribute
name
.
Specification
authors
cannot
use
support
ElementInternals
for
IDL
attributes
of
the
attribute
in
question.
this
type.
If
a
reflecting
reflected
IDL
attribute
attr
has
the
type
T
?
,
where
T
is
either
Element
or
an
interface
that
inherits
from
Element
,
then:
Elements
of
the
type
this
IDL
attribute
Reflected
targets
that
attr
appears
on
have
an
explicitly
set
attr
-element
,
which
is
a
weak
reference
to
an
element
or
null.
It
is
initially
null.
Elements
of
the
type
this
IDL
attribute
Reflected
targets
that
attr
appears
on
have
an
attr
-associated
element
.
To
compute
the
attr
-associated
element
for
such
an
element
a
reflected
target
element
reflectedTarget
:
If
Let
element
be
the
result
of
running
reflectedTarget
's
get
the
element
.
Let contentAttributeValue be the result of running reflectedTarget 's get the content attribute .
If reflectedTarget 's explicitly set attr -element is not null:
If
element
reflectedTarget
's
explicitly
set
attr
-element
is
a
descendant
of
any
of
element
's
shadow-including
ancestors
,
then
return
element
reflectedTarget
's
explicitly
set
attr
-element
.
Otherwise,
return
Return
null.
Otherwise,
if
the
content
attribute
is
present
on
element
,
then
contentAttributeValue
is
not
null,
return
the
first
element
candidate
,
in
tree
order
,
that
meets
the
following
criteria:
If no such element exists, then return null.
Return null.
Other
parts
of
this
specification,
or
other
specifications
using
attribute
reflection,
are
expected
to
consult
an
element's
a
reflected
target
's
attr
-associated
element
.
An
element's
A
reflected
target
's
explicitly
set
attr
-element
is
an
internal
implementation
detail
of
its
attr
-associated
element
and
is
not
to
be
used
directly.
The getter steps are to return this 's attr -associated element .
The setter steps are:
If the given value is null, then:
Set this 's explicitly set attr -element to null.
Remove
Run
this
's
delete
the
content
attribute
from
this
.
Return.
Set
Run
this
's
set
the
content
attribute's
value
for
this
attribute
to
with
the
empty
string.
Set this 's explicitly set attr -element to a weak reference to the given value.
The
For
element
reflected
targets
only:
the
following
attribute
change
steps
,
given
element
,
localName
,
oldValue
,
value
,
and
namespace
,
are
used
to
synchronize
between
the
content
attribute
and
the
IDL
attribute:
If
localName
is
not
the
reflected
content
attribute's
local
name,
attribute
name
or
namespace
is
not
null,
then
return.
Set element 's explicitly set attr -element to null.
If
a
reflecting
reflected
IDL
attribute
attr
has
the
type
FrozenArray<
T
>?
,
where
T
is
either
Element
or
an
interface
that
inherits
from
Element
,
then:
Elements
of
the
type
this
IDL
attribute
Reflected
targets
that
attr
appears
on
have
explicitly
set
attr
-elements
,
which
is
either
a
list
of
weak
references
to
elements
or
null.
It
is
initially
null.
Elements
of
the
type
this
IDL
attribute
Reflected
targets
that
attr
appears
on
have
cached
attr
-associated
elements
,
which
is
a
FrozenArray<
T
>?
.
It
is
initially
null.
Elements
of
the
type
this
IDL
attribute
Reflected
targets
that
attr
appears
on
have
attr
-associated
elements
.
To
compute
the
attr
-associated
elements
for
such
an
element
a
reflected
target
element
reflectedTarget
:
Let elements be an empty list .
If
Let
element
be
the
result
of
running
reflectedTarget
's
get
the
element
.
If
reflectedTarget
's
explicitly
set
attr
-elements
is
not
null,
then:
null:
For
each
attrElement
in
the
element
reflectedTarget
's
explicitly
set
attr
-elements
:
If attrElement is not a descendant of any of element 's shadow-including ancestors , then continue .
Append attrElement to elements .
Otherwise:
If
Let
contentAttributeValue
be
the
result
of
running
reflectedTarget
's
get
the
content
attribute
is
not
present
on
.
If
element
,
contentAttributeValue
is
null,
then
return
null.
Let
tokens
be
the
content
attribute's
value,
contentAttributeValue
,
split
on
ASCII
whitespace
.
For
each
id
in
of
tokens
:
Let candidate be the first element, in tree order , that meets the following criteria:
If no such element exists, then continue .
Append candidate to elements .
Return elements .
Other
parts
of
this
specification,
or
other
specifications
using
attribute
reflection,
are
expected
to
consult
an
element's
a
reflected
target
's
attr
-associated
elements
.
An
element's
A
reflected
target
's
explicitly
set
attr
-elements
is
an
internal
implementation
detail
of
its
attr
-associated
elements
and
is
not
to
be
used
directly.
Similarly,
the
element's
a
reflected
target
's
cached
attr
-associated
elements
is
an
internal
implementation
detail
of
the
IDL
attribute's
getter.
The getter steps are:
Let elements be this 's attr -associated elements .
If the contents of elements is equal to the contents of this 's cached attr -associated elements , then return this 's cached attr -associated elements .
Let
elementsAsFrozenArray
be
elements
,
converted
to
a
FrozenArray<
T
>?
.
Set this 's cached attr -associated elements to elementsAsFrozenArray .
Return elementsAsFrozenArray .
This
extra
caching
layer
is
necessary
to
preserve
the
invariant
that
element.reflectedElements
===
element.reflectedElements
.
The setter steps are:
If the given value is null:
Set this 's explicitly set attr -elements to null.
Remove
Run
this
's
delete
the
content
attribute
from
this
.
Return.
Set
Run
this
's
set
the
content
attribute's
value
for
this
attribute
to
with
the
empty
string.
Let elements be an empty list .
For each element in the given value:
Append a weak reference to element to elements .
Set this 's explicitly set attr -elements to elements .
The
For
element
reflected
targets
only:
the
following
attribute
change
steps
,
given
element
,
localName
,
oldValue
,
value
,
and
namespace
,
are
used
to
synchronize
between
the
content
attribute
and
the
IDL
attribute:
If
localName
is
not
the
reflected
content
attribute's
local
name,
attribute
name
,
or
namespace
is
not
null,
then
return.
Set element 's explicitly set attr -elements to null.
The
HTMLFormControlsCollection
and
HTMLOptionsCollection
interfaces
are
collections
derived
from
the
HTMLCollection
interface.
The
HTMLAllCollection
interface
is
a
collection
,
but
is
not
so
derived.
HTMLAllCollection
interface
The
HTMLAllCollection
interface
is
used
for
the
legacy
document.all
attribute.
It
operates
similarly
to
HTMLCollection
;
the
main
differences
are
that
it
allows
a
staggering
variety
of
different
(ab)uses
of
its
methods
to
all
end
up
returning
something,
and
that
it
can
be
called
as
a
function
as
an
alternative
to
property
access.
All
HTMLAllCollection
objects
are
rooted
at
a
Document
and
have
a
filter
that
matches
all
elements,
so
the
elements
represented
by
the
collection
of
an
HTMLAllCollection
object
consist
of
all
the
descendant
elements
of
the
root
Document
.
Objects
that
implement
the
HTMLAllCollection
interface
are
legacy
platform
objects
with
an
additional
[[Call]]
internal
method
described
in
the
section
below
.
They
also
have
an
[[IsHTMLDDA]]
internal
slot.
Objects
that
implement
the
HTMLAllCollection
interface
have
several
unusual
behaviors,
due
of
the
fact
that
they
have
an
[[IsHTMLDDA]]
internal
slot:
The
ToBoolean
abstract
operation
in
JavaScript
returns
false
when
given
objects
implementing
the
HTMLAllCollection
interface.
The
IsLooselyEqual
abstract
operation,
when
given
objects
implementing
the
HTMLAllCollection
interface,
returns
true
when
compared
to
the
undefined
and
null
values.
(Comparisons
using
the
IsStrictlyEqual
abstract
operation,
and
IsLooselyEqual
comparisons
to
other
values
such
as
strings
or
objects,
are
unaffected.)
The
typeof
operator
in
JavaScript
returns
the
string
"undefined"
when
applied
to
objects
implementing
the
HTMLAllCollection
interface.
These
special
behaviors
are
motivated
by
a
desire
for
compatibility
with
two
classes
of
legacy
content:
one
that
uses
the
presence
of
document.all
as
a
way
to
detect
legacy
user
agents,
and
one
that
only
supports
those
legacy
user
agents
and
uses
the
document.all
object
without
testing
for
its
presence
first.
[JAVASCRIPT]
[Exposed=Window,
LegacyUnenumerableNamedProperties]
interface HTMLAllCollection {
readonly attribute unsigned long length;
getter Element (unsigned long index);
getter (HTMLCollection or Element)? namedItem(DOMString name);
(HTMLCollection or Element)? item(optional DOMString nameOrIndex);
// Note: HTMLAllCollection objects have a custom [[Call]] internal method and an [[IsHTMLDDA]] internal slot.
};
The
object's
supported
property
indices
are
as
defined
for
HTMLCollection
objects.
The
supported
property
names
consist
of
the
non-empty
values
of
all
the
id
attributes
of
all
the
elements
represented
by
the
collection
,
and
the
non-empty
values
of
all
the
name
attributes
of
all
the
"all"-named
elements
represented
by
the
collection
,
in
tree
order
,
ignoring
later
duplicates,
with
the
id
of
an
element
preceding
its
name
if
it
contributes
both,
they
differ
from
each
other,
and
neither
is
the
duplicate
of
an
earlier
entry.
The
length
getter
steps
are
to
return
the
number
of
nodes
represented
by
the
collection
.
The indexed property getter must return the result of getting the "all"-indexed element from this given the passed index.
The
namedItem(
name
)
method
steps
are
to
return
the
result
of
getting
the
"all"-named
element(s)
from
this
given
name
.
The
item(
nameOrIndex
)
method
steps
are:
If nameOrIndex was not provided, return null.
Return the result of getting the "all"-indexed or named element(s) from this , given nameOrIndex .
The
following
elements
are
"all"-named
elements
:
a
,
button
,
embed
,
form
,
frame
,
frameset
,
iframe
,
img
,
input
,
map
,
meta
,
object
,
select
,
and
textarea
To
get
the
"all"-indexed
element
from
an
HTMLAllCollection
collection
given
an
index
index
,
return
the
index
th
element
in
collection
,
or
null
if
there
is
no
such
index
th
element.
To
get
the
"all"-named
element(s)
from
an
HTMLAllCollection
collection
given
a
name
name
,
perform
the
following
steps:
If name is the empty string, return null.
Let
subCollection
be
an
HTMLCollection
object
rooted
at
the
same
Document
as
collection
,
whose
filter
matches
only
elements
that
are
either:
"all"-named
elements
with
a
name
attribute
equal
to
name
,
or,
elements with an ID equal to name .
If there is exactly one element in subCollection , then return that element.
Otherwise, if subCollection is empty, return null.
Otherwise, return subCollection .
To
get
the
"all"-indexed
or
named
element(s)
from
an
HTMLAllCollection
collection
given
nameOrIndex
:
If nameOrIndex , converted to a JavaScript String value, is an array index property name , return the result of getting the "all"-indexed element from collection given the number represented by nameOrIndex .
Return the result of getting the "all"-named element(s) from collection given nameOrIndex .
If argumentsList 's size is zero, or if argumentsList [0] is undefined, return null.
Let
nameOrIndex
be
the
result
of
converting
argumentsList
[0]
to
a
DOMString
.
Let
result
be
the
result
of
getting
the
"all"-indexed
or
named
element(s)
from
this
HTMLAllCollection
given
nameOrIndex
.
Return the result of converting result to an ECMAScript value.
The
thisArgument
is
ignored,
and
thus
code
such
as
Function.prototype.call.call(document.all,
null,
"x")
will
still
search
for
elements.
(
document.all.call
does
not
exist,
since
document.all
does
not
inherit
from
Function.prototype
.)
HTMLFormControlsCollection
interface
The
HTMLFormControlsCollection
interface
is
used
for
collections
of
listed
elements
in
form
elements.
Support in all current engines.
Support in all current engines.
[Exposed=Window]
interface HTMLFormControlsCollection : HTMLCollection {
// inherits length and item()
getter (RadioNodeList or Element)? namedItem(DOMString name); // shadows inherited namedItem()
};
[Exposed=Window]
interface RadioNodeList : NodeList {
attribute DOMString value;
};
collection
.
length
Returns the number of elements in collection .
element
=
collection
.
item
(
index
)
element
=
collection
[
index
]
Returns the item at index index in collection . The items are sorted in tree order .
element
=
collection
.
namedItem
(
name
)
HTMLFormControlsCollection/namedItem
Support in all current engines.
radioNodeList
=
collection
.
namedItem
(
name
)
element
=
collection
[
name
]
radioNodeList
=
collection
[
name
]
Returns
the
item
with
ID
or
name
name
from
collection
.
If
there
are
multiple
matching
items,
then
a
RadioNodeList
object
containing
all
those
elements
is
returned.
radioNodeList
.
value
Returns the value of the first checked radio button represented by radioNodeList .
radioNodeList
.
value
=
value
Checks the first first radio button represented by radioNodeList that has value value .
The
object's
supported
property
indices
are
as
defined
for
HTMLCollection
objects.
The
supported
property
names
consist
of
the
non-empty
values
of
all
the
id
and
name
attributes
of
all
the
elements
represented
by
the
collection
,
in
tree
order
,
ignoring
later
duplicates,
with
the
id
of
an
element
preceding
its
name
if
it
contributes
both,
they
differ
from
each
other,
and
neither
is
the
duplicate
of
an
earlier
entry.
The
namedItem(
name
)
method
must
act
according
to
the
following
algorithm:
id
attribute
or
a
name
attribute
equal
to
name
,
then
return
that
node
and
stop
the
algorithm.
id
attribute
or
a
name
attribute
equal
to
name
,
then
return
null
and
stop
the
algorithm.
RadioNodeList
object
representing
a
live
view
of
the
HTMLFormControlsCollection
object,
further
filtered
so
that
the
only
nodes
in
the
RadioNodeList
object
are
those
that
have
either
an
id
attribute
or
a
name
attribute
equal
to
name
.
The
nodes
in
the
RadioNodeList
object
must
be
sorted
in
tree
order
.
RadioNodeList
object.
Members
of
the
RadioNodeList
interface
inherited
from
the
NodeList
interface
must
behave
as
they
would
on
a
NodeList
object.
Support in all current engines.
The
value
IDL
attribute
on
the
RadioNodeList
object,
on
getting,
must
return
the
value
returned
by
running
the
following
steps:
Let
element
be
the
first
element
in
tree
order
represented
by
the
RadioNodeList
object
that
is
an
input
element
whose
type
attribute
is
in
the
Radio
Button
state
and
whose
checkedness
is
true.
Otherwise,
let
it
be
null.
If element is null, return the empty string.
If
element
is
an
element
with
no
value
attribute,
return
the
string
"
on
".
Otherwise,
return
the
value
of
element
's
value
attribute.
On
setting,
the
value
IDL
attribute
must
run
the
following
steps:
If
the
new
value
is
the
string
"
on
":
let
element
be
the
first
element
in
tree
order
represented
by
the
RadioNodeList
object
that
is
an
input
element
whose
type
attribute
is
in
the
Radio
Button
state
and
whose
value
content
attribute
is
either
absent,
or
present
and
equal
to
the
new
value,
if
any.
If
no
such
element
exists,
then
instead
let
element
be
null.
Otherwise:
let
element
be
the
first
element
in
tree
order
represented
by
the
RadioNodeList
object
that
is
an
input
element
whose
type
attribute
is
in
the
Radio
Button
state
and
whose
value
content
attribute
is
present
and
equal
to
the
new
value,
if
any.
If
no
such
element
exists,
then
instead
let
element
be
null.
If element is not null, then set its checkedness to true.
HTMLOptionsCollection
interface
Support in all current engines.
The
HTMLOptionsCollection
interface
is
used
for
collections
of
option
elements.
It
is
always
rooted
on
a
select
element
and
has
attributes
and
methods
that
manipulate
that
element's
descendants.
[Exposed=Window]
interface HTMLOptionsCollection : HTMLCollection {
// inherits item(), namedItem()
[CEReactions] attribute unsigned long length; // shadows inherited length
[CEReactions] setter undefined (unsigned long index, HTMLOptionElement? option);
[CEReactions] undefined add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
[CEReactions] undefined remove(long index);
attribute long selectedIndex;
};
collection
.
length
Returns the number of elements in collection .
collection
.
length
=
value
When
set
to
a
smaller
number
than
the
existing
length,
truncates
the
number
of
option
elements
in
the
container
corresponding
to
collection
.
When
set
to
a
greater
number
than
the
existing
length,
if
that
number
is
less
than
or
equal
to
100000,
adds
new
blank
option
elements
to
the
container
corresponding
to
collection
.
element
=
collection
.
item
(
index
)
element
=
collection
[
index
]
Returns the item at index index in collection . The items are sorted in tree order .
collection
[
index
]
=
element
When
index
is
a
greater
number
than
the
number
of
items
in
collection
,
adds
new
blank
option
elements
in
the
corresponding
container.
When set to null, removes the item at index index from collection .
When
set
to
an
option
element,
adds
or
replaces
it
at
index
index
in
collection
.
element
=
collection
.
namedItem
(
name
)
element
=
collection
[
name
]
Returns
the
item
with
ID
or
name
name
from
collection
.
If there are multiple matching items, then the first is returned.
collection
.
add
(
element
[,
before
])
Inserts element before the node given by before .
The before argument can be a number, in which case element is inserted before the item with that number, or an element from collection , in which case element is inserted before that element.
If before is omitted, null, or a number out of range, then element will be added at the end of the list.
Throws
a
"
HierarchyRequestError
"
DOMException
if
element
is
an
ancestor
of
the
element
into
which
it
is
to
be
inserted.
collection
.
remove
(
index
)
Removes the item with index index from collection .
collection
.
selectedIndex
Returns the index of the first selected item, if any, or −1 if there is no selected item.
collection
.
selectedIndex
=
index
Changes
the
selection
to
the
option
element
at
index
index
in
collection
.
The
object's
supported
property
indices
are
as
defined
for
HTMLCollection
objects.
The
length
getter
steps
are
to
return
the
number
of
nodes
represented
by
the
collection
.
The
length
setter
steps
are:
Let current be the number of nodes represented by the collection .
If the given value is greater than current , then:
If the given value is greater than 100,000, then return.
Let n be value − current .
Append
n
new
option
elements
with
no
attributes
and
no
child
nodes
to
the
select
element
on
which
this
is
rooted.
Mutation
events
must
be
fired
as
if
a
DocumentFragment
containing
the
new
option
elements
had
been
inserted.
If the given value is less than current , then:
Let n be current − value .
Remove the last n nodes in the collection from their parent nodes.
Setting
length
never
removes
or
adds
any
optgroup
elements,
and
never
adds
new
children
to
existing
optgroup
elements
(though
it
can
remove
children
from
them).
The
supported
property
names
consist
of
the
non-empty
values
of
all
the
id
and
name
attributes
of
all
the
elements
represented
by
the
collection
,
in
tree
order
,
ignoring
later
duplicates,
with
the
id
of
an
element
preceding
its
name
if
it
contributes
both,
they
differ
from
each
other,
and
neither
is
the
duplicate
of
an
earlier
entry.
When the user agent is to set the value of a new indexed property or set the value of an existing indexed property for a given property index index to a new value value , it must run the following algorithm:
If
value
is
null,
invoke
the
steps
for
the
remove
method
with
index
as
the
argument,
and
return.
Let length be the number of nodes represented by the collection .
Let n be index minus length .
If
n
is
greater
than
zero,
then
append
a
DocumentFragment
consisting
of
n
-1
new
option
elements
with
no
attributes
and
no
child
nodes
to
the
select
element
on
which
the
HTMLOptionsCollection
is
rooted.
If
n
is
greater
than
or
equal
to
zero,
append
value
to
the
select
element.
Otherwise,
replace
the
index
th
element
in
the
collection
by
value
.
The
add(
element
,
before
)
method
must
act
according
to
the
following
algorithm:
If
element
is
an
ancestor
of
the
select
element
on
which
the
HTMLOptionsCollection
is
rooted,
then
throw
a
"
HierarchyRequestError
"
DOMException
.
If
before
is
an
element,
but
that
element
isn't
a
descendant
of
the
select
element
on
which
the
HTMLOptionsCollection
is
rooted,
then
throw
a
"
NotFoundError
"
DOMException
.
If element and before are the same element, then return.
If before is a node, then let reference be that node. Otherwise, if before is an integer, and there is a before th node in the collection, let reference be that node. Otherwise, let reference be null.
If
reference
is
not
null,
let
parent
be
the
parent
node
of
reference
.
Otherwise,
let
parent
be
the
select
element
on
which
the
HTMLOptionsCollection
is
rooted.
Pre-insert element into parent node before reference .
The
remove(
index
)
method
must
act
according
to
the
following
algorithm:
If the number of nodes represented by the collection is zero, return.
If index is not a number greater than or equal to 0 and less than the number of nodes represented by the collection , return.
Let element be the index th element in the collection.
Remove element from its parent node.
The
selectedIndex
IDL
attribute
must
act
like
the
identically
named
attribute
on
the
select
element
on
which
the
HTMLOptionsCollection
is
rooted
DOMStringList
interface
Support in all current engines.
The
DOMStringList
interface
is
a
non-fashionable
retro
way
of
representing
a
list
of
strings.
[Exposed=(Window,Worker)]
interface DOMStringList {
readonly attribute unsigned long length;
getter DOMString? item(unsigned long index);
boolean contains(DOMString string);
};
New
APIs
must
use
sequence<DOMString>
or
equivalent
rather
than
DOMStringList
.
strings
.
length
Returns the number of strings in strings .
strings
[
index
]
strings
.
item
(
index
)
Returns the string with index index from strings .
strings
.
contains
(
string
)
Returns true if strings contains string , and false otherwise.
Each
DOMStringList
object
has
an
associated
list
.
The
DOMStringList
interface
supports
indexed
properties
.
The
supported
property
indices
are
the
indices
of
this
's
associated
list.
The
length
getter
steps
are
to
return
this
's
associated
list's
size
.
The
item(
index
)
method
steps
are
to
return
the
index
th
item
in
this
's
associated
list,
or
null
if
index
plus
one
is
greater
than
this
's
associated
list's
size
.
The
contains(
string
)
method
steps
are
to
return
true
if
this
's
associated
list
contains
string
,
and
false
otherwise.