You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1490 lines
99 KiB
1490 lines
99 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html lang="en-US-x-Hixie" ><head><title>2.8 Common DOM interfaces — HTML5 </title><style type="text/css">
|
|
pre { margin-left: 2em; white-space: pre-wrap; }
|
|
h2 { margin: 3em 0 1em 0; }
|
|
h3 { margin: 2.5em 0 1em 0; }
|
|
h4 { margin: 2.5em 0 0.75em 0; }
|
|
h5, h6 { margin: 2.5em 0 1em; }
|
|
h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
|
|
h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
|
|
p { margin: 1em 0; }
|
|
hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
|
|
dl, dd { margin-top: 0; margin-bottom: 0; }
|
|
dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
|
|
dt + dt { margin-top: 0; }
|
|
dd dt { margin-top: 0.25em; margin-bottom: 0; }
|
|
dd p { margin-top: 0; }
|
|
dd dl + p { margin-top: 1em; }
|
|
dd table + p { margin-top: 1em; }
|
|
p + * > li, dd li { margin: 1em 0; }
|
|
dt, dfn { font-weight: bold; font-style: normal; }
|
|
dt dfn { font-style: italic; }
|
|
pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
|
|
pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
|
|
pre em { font-weight: bolder; font-style: normal; }
|
|
@media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
|
|
var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
|
|
table { border-collapse: collapse; border-style: hidden hidden none hidden; }
|
|
table thead, table tbody { border-bottom: solid; }
|
|
table tbody th:first-child { border-left: solid; }
|
|
table tbody th { text-align: left; }
|
|
table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
|
|
blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
|
|
|
|
.bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
|
|
.matrix, .matrix td { border: none; text-align: right; }
|
|
.matrix { margin-left: 2em; }
|
|
.dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
|
|
.dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
|
|
.dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
|
|
|
|
.toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
|
|
img.extra { float: right; }
|
|
pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
|
|
pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
|
|
pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
|
|
pre.css:first-line { color: #AAAA50; }
|
|
dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
|
|
hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
|
|
dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
|
|
dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
|
|
dl.domintro dd p { margin: 0.5em 0; }
|
|
dl.switch { padding-left: 2em; }
|
|
dl.switch > dt { text-indent: -1.5em; }
|
|
dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
|
|
dl.triple { padding: 0 0 0 1em; }
|
|
dl.triple dt, dl.triple dd { margin: 0; display: inline }
|
|
dl.triple dt:after { content: ':'; }
|
|
dl.triple dd:after { content: '\A'; white-space: pre; }
|
|
.diff-old { text-decoration: line-through; color: silver; background: transparent; }
|
|
.diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
|
|
a .diff-new { border-bottom: 1px blue solid; }
|
|
|
|
h2 { page-break-before: always; }
|
|
h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
|
|
h1 + h2, hr + h2.no-toc { page-break-before: auto; }
|
|
|
|
p > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]),
|
|
li > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]), { border-bottom: solid #9999CC; }
|
|
|
|
div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
|
|
div.head p { margin: 0; }
|
|
div.head h1 { margin: 0; }
|
|
div.head .logo { float: right; margin: 0 1em; }
|
|
div.head .logo img { border: none } /* remove border from top image */
|
|
div.head dl { margin: 1em 0; }
|
|
div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
|
|
|
|
body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
|
|
body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
|
|
body > .toc > li > * { margin-bottom: 0.5em; }
|
|
body > .toc > li > * > li > * { margin-bottom: 0.25em; }
|
|
.toc, .toc li { list-style: none; }
|
|
|
|
.brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
|
|
.brief li { margin: 0; padding: 0; }
|
|
.brief li p { margin: 0; padding: 0; }
|
|
|
|
.category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
|
|
.category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
|
|
.category-list li { display: inline; }
|
|
.category-list li:not(:last-child)::after { content: ', '; }
|
|
.category-list li > span, .category-list li > a { text-transform: lowercase; }
|
|
.category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
|
|
|
|
.XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
|
|
.XXX > :first-child { margin-top: 0; }
|
|
p .XXX { line-height: 3em; }
|
|
.annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
|
|
.annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
|
|
.annotation :link, .annotation :visited { color: inherit; }
|
|
.annotation :link:hover, .annotation :visited:hover { background: transparent; }
|
|
.annotation span { border: none ! important; }
|
|
.note { color: green; background: transparent; font-family: sans-serif; }
|
|
.warning { color: red; background: transparent; }
|
|
.note, .warning { font-weight: bolder; font-style: italic; }
|
|
p.note, div.note { padding: 0.5em 2em; }
|
|
span.note { padding: 0 2em; }
|
|
.note p:first-child, .warning p:first-child { margin-top: 0; }
|
|
.note p:last-child, .warning p:last-child { margin-bottom: 0; }
|
|
.warning:before { font-style: normal; }
|
|
p.note:before { content: 'Note: '; }
|
|
p.warning:before { content: '\26A0 Warning! '; }
|
|
|
|
.bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
|
|
.bookkeeping { font-size: 0.8em; margin: 2em 0; }
|
|
.bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
|
|
.bookkeeping dt { margin: 0.5em 2em 0; }
|
|
.bookkeeping dd { margin: 0 3em 0.5em; }
|
|
|
|
h4 { position: relative; z-index: 3; }
|
|
h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
|
|
.element {
|
|
background: #EEEEFF;
|
|
color: black;
|
|
margin: 0 0 1em 0.15em;
|
|
padding: 0 1em 0.25em 0.75em;
|
|
border-left: solid #9999FF 0.25em;
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
.element:before {
|
|
position: absolute;
|
|
z-index: 2;
|
|
top: 0;
|
|
left: -1.15em;
|
|
height: 2em;
|
|
width: 0.9em;
|
|
background: #EEEEFF;
|
|
content: ' ';
|
|
border-style: none none solid solid;
|
|
border-color: #9999FF;
|
|
border-width: 0.25em;
|
|
}
|
|
|
|
.example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
|
|
td > .example:only-child { margin: 0 0 0 0.1em; }
|
|
|
|
ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
|
|
ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
|
|
ul.domTree li li { list-style: none; }
|
|
ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
|
|
ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
|
|
ul.domTree span { font-style: italic; font-family: serif; }
|
|
ul.domTree .t1 code { color: purple; font-weight: bold; }
|
|
ul.domTree .t2 { font-style: normal; font-family: monospace; }
|
|
ul.domTree .t2 .name { color: black; font-weight: bold; }
|
|
ul.domTree .t2 .value { color: blue; font-weight: normal; }
|
|
ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
|
|
ul.domTree .t7 code, .domTree .t8 code { color: green; }
|
|
ul.domTree .t10 code { color: teal; }
|
|
|
|
body.dfnEnabled dfn { cursor: pointer; }
|
|
.dfnPanel {
|
|
display: inline;
|
|
position: absolute;
|
|
z-index: 10;
|
|
height: auto;
|
|
width: auto;
|
|
padding: 0.5em 0.75em;
|
|
font: small sans-serif, Droid Sans Fallback;
|
|
background: #DDDDDD;
|
|
color: black;
|
|
border: outset 0.2em;
|
|
}
|
|
.dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
|
|
.dfnPanel :link, .dfnPanel :visited { color: black; }
|
|
.dfnPanel p { font-weight: bolder; }
|
|
.dfnPanel * + p { margin-top: 0.25em; }
|
|
.dfnPanel li { list-style-position: inside; }
|
|
|
|
#configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
|
|
#configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
|
|
#configUI p label { display: block; }
|
|
#configUI #updateUI, #configUI .loginUI { text-align: center; }
|
|
#configUI input[type=button] { display: block; margin: auto; }
|
|
|
|
fieldset { margin: 1em; padding: 0.5em 1em; }
|
|
fieldset > legend + * { margin-top: 0; }
|
|
fieldset > :last-child { margin-bottom: 0; }
|
|
fieldset p { margin: 0.5em 0; }
|
|
|
|
.stability {
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 0; right: 0;
|
|
margin: 0 auto 0 auto !important;
|
|
z-index: 1000;
|
|
width: 50%;
|
|
background: maroon; color: yellow;
|
|
-webkit-border-radius: 1em 1em 0 0;
|
|
-moz-border-radius: 1em 1em 0 0;
|
|
border-radius: 1em 1em 0 0;
|
|
-moz-box-shadow: 0 0 1em #500;
|
|
-webkit-box-shadow: 0 0 1em #500;
|
|
box-shadow: 0 0 1em red;
|
|
padding: 0.5em 1em;
|
|
text-align: center;
|
|
}
|
|
.stability strong {
|
|
display: block;
|
|
}
|
|
.stability input {
|
|
appearance: none; margin: 0; border: 0; padding: 0.25em 0.5em; background: transparent; color: black;
|
|
position: absolute; top: -0.5em; right: 0; font: 1.25em sans-serif; text-align: center;
|
|
}
|
|
.stability input:hover {
|
|
color: white;
|
|
text-shadow: 0 0 2px black;
|
|
}
|
|
.stability input:active {
|
|
padding: 0.3em 0.45em 0.2em 0.55em;
|
|
}
|
|
.stability :link, .stability :visited,
|
|
.stability :link:hover, .stability :visited:hover {
|
|
background: transparent;
|
|
color: white;
|
|
}
|
|
|
|
</style><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D%0Ahtml%20%7B%20border:%20solid%20yellow;%20%7D%20.domintro:before%20%7B%20display:%20none;%20%7D" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D%20.domintro:before%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation
|
|
requirements"><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css"><style type="text/css">
|
|
|
|
.applies thead th > * { display: block; }
|
|
.applies thead code { display: block; }
|
|
.applies tbody th { whitespace: nowrap; }
|
|
.applies td { text-align: center; }
|
|
.applies .yes { background: yellow; }
|
|
|
|
.matrix, .matrix td { border: hidden; text-align: right; }
|
|
.matrix { margin-left: 2em; }
|
|
|
|
.dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
|
|
.dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
|
|
.dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
|
|
|
|
td.eg { border-width: thin; text-align: center; }
|
|
|
|
#table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
|
|
#table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
|
|
#table-example-1 caption { padding-bottom: 0.5em; }
|
|
#table-example-1 thead, #table-example-1 tbody { border: none; }
|
|
#table-example-1 th, #table-example-1 td { border: solid thin; }
|
|
#table-example-1 th { font-weight: normal; }
|
|
#table-example-1 td { border-style: none solid; vertical-align: top; }
|
|
#table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
|
|
#table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
|
|
#table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
|
|
#table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
|
|
#table-example-1 tbody td:first-child::after { content: leader(". "); }
|
|
#table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
|
|
#table-example-1 tbody td:first-child + td { width: 10em; }
|
|
#table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
|
|
#table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
|
|
|
|
.apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
|
|
.apple-table-examples * { font-family: "Times", serif; }
|
|
.apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
|
|
.apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
|
|
.apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
|
|
.apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
|
|
.apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
|
|
.apple-table-examples td { text-align: right; vertical-align: top; }
|
|
.apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
|
|
.apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
|
|
.apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
|
|
.apple-table-examples sup { line-height: 0; }
|
|
|
|
.details-example img { vertical-align: top; }
|
|
|
|
#base64-table {
|
|
white-space: nowrap;
|
|
font-size: 0.6em;
|
|
column-width: 6em;
|
|
column-count: 5;
|
|
column-gap: 1em;
|
|
-moz-column-width: 6em;
|
|
-moz-column-count: 5;
|
|
-moz-column-gap: 1em;
|
|
-webkit-column-width: 6em;
|
|
-webkit-column-count: 5;
|
|
-webkit-column-gap: 1em;
|
|
}
|
|
#base64-table thead { display: none; }
|
|
#base64-table * { border: none; }
|
|
#base64-table tbody td:first-child:after { content: ':'; }
|
|
#base64-table tbody td:last-child { text-align: right; }
|
|
|
|
#named-character-references-table {
|
|
white-space: nowrap;
|
|
font-size: 0.6em;
|
|
column-width: 30em;
|
|
column-gap: 1em;
|
|
-moz-column-width: 30em;
|
|
-moz-column-gap: 1em;
|
|
-webkit-column-width: 30em;
|
|
-webkit-column-gap: 1em;
|
|
}
|
|
#named-character-references-table > table > tbody > tr > td:first-child + td,
|
|
#named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
|
|
#named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
|
|
#named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }
|
|
|
|
.glyph.control { color: red; }
|
|
|
|
@font-face {
|
|
font-family: 'Essays1743';
|
|
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf');
|
|
}
|
|
@font-face {
|
|
font-family: 'Essays1743';
|
|
font-weight: bold;
|
|
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf');
|
|
}
|
|
@font-face {
|
|
font-family: 'Essays1743';
|
|
font-style: italic;
|
|
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf');
|
|
}
|
|
@font-face {
|
|
font-family: 'Essays1743';
|
|
font-style: italic;
|
|
font-weight: bold;
|
|
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
|
|
}
|
|
|
|
</style><style type="text/css">
|
|
.domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
|
|
</style><script type="text/javascript">
|
|
function getCookie(name) {
|
|
var params = location.search.substr(1).split("&");
|
|
for (var index = 0; index < params.length; index++) {
|
|
if (params[index] == name)
|
|
return "1";
|
|
var data = params[index].split("=");
|
|
if (data[0] == name)
|
|
return unescape(data[1]);
|
|
}
|
|
var cookies = document.cookie.split("; ");
|
|
for (var index = 0; index < cookies.length; index++) {
|
|
var data = cookies[index].split("=");
|
|
if (data[0] == name)
|
|
return unescape(data[1]);
|
|
}
|
|
return null;
|
|
}
|
|
</script>
|
|
<script src="link-fixup.js" type="text/javascript"></script>
|
|
<link href="style.css" rel="stylesheet"><link href="fetching-resources.html" title="2.7 Fetching resources" rel="prev">
|
|
<link href="spec.html#contents" title="Table of contents" rel="index">
|
|
<link href="namespaces.html" title="2.9 Namespaces" rel="next">
|
|
</head><body><div class="head" id="head">
|
|
<div id="multipage-common">
|
|
<p class="stability" id="wip"><strong>This is a work in
|
|
progress!</strong> For the latest updates from the HTML WG, possibly
|
|
including important bug fixes, please look at the <a href="http://dev.w3.org/html5/spec/Overview.html">editor's draft</a> instead.
|
|
There may also be a more
|
|
<a href="http://www.w3.org/TR/html5">up-to-date Working Draft</a>
|
|
with changes based on resolution of Last Call issues.
|
|
<input onclick="closeWarning(this.parentNode)" type="button" value="╳⃝"></p>
|
|
<script type="text/javascript">
|
|
function closeWarning(element) {
|
|
element.parentNode.removeChild(element);
|
|
var date = new Date();
|
|
date.setDate(date.getDate()+4);
|
|
document.cookie = 'hide-obsolescence-warning=1; expires=' + date.toGMTString();
|
|
}
|
|
if (getCookie('hide-obsolescence-warning') == '1')
|
|
setTimeout(function () { document.getElementById('wip').parentNode.removeChild(document.getElementById('wip')); }, 2000);
|
|
</script></div>
|
|
|
|
<p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
|
|
|
|
<h1>HTML5</h1>
|
|
</div><div>
|
|
<a href="fetching-resources.html" class="prev">2.7 Fetching resources</a> –
|
|
<a href="spec.html#contents">Table of contents</a> –
|
|
<a href="namespaces.html" class="next">2.9 Namespaces</a>
|
|
<ol class="toc"><li><ol><li><a href="common-dom-interfaces.html#common-dom-interfaces"><span class="secno">2.8 </span>Common DOM interfaces</a>
|
|
<ol><li><a href="common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes"><span class="secno">2.8.1 </span>Reflecting content attributes in IDL attributes</a></li><li><a href="common-dom-interfaces.html#collections-0"><span class="secno">2.8.2 </span>Collections</a>
|
|
<ol><li><a href="common-dom-interfaces.html#htmlcollection-0"><span class="secno">2.8.2.1 </span>HTMLCollection</a></li><li><a href="common-dom-interfaces.html#htmlallcollection-0"><span class="secno">2.8.2.2 </span>HTMLAllCollection</a></li><li><a href="common-dom-interfaces.html#htmlformcontrolscollection-0"><span class="secno">2.8.2.3 </span>HTMLFormControlsCollection</a></li><li><a href="common-dom-interfaces.html#htmloptionscollection-0"><span class="secno">2.8.2.4 </span>HTMLOptionsCollection</a></li></ol></li><li><a href="common-dom-interfaces.html#domtokenlist-0"><span class="secno">2.8.3 </span>DOMTokenList</a></li><li><a href="common-dom-interfaces.html#domsettabletokenlist-0"><span class="secno">2.8.4 </span>DOMSettableTokenList</a></li><li><a href="common-dom-interfaces.html#safe-passing-of-structured-data"><span class="secno">2.8.5 </span>Safe passing of structured data</a></li><li><a href="common-dom-interfaces.html#domstringmap-0"><span class="secno">2.8.6 </span>DOMStringMap</a></li><li><a href="common-dom-interfaces.html#dom-feature-strings"><span class="secno">2.8.7 </span>DOM feature strings</a></li><li><a href="common-dom-interfaces.html#exceptions"><span class="secno">2.8.8 </span>Exceptions</a></li><li><a href="common-dom-interfaces.html#garbage-collection"><span class="secno">2.8.9 </span>Garbage collection</a></li></ol></li></ol></li></ol></div>
|
|
|
|
<h3 id="common-dom-interfaces"><span class="secno">2.8 </span>Common DOM interfaces</h3><h4 id="reflecting-content-attributes-in-idl-attributes"><span class="secno">2.8.1 </span>Reflecting content attributes in IDL attributes</h4><p>Some IDL attributes are defined to <dfn id="reflect">reflect</dfn> a
|
|
particular content attribute. This means that on getting, the IDL
|
|
attribute returns the current value of the content attribute, and on
|
|
setting, the IDL attribute changes the value of the content
|
|
attribute to the given value.</p><div class="impl">
|
|
|
|
<p>In general, on getting, if the content attribute is not present,
|
|
the IDL attribute must act as if the content attribute's value is
|
|
the empty string; and on setting, if the content attribute is not
|
|
present, it must first be added.</p>
|
|
|
|
<p>If a reflecting IDL attribute is a <code>DOMString</code>
|
|
attribute whose content attribute is defined to contain a
|
|
<a href="urls.html#url">URL</a>, then on getting, the IDL attribute must <a href="urls.html#resolve-a-url" title="resolve a url">resolve</a> the value of the content
|
|
attribute relative to the element and return the resulting
|
|
<a href="urls.html#absolute-url">absolute URL</a> if that was successful, or the empty
|
|
string otherwise; and on setting, must set the content attribute to
|
|
the specified literal value. If the content attribute is absent, the
|
|
IDL attribute must return the default value, if the content
|
|
attribute has one, or else the empty string.</p>
|
|
|
|
<p>If a reflecting IDL attribute is a <code>DOMString</code>
|
|
attribute whose content attribute is defined to contain one or more
|
|
<a href="urls.html#url" title="URL">URLs</a>, then on getting, the IDL attribute
|
|
must <a href="common-microsyntaxes.html#split-a-string-on-spaces" title="split a string on spaces">split the content
|
|
attribute on spaces</a> and return the concatenation of <a href="urls.html#resolve-a-url" title="resolve a URL">resolving</a> each token URL to an
|
|
<a href="urls.html#absolute-url">absolute URL</a> relative to the element, with a single
|
|
U+0020 SPACE character between each URL, ignoring any tokens that
|
|
did not resolve successfully. If the content attribute is absent,
|
|
the IDL attribute must return the default value, if the content
|
|
attribute has one, or else the empty string. On setting, the IDL
|
|
attribute must set the content attribute to the specified literal
|
|
value.</p>
|
|
|
|
<p>If a reflecting IDL attribute is a <code>DOMString</code>
|
|
attribute whose content attribute is an <a href="common-microsyntaxes.html#enumerated-attribute">enumerated
|
|
attribute</a>, and the IDL attribute is <dfn id="limited-to-only-known-values">limited to only
|
|
known values</dfn>, then, on getting, the IDL attribute must return
|
|
the conforming value associated with the state the attribute is in
|
|
(in its canonical case), or the empty string if the attribute is in
|
|
a state that has no associated keyword value; and on setting, the
|
|
content attribute must be set to the specified new value.</p>
|
|
|
|
<p>If a reflecting IDL attribute is a <code>DOMString</code>
|
|
attribute but doesn't fall into any of the above categories, then
|
|
the getting and setting must be done in a transparent,
|
|
case-preserving manner.</p>
|
|
|
|
<p>If a reflecting IDL attribute is a <code title="">boolean</code>
|
|
attribute, then on getting the IDL attribute must return true if the
|
|
content attribute is set, and false if it is absent. On setting, the
|
|
content attribute must be removed if the IDL attribute is set to
|
|
false, and must be set to the empty string if the IDL attribute is
|
|
set to true. (This corresponds to the rules for <a href="common-microsyntaxes.html#boolean-attribute" title="boolean
|
|
attribute">boolean content attributes</a>.)</p>
|
|
|
|
<p>If a reflecting IDL attribute has a signed integer type
|
|
(<code>long</code>) then, on getting, the content attribute must be
|
|
parsed according to the <a href="common-microsyntaxes.html#rules-for-parsing-integers" title="rules for parsing
|
|
integers">rules for parsing signed integers</a>, and if that is
|
|
successful, and the value is in the range of the 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 to the shortest possible string representing the number as
|
|
a <a href="common-microsyntaxes.html#valid-integer">valid integer</a> and then that string must be used as
|
|
the new content attribute value.</p>
|
|
|
|
<p>If a reflecting IDL attribute has a signed integer type
|
|
(<code>long</code>) that is <dfn id="limited-to-only-non-negative-numbers">limited to only non-negative
|
|
numbers</dfn> then, on getting, the content attribute must be parsed
|
|
according to the <a href="common-microsyntaxes.html#rules-for-parsing-non-negative-integers">rules for parsing non-negative
|
|
integers</a>, and if that is successful, and the value is in the
|
|
range of the 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 the value is negative, the user agent must fire an
|
|
<code><a href="#index_size_err">INDEX_SIZE_ERR</a></code> exception. Otherwise, the given value
|
|
must be converted to the shortest possible string representing the
|
|
number as a <a href="common-microsyntaxes.html#valid-non-negative-integer">valid non-negative integer</a> and then that
|
|
string must be used as the new content attribute value.</p>
|
|
|
|
<p>If a reflecting IDL attribute has an <em>unsigned</em> integer
|
|
type (<code>unsigned long</code>) then, on getting, the content
|
|
attribute must be parsed according to the <a href="common-microsyntaxes.html#rules-for-parsing-non-negative-integers">rules for parsing
|
|
non-negative integers</a>, and if that is successful, and the
|
|
value is in the range 0 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, or 0 if there is no default value. On
|
|
setting, the given value must be converted to the shortest possible
|
|
string representing the number as a <a href="common-microsyntaxes.html#valid-non-negative-integer">valid non-negative
|
|
integer</a> and then that string must be used as the new content
|
|
attribute value.</p>
|
|
|
|
<p>If a reflecting IDL attribute has an unsigned integer type
|
|
(<code>unsigned long</code>) that is <dfn id="limited-to-only-non-negative-numbers-greater-than-zero">limited to only
|
|
non-negative numbers greater than zero</dfn>, then the behavior is
|
|
similar to the previous case, but zero is not allowed. On getting,
|
|
the content attribute must first be parsed according to the
|
|
<a href="common-microsyntaxes.html#rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</a>, and if that is
|
|
successful, and the value is in the range 1 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, or 1 if there is
|
|
no default value. On setting, if the value is zero, the user agent
|
|
must fire an <code><a href="#index_size_err">INDEX_SIZE_ERR</a></code> exception. Otherwise, the
|
|
given value must be converted to the shortest possible string
|
|
representing the number as a <a href="common-microsyntaxes.html#valid-non-negative-integer">valid non-negative integer</a>
|
|
and then that string must be used as the new content attribute
|
|
value.</p>
|
|
|
|
<p>If a reflecting IDL attribute has a floating point number type
|
|
(<code>double</code>), then, on getting, the content attribute must
|
|
be parsed according to the <a href="common-microsyntaxes.html#rules-for-parsing-floating-point-number-values">rules for parsing floating point
|
|
number values</a>, 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 to the <a href="common-microsyntaxes.html#best-representation-of-the-number-as-a-floating-point-number">best representation of the number as a
|
|
floating point number</a> and then that string must be used as
|
|
the new content attribute value.</p>
|
|
|
|
<p class="note">The values Infinity and Not-a-Number (NaN) values
|
|
throw an exception on setting, as <a href="infrastructure.html#float-nan">defined
|
|
earlier</a>.</p>
|
|
|
|
<p>If a reflecting IDL attribute has the type
|
|
<code><a href="#domtokenlist">DOMTokenList</a></code> or <code><a href="#domsettabletokenlist">DOMSettableTokenList</a></code>, then
|
|
on getting it must return a <code><a href="#domtokenlist">DOMTokenList</a></code> or
|
|
<code><a href="#domsettabletokenlist">DOMSettableTokenList</a></code> object (as appropriate) whose
|
|
underlying string is the element's corresponding content attribute.
|
|
When the object mutates its underlying string, the content attribute
|
|
must itself be immediately mutated. When the attribute is absent,
|
|
then the string represented by the object is the empty string; when
|
|
the object mutates this empty string, the user agent must add the
|
|
corresponding content attribute, with its value set to the value it
|
|
would have been set to after mutating the empty string. The same
|
|
<code><a href="#domtokenlist">DOMTokenList</a></code> or <code><a href="#domsettabletokenlist">DOMSettableTokenList</a></code>
|
|
object must be returned every time for each attribute.</p>
|
|
|
|
<div class="example">
|
|
|
|
<p>If an element with no attributes has its <code title="dom-tokenlist-remove"><a href="#dom-tokenlist-remove">element.classList.remove()</a></code>
|
|
method invoked, the underlying string won't be changed, since the
|
|
result of removing any token from the empty string is still the
|
|
empty string. However, if the <code title="dom-tokenlist-add"><a href="#dom-tokenlist-add">element.classList.add()</a></code> method is
|
|
then invoked, a <code title="attr-class"><a href="elements.html#classes">class</a></code> attribute
|
|
will be added to the element with the value of the token to be
|
|
added.</p>
|
|
|
|
</div>
|
|
|
|
<p>If a reflecting IDL attribute has the type
|
|
<code><a href="elements.html#htmlelement">HTMLElement</a></code>, or an interface that descends from
|
|
<code><a href="elements.html#htmlelement">HTMLElement</a></code>, then, on getting, it must run the
|
|
following algorithm (stopping at the first point where a value is
|
|
returned):</p>
|
|
|
|
<ol><li>If the corresponding content attribute is absent, then the
|
|
IDL attribute must return null.</li>
|
|
|
|
<li>Let <var title="">candidate</var> be the element that the <code title="dom-Document-getElementById"><a href="infrastructure.html#dom-document-getelementbyid">document.getElementById()</a></code> method
|
|
would find when called on the content attribute's document if it
|
|
was passed as its argument the current value of the corresponding
|
|
content attribute.</li>
|
|
|
|
<li>If <var title="">candidate</var> is null, or if it is not
|
|
type-compatible with the IDL attribute, then the IDL attribute must
|
|
return null.</li>
|
|
|
|
<li>Otherwise, it must return <var title="">candidate</var>.</li>
|
|
|
|
</ol><p>On setting, if the given element has an <code title="attr-id"><a href="elements.html#the-id-attribute">id</a></code> attribute, then the content attribute must
|
|
be set to the value of that <code title="attr-id"><a href="elements.html#the-id-attribute">id</a></code>
|
|
attribute. Otherwise, the IDL attribute must be set to the empty
|
|
string.</p>
|
|
|
|
</div><h4 id="collections-0"><span class="secno">2.8.2 </span>Collections</h4><p>The <code><a href="#htmlcollection">HTMLCollection</a></code>, <code><a href="#htmlallcollection">HTMLAllCollection</a></code>,
|
|
<code><a href="#htmlformcontrolscollection">HTMLFormControlsCollection</a></code>,
|
|
<code><a href="#htmloptionscollection">HTMLOptionsCollection</a></code>,
|
|
interfaces represent various
|
|
lists of DOM nodes. Collectively, objects implementing these
|
|
interfaces are called <dfn id="collections">collections</dfn>.</p><p>When a <a href="#collections" title="collections">collection</a> is created, a
|
|
filter and a root are associated with the collection.</p><p class="example">For example, when the <code><a href="#htmlcollection">HTMLCollection</a></code>
|
|
object for the <code title="dom-document-images"><a href="dom.html#dom-document-images">document.images</a></code> attribute is
|
|
created, it is associated with a filter that selects only
|
|
<code><a href="embedded-content-1.html#the-img-element">img</a></code> elements, and rooted at the root of the
|
|
document.</p><p>The <a href="#collections" title="collections">collection</a> then <dfn id="represented-by-the-collection" title="represented by the collection">represents</dfn> a
|
|
<a href="infrastructure.html#live">live</a> view of the subtree rooted at the collection's
|
|
root, containing only nodes that match the given filter. The view is
|
|
linear. <span class="impl">In the absence of specific requirements
|
|
to the contrary, the nodes within the collection must be sorted in
|
|
<a href="infrastructure.html#tree-order">tree order</a>.</span></p><div class="impl">
|
|
|
|
<p class="note">The <code title="dom-table-rows"><a href="tabular-data.html#dom-table-rows">rows</a></code> list is
|
|
not in tree order.</p>
|
|
|
|
<p>An attribute that returns a collection must return the same
|
|
object every time it is retrieved.</p>
|
|
|
|
</div><h5 id="htmlcollection-0"><span class="secno">2.8.2.1 </span>HTMLCollection</h5><p>The <code><a href="#htmlcollection">HTMLCollection</a></code> interface represents a generic
|
|
<a href="#collections" title="collections">collection</a> of elements.</p><pre class="idl">interface <dfn id="htmlcollection">HTMLCollection</dfn> {
|
|
readonly attribute unsigned long <a href="#dom-htmlcollection-length" title="dom-HTMLCollection-length">length</a>;
|
|
caller getter <a href="infrastructure.html#element">Element</a> <a href="#dom-htmlcollection-item" title="dom-HTMLCollection-item">item</a>(in unsigned long index);
|
|
caller getter object <a href="#dom-htmlcollection-nameditem" title="dom-HTMLCollection-namedItem">namedItem</a>(in DOMString name); // only returns Element
|
|
};</pre><dl class="domintro"><dt><var title="">collection</var> . <code title="dom-HTMLCollection-length"><a href="#dom-htmlcollection-length">length</a></code></dt>
|
|
<dd>
|
|
<p>Returns the number of elements in the collection.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLCollection-item"><a href="#dom-htmlcollection-item">item</a></code>(<var title="">index</var>)</dt>
|
|
<dt><var title="">collection</var>[<var title="">index</var>]</dt>
|
|
<dt><var title="">collection</var>(<var title="">index</var>)</dt>
|
|
<dd>
|
|
<p>Returns the item with index <var title="">index</var> from the collection. The items are sorted in <a href="infrastructure.html#tree-order">tree order</a>.</p>
|
|
<p>Returns null if <var title="">index</var> is out of range.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLCollection-namedItem"><a href="#dom-htmlcollection-nameditem">namedItem</a></code>(<var title="">name</var>)</dt>
|
|
<dt><var title="">collection</var>[<var title="">name</var>]</dt>
|
|
<dt><var title="">collection</var>(<var title="">name</var>)</dt>
|
|
<dd>
|
|
<p>Returns the first item with <a href="elements.html#concept-id" title="concept-id">ID</a> or name <var title="">name</var>
|
|
from the collection.</p>
|
|
<p>Returns null if no element with that <a href="elements.html#concept-id" title="concept-id">ID</a> or name could be found.</p>
|
|
<p>Only <code><a href="text-level-semantics.html#the-a-element">a</a></code>, <code><a href="obsolete.html#the-applet-element">applet</a></code>, <code><a href="the-map-element.html#the-area-element">area</a></code>,
|
|
<code><a href="the-iframe-element.html#the-embed-element">embed</a></code>, <code><a href="forms.html#the-form-element">form</a></code>, <code><a href="obsolete.html#frame">frame</a></code>,
|
|
<code><a href="obsolete.html#frameset">frameset</a></code>, <code><a href="the-iframe-element.html#the-iframe-element">iframe</a></code>, <code><a href="embedded-content-1.html#the-img-element">img</a></code>, and
|
|
<code><a href="the-iframe-element.html#the-object-element">object</a></code> elements can have a name for the purpose of
|
|
this method; their name is given by the value of their <code title="">name</code> attribute.</p>
|
|
</dd>
|
|
</dl><div class="impl">
|
|
|
|
<p>The object's <a href="infrastructure.html#supported-property-indices">supported property indices</a> are the
|
|
numbers in the range zero to one less than the number of nodes
|
|
<a href="#represented-by-the-collection">represented by the collection</a>. If there are no such
|
|
elements, then there are no <a href="infrastructure.html#supported-property-indices">supported property
|
|
indices</a>.</p>
|
|
|
|
<p>The <dfn id="dom-htmlcollection-length" title="dom-HTMLCollection-length"><code>length</code></dfn>
|
|
attribute must return the number of nodes <a href="#represented-by-the-collection">represented by the
|
|
collection</a>.</p>
|
|
|
|
<p>The <dfn id="dom-htmlcollection-item" title="dom-HTMLCollection-item"><code>item(<var title="">index</var>)</code></dfn> method must return the <var title="">index</var>th node in the collection. If there is no <var title="">index</var>th node in the collection, then the method must
|
|
return null.</p>
|
|
|
|
<p>The <a href="infrastructure.html#supported-property-names">supported property names</a> consist
|
|
of the values of the <code title="">name</code> attributes of each
|
|
<code><a href="text-level-semantics.html#the-a-element">a</a></code>, <code><a href="obsolete.html#the-applet-element">applet</a></code>, <code><a href="the-map-element.html#the-area-element">area</a></code>,
|
|
<code><a href="the-iframe-element.html#the-embed-element">embed</a></code>, <code><a href="forms.html#the-form-element">form</a></code>, <code><a href="obsolete.html#frame">frame</a></code>,
|
|
<code><a href="obsolete.html#frameset">frameset</a></code>, <code><a href="the-iframe-element.html#the-iframe-element">iframe</a></code>, <code><a href="embedded-content-1.html#the-img-element">img</a></code>, and
|
|
<code><a href="the-iframe-element.html#the-object-element">object</a></code> element <a href="#represented-by-the-collection">represented by the
|
|
collection</a> with a <code title="">name</code> attribute, plus
|
|
the list of IDs that the elements <a href="#represented-by-the-collection">represented by the
|
|
collection</a> have.</p>
|
|
|
|
<p>The <dfn id="dom-htmlcollection-nameditem" title="dom-HTMLCollection-namedItem"><code>namedItem(<var title="">key</var>)</code></dfn> method must return the first node
|
|
in the collection that matches either of the following
|
|
requirements:</p>
|
|
|
|
<ul><li>It is an <code><a href="text-level-semantics.html#the-a-element">a</a></code>, <code><a href="obsolete.html#the-applet-element">applet</a></code>,
|
|
<code><a href="the-map-element.html#the-area-element">area</a></code>, <code><a href="the-iframe-element.html#the-embed-element">embed</a></code>, <code><a href="forms.html#the-form-element">form</a></code>,
|
|
<code><a href="obsolete.html#frame">frame</a></code>, <code><a href="obsolete.html#frameset">frameset</a></code>, <code><a href="the-iframe-element.html#the-iframe-element">iframe</a></code>,
|
|
<code><a href="embedded-content-1.html#the-img-element">img</a></code>, or <code><a href="the-iframe-element.html#the-object-element">object</a></code> element with a <code title="">name</code> attribute equal to <var title="">key</var>,
|
|
or,</li>
|
|
|
|
<li>It is an element with an <a href="elements.html#concept-id" title="concept-id">ID</a>
|
|
equal to <var title="">key</var>.</li>
|
|
|
|
</ul><p>If no such elements are found, then the method must return
|
|
null.</p>
|
|
|
|
</div><h5 id="htmlallcollection-0"><span class="secno">2.8.2.2 </span>HTMLAllCollection</h5><p>The <code><a href="#htmlallcollection">HTMLAllCollection</a></code> interface represents a generic
|
|
<a href="#collections" title="collections">collection</a> of elements just like
|
|
<code><a href="#htmlcollection">HTMLCollection</a></code>, with the exception that its <code title="dom-HTMLAllCollection-namedItem"><a href="#dom-htmlallcollection-nameditem">namedItem()</a></code> method
|
|
returns an <code><a href="#htmlallcollection">HTMLAllCollection</a></code> object when there are
|
|
multiple matching elements.</p><pre class="idl">interface <dfn id="htmlallcollection">HTMLAllCollection</dfn> : <a href="#htmlcollection">HTMLCollection</a> {
|
|
// inherits <a href="#dom-htmlcollection-length" title="dom-HTMLCollection-length">length</a> and <a href="#dom-htmlcollection-item" title="dom-HTMLCollection-item">item</a>()
|
|
caller getter object <a href="#dom-htmlallcollection-nameditem" title="dom-HTMLAllCollection-namedItem">namedItem</a>(in DOMString name); // overrides inherited namedItem()
|
|
<a href="#htmlallcollection">HTMLAllCollection</a> <a href="#dom-htmlallcollection-tags" title="dom-HTMLAllCollection-tags">tags</a>(in DOMString tagName);
|
|
};</pre><dl class="domintro"><dt><var title="">collection</var> . <code title="dom-HTMLCollection-length"><a href="#dom-htmlcollection-length">length</a></code></dt>
|
|
<dd>
|
|
<p>Returns the number of elements in the collection.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLCollection-item"><a href="#dom-htmlcollection-item">item</a></code>(<var title="">index</var>)</dt>
|
|
<dt><var title="">collection</var>[<var title="">index</var>]</dt>
|
|
<dt><var title="">collection</var>(<var title="">index</var>)</dt>
|
|
<dd>
|
|
<p>Returns the item with index <var title="">index</var> from the collection. The items are sorted in <a href="infrastructure.html#tree-order">tree order</a>.</p>
|
|
<p>Returns null if <var title="">index</var> is out of range.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLAllCollection-namedItem"><a href="#dom-htmlallcollection-nameditem">namedItem</a></code>(<var title="">name</var>)</dt>
|
|
<dt><var title="">collection</var> = <var title="">collection</var> . <code title="dom-HTMLAllCollection-namedItem"><a href="#dom-htmlallcollection-nameditem">namedItem</a></code>(<var title="">name</var>)</dt>
|
|
<dt><var title="">collection</var>[<var title="">name</var>]</dt>
|
|
<dt><var title="">collection</var>(<var title="">name</var>)</dt>
|
|
<dd>
|
|
<p>Returns the item with <a href="elements.html#concept-id" title="concept-id">ID</a> or name <var title="">name</var> from the collection.</p>
|
|
<p>If there are multiple matching items, then an <code><a href="#htmlallcollection">HTMLAllCollection</a></code> object containing all those elements is returned.</p>
|
|
<p>Returns null if no element with that <a href="elements.html#concept-id" title="concept-id">ID</a> or name could be found.</p>
|
|
<p>Only <code><a href="text-level-semantics.html#the-a-element">a</a></code>, <code><a href="obsolete.html#the-applet-element">applet</a></code>, <code><a href="the-map-element.html#the-area-element">area</a></code>,
|
|
<code><a href="the-iframe-element.html#the-embed-element">embed</a></code>, <code><a href="forms.html#the-form-element">form</a></code>, <code><a href="obsolete.html#frame">frame</a></code>,
|
|
<code><a href="obsolete.html#frameset">frameset</a></code>, <code><a href="the-iframe-element.html#the-iframe-element">iframe</a></code>, <code><a href="embedded-content-1.html#the-img-element">img</a></code>, and
|
|
<code><a href="the-iframe-element.html#the-object-element">object</a></code> elements can have a name for the purpose of
|
|
this method; their name is given by the value of their <code title="">name</code> attribute.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">collection</var> = <var title="">collection</var> . <code title="dom-HTMLAllCollection-tags"><a href="#dom-htmlallcollection-tags">tags</a></code>(<var title="">tagName</var>)</dt>
|
|
<dd>
|
|
<p>Returns a collection that is a filtered view of the current collection, containing only elements with the given tag name.</p>
|
|
</dd>
|
|
|
|
</dl><div class="impl">
|
|
|
|
<p>The object's <a href="infrastructure.html#supported-property-indices">supported property indices</a> and
|
|
<a href="infrastructure.html#supported-property-names">supported property names</a> are as defined for
|
|
<code><a href="#htmlcollection">HTMLCollection</a></code> objects.</p>
|
|
|
|
<p>The <dfn id="dom-htmlallcollection-nameditem" title="dom-HTMLAllCollection-namedItem"><code>namedItem(<var title="">key</var>)</code></dfn> method must act according to the
|
|
following algorithm:</p>
|
|
|
|
<ol><li>
|
|
|
|
<p>Let <var title="">collection</var> be an
|
|
<code><a href="#htmlallcollection">HTMLAllCollection</a></code> object rooted at the same node as
|
|
the <code><a href="#htmlallcollection">HTMLAllCollection</a></code> object on which the method was
|
|
invoked, whose filter matches only elements that already
|
|
match the filter of the <code><a href="#htmlallcollection">HTMLAllCollection</a></code> object on
|
|
which the method was invoked and that are either:</p>
|
|
|
|
<ul><li><code><a href="text-level-semantics.html#the-a-element">a</a></code>, <code><a href="obsolete.html#the-applet-element">applet</a></code>, <code><a href="the-map-element.html#the-area-element">area</a></code>,
|
|
<code><a href="the-iframe-element.html#the-embed-element">embed</a></code>, <code><a href="forms.html#the-form-element">form</a></code>, <code><a href="obsolete.html#frame">frame</a></code>,
|
|
<code><a href="obsolete.html#frameset">frameset</a></code>, <code><a href="the-iframe-element.html#the-iframe-element">iframe</a></code>, <code><a href="embedded-content-1.html#the-img-element">img</a></code>, or
|
|
<code><a href="the-iframe-element.html#the-object-element">object</a></code> elements with a <code title="">name</code>
|
|
attribute equal to <var title="">key</var>, or,</li>
|
|
|
|
<li>elements with an <a href="elements.html#concept-id" title="concept-id">ID</a> equal to
|
|
<var title="">key</var>.</li>
|
|
|
|
</ul></li>
|
|
|
|
<li>If, at the time the method is called, there is exactly one node
|
|
in <var title="">collection</var>, then return that node and stop
|
|
the algorithm.</li>
|
|
|
|
<li>Otherwise, if, at the time the method is called, <var title="">collection</var> is empty, return null and stop the
|
|
algorithm.</li>
|
|
|
|
<li>Otherwise, return <var title="">collection</var>.</li>
|
|
|
|
</ol><p>The <dfn id="dom-htmlallcollection-tags" title="dom-HTMLAllCollection-tags"><code>tags(<var title="">tagName</var>)</code></dfn> method must return an
|
|
<code><a href="#htmlallcollection">HTMLAllCollection</a></code> rooted at the same node as the
|
|
<code><a href="#htmlallcollection">HTMLAllCollection</a></code> object on which the method was
|
|
invoked, whose filter matches only <a href="infrastructure.html#html-elements">HTML elements</a> whose
|
|
local name is the <var title="">tagName</var> argument and that
|
|
already match the filter of the <code><a href="#htmlallcollection">HTMLAllCollection</a></code>
|
|
object on which the method was invoked. In <a href="dom.html#html-documents">HTML
|
|
documents</a>, the argument must first be <a href="infrastructure.html#converted-to-ascii-lowercase">converted to
|
|
ASCII lowercase</a>.</p>
|
|
|
|
</div><h5 id="htmlformcontrolscollection-0"><span class="secno">2.8.2.3 </span>HTMLFormControlsCollection</h5><p>The <code><a href="#htmlformcontrolscollection">HTMLFormControlsCollection</a></code> interface represents
|
|
a <a href="#collections" title="collections">collection</a> of <a href="forms.html#category-listed" title="category-listed">listed elements</a> in <code><a href="forms.html#the-form-element">form</a></code>
|
|
and <code><a href="forms.html#the-fieldset-element">fieldset</a></code> elements.</p><pre class="idl">interface <dfn id="htmlformcontrolscollection">HTMLFormControlsCollection</dfn> : <a href="#htmlcollection">HTMLCollection</a> {
|
|
// inherits <a href="#dom-htmlcollection-length" title="dom-HTMLCollection-length">length</a> and <a href="#dom-htmlcollection-item" title="dom-HTMLCollection-item">item</a>()
|
|
caller getter object <a href="#dom-htmlformcontrolscollection-nameditem" title="dom-HTMLFormControlsCollection-namedItem">namedItem</a>(in DOMString name); // overrides inherited namedItem()
|
|
};
|
|
|
|
interface <dfn id="radionodelist">RadioNodeList</dfn> : <a href="infrastructure.html#nodelist">NodeList</a> {
|
|
attribute DOMString <a href="#dom-radionodelist-value" title="dom-RadioNodeList-value">value</a>;
|
|
};</pre><dl class="domintro"><dt><var title="">collection</var> . <code title="dom-HTMLCollection-length"><a href="#dom-htmlcollection-length">length</a></code></dt>
|
|
<dd>
|
|
<p>Returns the number of elements in the collection.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLCollection-item"><a href="#dom-htmlcollection-item">item</a></code>(<var title="">index</var>)</dt>
|
|
<dt><var title="">collection</var>[<var title="">index</var>]</dt>
|
|
<dt><var title="">collection</var>(<var title="">index</var>)</dt>
|
|
<dd>
|
|
<p>Returns the item with index <var title="">index</var> from the collection. The items are sorted in <a href="infrastructure.html#tree-order">tree order</a>.</p>
|
|
<p>Returns null if <var title="">index</var> is out of range.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLFormControlsCollection-namedItem"><a href="#dom-htmlformcontrolscollection-nameditem">namedItem</a></code>(<var title="">name</var>)</dt>
|
|
<dt><var title="">radioNodeList</var> = <var title="">collection</var> . <code title="dom-HTMLFormControlsCollection-namedItem"><a href="#dom-htmlformcontrolscollection-nameditem">namedItem</a></code>(<var title="">name</var>)</dt>
|
|
<dt><var title="">collection</var>[<var title="">name</var>]</dt>
|
|
<dt><var title="">collection</var>(<var title="">name</var>)</dt>
|
|
<dd>
|
|
<p>Returns the item with <a href="elements.html#concept-id" title="concept-id">ID</a> or <code title="attr-fe-name"><a href="association-of-controls-and-forms.html#attr-fe-name">name</a></code> <var title="">name</var> from the collection.</p>
|
|
<p>If there are multiple matching items, then a <code><a href="#radionodelist">RadioNodeList</a></code> object containing all those elements is returned.</p>
|
|
<p>Returns null if no element with that <a href="elements.html#concept-id" title="concept-id">ID</a> or <code title="attr-fe-name"><a href="association-of-controls-and-forms.html#attr-fe-name">name</a></code> could be found.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">radioNodeList</var> . <var title="">value</var> [ = <var title="">value</var> ]</dt>
|
|
<dd>
|
|
<p>Returns the value of the first checked radio button represented by the object.</p>
|
|
<p>Can be set, to check the first radio button with the given value represented by the object.</p>
|
|
</dd>
|
|
|
|
</dl><div class="impl">
|
|
|
|
<p>The object's <a href="infrastructure.html#supported-property-indices">supported property indices</a> are as
|
|
defined for <code><a href="#htmlcollection">HTMLCollection</a></code> objects.</p>
|
|
|
|
<p>The <a href="infrastructure.html#supported-property-names">supported property names</a> consist of the values
|
|
of all the <code title="attr-id"><a href="elements.html#the-id-attribute">id</a></code> and <code title="attr-fe-name"><a href="association-of-controls-and-forms.html#attr-fe-name">name</a></code> attributes of all the elements
|
|
<a href="#represented-by-the-collection">represented by the collection</a>.</p>
|
|
|
|
<p>The <dfn id="dom-htmlformcontrolscollection-nameditem" title="dom-HTMLFormControlsCollection-namedItem"><code>namedItem(<var title="">name</var>)</code></dfn> method must act according to the
|
|
following algorithm:</p>
|
|
|
|
<ol><li>If, at the time the method is called, there is exactly one node
|
|
in the collection that has either an <code title="attr-id"><a href="elements.html#the-id-attribute">id</a></code> attribute or a <code title="attr-fe-name"><a href="association-of-controls-and-forms.html#attr-fe-name">name</a></code> attribute equal to <var title="">name</var>, then return that node and stop the
|
|
algorithm.</li>
|
|
|
|
<li>Otherwise, if there are no nodes in the collection that have
|
|
either an <code title="attr-id"><a href="elements.html#the-id-attribute">id</a></code> attribute or a <code title="attr-fe-name"><a href="association-of-controls-and-forms.html#attr-fe-name">name</a></code> attribute equal to <var title="">name</var>, then return null and stop the algorithm.</li>
|
|
|
|
<li>Otherwise, create a new <code><a href="#radionodelist">RadioNodeList</a></code> object
|
|
representing a <a href="infrastructure.html#live">live</a> view of the
|
|
<code><a href="#htmlformcontrolscollection">HTMLFormControlsCollection</a></code> object, further filtered so
|
|
that the only nodes in the <code><a href="#radionodelist">RadioNodeList</a></code> object are
|
|
those that have either an <code title="attr-id"><a href="elements.html#the-id-attribute">id</a></code> attribute
|
|
or a <code title="attr-fe-name"><a href="association-of-controls-and-forms.html#attr-fe-name">name</a></code> attribute equal to <var title="">name</var>. The nodes in the <code><a href="#radionodelist">RadioNodeList</a></code>
|
|
object must be sorted in <a href="infrastructure.html#tree-order">tree order</a>.</li>
|
|
|
|
<li>Return that <code><a href="#radionodelist">RadioNodeList</a></code> object.</li>
|
|
|
|
</ol><hr><p>Members of the <code><a href="#radionodelist">RadioNodeList</a></code> interface inherited
|
|
from the <code><a href="infrastructure.html#nodelist">NodeList</a></code> interface must behave as they would
|
|
on a <code><a href="infrastructure.html#nodelist">NodeList</a></code> object.</p>
|
|
|
|
<p>The <dfn id="dom-radionodelist-value" title="dom-RadioNodeList-value"><code>value</code></dfn>
|
|
IDL attribute on the <code><a href="#radionodelist">RadioNodeList</a></code> object, on getting,
|
|
must return the value returned by running the following steps:</p>
|
|
|
|
<ol><li><p>Let <var title="">element</var> be the first element in
|
|
<a href="infrastructure.html#tree-order">tree order</a> represented by the
|
|
<code><a href="#radionodelist">RadioNodeList</a></code> object that is an <code><a href="the-input-element.html#the-input-element">input</a></code>
|
|
element whose <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute
|
|
is in the <a href="number-state.html#radio-button-state" title="attr-input-type-radio">Radio Button</a>
|
|
state and whose <a href="association-of-controls-and-forms.html#concept-fe-checked" title="concept-fe-checked">checkedness</a>
|
|
is true. Otherwise, let it be null.</p></li>
|
|
|
|
<li><p>If <var title="">element</var> is null, or if it is an
|
|
element with no <code title="attr-input-value"><a href="the-input-element.html#attr-input-value">value</a></code>
|
|
attribute, return the empty string.</p></li>
|
|
|
|
<li><p>Otherwise, return the value of <var title="">element</var>'s
|
|
<code title="attr-input-value"><a href="the-input-element.html#attr-input-value">value</a></code> attribute.</p></li>
|
|
|
|
</ol><p>On setting, the <code title="dom-RadioNodeList-value"><a href="#dom-radionodelist-value">value</a></code> IDL attribute must run
|
|
the following steps:</p>
|
|
|
|
<ol><li><p>Let <var title="">element</var> be the first element in
|
|
<a href="infrastructure.html#tree-order">tree order</a> represented by the
|
|
<code><a href="#radionodelist">RadioNodeList</a></code> object that is an <code><a href="the-input-element.html#the-input-element">input</a></code>
|
|
element whose <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute
|
|
is in the <a href="number-state.html#radio-button-state" title="attr-input-type-radio">Radio Button</a>
|
|
state and whose <code title="attr-input-value"><a href="the-input-element.html#attr-input-value">value</a></code> content
|
|
attribute is present and equal to the new value, if any. Otherwise,
|
|
let it be null.</p></li>
|
|
|
|
<li><p>If <var title="">element</var> is not null, then set its
|
|
<a href="association-of-controls-and-forms.html#concept-fe-checked" title="concept-fe-checked">checkedness</a> to true.</p>
|
|
|
|
</li></ol></div><h5 id="htmloptionscollection-0"><span class="secno">2.8.2.4 </span>HTMLOptionsCollection</h5><p>The <code><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> interface represents a
|
|
list of <code><a href="the-button-element.html#the-option-element">option</a></code> elements. It is always rooted on a
|
|
<code><a href="the-button-element.html#the-select-element">select</a></code> element and has attributes and methods that
|
|
manipulate that element's descendants.</p><pre class="idl">interface <dfn id="htmloptionscollection">HTMLOptionsCollection</dfn> : <a href="#htmlcollection">HTMLCollection</a> {
|
|
// inherits <a href="#dom-htmlcollection-item" title="dom-HTMLCollection-item">item</a>()
|
|
attribute unsigned long <a href="#dom-htmloptionscollection-length" title="dom-HTMLOptionsCollection-length">length</a>; // overrides inherited length
|
|
caller getter object <a href="#dom-htmloptionscollection-nameditem" title="dom-HTMLOptionsCollection-namedItem">namedItem</a>(in DOMString name); // overrides inherited namedItem()
|
|
void <a href="#dom-htmloptionscollection-add" title="dom-HTMLOptionsCollection-add">add</a>(in <a href="elements.html#htmlelement">HTMLElement</a> element, in optional <a href="elements.html#htmlelement">HTMLElement</a> before);
|
|
void <a href="#dom-htmloptionscollection-add" title="dom-HTMLOptionsCollection-add">add</a>(in <a href="elements.html#htmlelement">HTMLElement</a> element, in long before);
|
|
void <a href="#dom-htmloptionscollection-remove" title="dom-HTMLOptionsCollection-remove">remove</a>(in long index);
|
|
attribute long <a href="#dom-htmloptionscollection-selectedindex" title="dom-HTMLOptionsCollection-selectedIndex">selectedIndex</a>;
|
|
};</pre><dl class="domintro"><dt><var title="">collection</var> . <code title="dom-HTMLOptionsCollection-length"><a href="#dom-htmloptionscollection-length">length</a></code> [ = <var title="">value</var> ]</dt>
|
|
<dd>
|
|
<p>Returns the number of elements in the collection.</p>
|
|
<p>When set to a smaller number, truncates the number of <code><a href="the-button-element.html#the-option-element">option</a></code> elements in the corresponding container.</p>
|
|
<p>When set to a greater number, adds new blank <code><a href="the-button-element.html#the-option-element">option</a></code> elements to that container.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLCollection-item"><a href="#dom-htmlcollection-item">item</a></code>(<var title="">index</var>)</dt>
|
|
<dt><var title="">collection</var>[<var title="">index</var>]</dt>
|
|
<dt><var title="">collection</var>(<var title="">index</var>)</dt>
|
|
<dd>
|
|
<p>Returns the item with index <var title="">index</var> from the collection. The items are sorted in <a href="infrastructure.html#tree-order">tree order</a>.</p>
|
|
<p>Returns null if <var title="">index</var> is out of range.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLOptionsCollection-namedItem"><a href="#dom-htmloptionscollection-nameditem">namedItem</a></code>(<var title="">name</var>)</dt>
|
|
<dt><var title="">nodeList</var> = <var title="">collection</var> . <code title="dom-HTMLOptionsCollection-namedItem"><a href="#dom-htmloptionscollection-nameditem">namedItem</a></code>(<var title="">name</var>)</dt>
|
|
<dt><var title="">collection</var>[<var title="">name</var>]</dt>
|
|
<dt><var title="">collection</var>(<var title="">name</var>)</dt>
|
|
<dd>
|
|
<p>Returns the item with <a href="elements.html#concept-id" title="concept-id">ID</a> or <code title="attr-option-name"><a href="obsolete.html#attr-option-name">name</a></code> <var title="">name</var> from the collection.</p>
|
|
<p>If there are multiple matching items, then a <code><a href="infrastructure.html#nodelist">NodeList</a></code> object containing all those elements is returned.</p>
|
|
<p>Returns null if no element with that <a href="elements.html#concept-id" title="concept-id">ID</a> could be found.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">collection</var> . <code title="dom-HTMLOptionsCollection-add"><a href="#dom-htmloptionscollection-add">add</a></code>(<var title="">element</var> [, <var title="">before</var> ] )</dt>
|
|
<dd>
|
|
<p>Inserts <var title="">element</var> before the node given by <var title="">before</var>.</p>
|
|
<p>The <var title="">before</var> argument can be a number, in
|
|
which case <var title="">element</var> is inserted before the item
|
|
with that number, or an element from the collection, in which case
|
|
<var title="">element</var> is inserted before that element.</p>
|
|
<p>If <var title="">before</var> is omitted, null, or a number out
|
|
of range, then <var title="">element</var> will be added at the
|
|
end of the list.</p>
|
|
<p>This method will throw a <code><a href="#hierarchy_request_err">HIERARCHY_REQUEST_ERR</a></code>
|
|
exception if <var title="">element</var> is an ancestor of the
|
|
element into which it is to be inserted. If <var title="">element</var> is not an <code><a href="the-button-element.html#the-option-element">option</a></code> or
|
|
<code><a href="the-button-element.html#the-optgroup-element">optgroup</a></code> element, then the method does nothing.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">collection</var> . <code title="dom-HTMLOptionsCollection-selectedIndex"><a href="#dom-htmloptionscollection-selectedindex">selectedIndex</a></code> [ = <var title="">value</var> ]</dt>
|
|
|
|
<dd>
|
|
|
|
<p>Returns the index of the first selected item, if any, or
|
|
−1 if there is no selected item.</p>
|
|
|
|
<p>Can be set, to change the selection.</p>
|
|
|
|
</dd>
|
|
|
|
</dl><div class="impl">
|
|
|
|
<p>The object's <a href="infrastructure.html#supported-property-indices">supported property indices</a> are as
|
|
defined for <code><a href="#htmlcollection">HTMLCollection</a></code> objects.</p>
|
|
|
|
<p>On getting, the <dfn id="dom-htmloptionscollection-length" title="dom-HTMLOptionsCollection-length"><code>length</code></dfn>
|
|
attribute must return the number of nodes <a href="#represented-by-the-collection">represented by the
|
|
collection</a>.</p>
|
|
|
|
<p>On setting, the behavior depends on whether the new value is
|
|
equal to, greater than, or less than the number of nodes
|
|
<a href="#represented-by-the-collection">represented by the collection</a> at that time. If the
|
|
number is the same, then setting the attribute must do nothing. If
|
|
the new value is greater, then <var title="">n</var> new
|
|
<code><a href="the-button-element.html#the-option-element">option</a></code> elements with no attributes and no child nodes
|
|
must be appended to the <code><a href="the-button-element.html#the-select-element">select</a></code> element on which the
|
|
<code><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> is rooted, where <var title="">n</var> is the difference between the two numbers (new
|
|
value minus old value). Mutation events must be fired as if a
|
|
<code><a href="infrastructure.html#documentfragment">DocumentFragment</a></code> containing the new <code><a href="the-button-element.html#the-option-element">option</a></code>
|
|
elements had been inserted. If the new value is lower, then the
|
|
last <var title="">n</var> nodes in the collection must be removed
|
|
from their parent nodes, where <var title="">n</var> is the
|
|
difference between the two numbers (old value minus new value).</p>
|
|
|
|
<p class="note">Setting <code title="dom-HTMLOptionsCollection-length"><a href="#dom-htmloptionscollection-length">length</a></code> never removes
|
|
or adds any <code><a href="the-button-element.html#the-optgroup-element">optgroup</a></code> elements, and never adds new
|
|
children to existing <code><a href="the-button-element.html#the-optgroup-element">optgroup</a></code> elements (though it can
|
|
remove children from them).</p>
|
|
|
|
<p>The <a href="infrastructure.html#supported-property-names">supported property names</a> consist of the values
|
|
of all the <code title="attr-id"><a href="elements.html#the-id-attribute">id</a></code> and <code title="attr-option-name"><a href="obsolete.html#attr-option-name">name</a></code> attributes of all the elements
|
|
<a href="#represented-by-the-collection">represented by the collection</a>.</p>
|
|
|
|
<p>The <dfn id="dom-htmloptionscollection-nameditem" title="dom-HTMLOptionsCollection-namedItem"><code>namedItem(<var title="">name</var>)</code></dfn> method must act according to the
|
|
following algorithm:</p>
|
|
|
|
<ol><li>If, at the time the method is called, there is exactly one node
|
|
in the collection that has either an <code title="attr-id"><a href="elements.html#the-id-attribute">id</a></code> attribute or a <code title="attr-option-name"><a href="obsolete.html#attr-option-name">name</a></code> attribute equal to <var title="">name</var>, then return that node and stop the
|
|
algorithm.</li>
|
|
|
|
<li>Otherwise, if there are no nodes in the collection that have
|
|
either an <code title="attr-id"><a href="elements.html#the-id-attribute">id</a></code> attribute or a <code title="attr-option-name"><a href="obsolete.html#attr-option-name">name</a></code> attribute equal to <var title="">name</var>, then return null and stop the algorithm.</li>
|
|
|
|
|
|
<li>Otherwise, create a new <code><a href="infrastructure.html#nodelist">NodeList</a></code> object
|
|
representing a <a href="infrastructure.html#live">live</a> view of the
|
|
<code><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> object, further filtered so that
|
|
the only nodes in the <code><a href="infrastructure.html#nodelist">NodeList</a></code> object are those that
|
|
have either an <code title="attr-id"><a href="elements.html#the-id-attribute">id</a></code> attribute or a <code title="attr-option-name"><a href="obsolete.html#attr-option-name">name</a></code> attribute equal to <var title="">name</var>. The nodes in the <code><a href="infrastructure.html#nodelist">NodeList</a></code> object
|
|
must be sorted in <a href="infrastructure.html#tree-order">tree order</a>.</li>
|
|
|
|
<li>Return that <code><a href="infrastructure.html#nodelist">NodeList</a></code> object.</li>
|
|
|
|
</ol><p>The <dfn id="dom-htmloptionscollection-add" title="dom-HTMLOptionsCollection-add"><code>add(<var title="">element</var>, <var title="">before</var>)</code></dfn>
|
|
method must act according to the following algorithm:</p>
|
|
|
|
<ol><li><p>If <var title="">element</var> is not an <code><a href="the-button-element.html#the-option-element">option</a></code>
|
|
or <code><a href="the-button-element.html#the-optgroup-element">optgroup</a></code> element, then return and abort these
|
|
steps.</p></li>
|
|
|
|
<li><p>If <var title="">element</var> is an ancestor of the
|
|
<code><a href="the-button-element.html#the-select-element">select</a></code> element on which the
|
|
<code><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> is rooted, then throw a
|
|
<code><a href="#hierarchy_request_err">HIERARCHY_REQUEST_ERR</a></code> exception.</p></li>
|
|
|
|
<li><p>If <var title="">before</var> is an element, but that
|
|
element isn't a descendant of the <code><a href="the-button-element.html#the-select-element">select</a></code> element on
|
|
which the <code><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> is rooted, then throw
|
|
a <code><a href="#not_found_err">NOT_FOUND_ERR</a></code> exception.</p></li>
|
|
|
|
<li><p>If <var title="">element</var> and <var title="">before</var> are the same element, then return and abort
|
|
these steps.</p></li>
|
|
|
|
<li><p>If <var title="">before</var> is a node, then let <var title="">reference</var> be that node. Otherwise, if <var title="">before</var> is an integer, and there is a <var title="">before</var>th node in the collection, let <var title="">reference</var> be that node. Otherwise, let <var title="">reference</var> be null.</p></li>
|
|
|
|
<li><p>If <var title="">reference</var> is not null, let <var title="">parent</var> be the parent node of <var title="">reference</var>. Otherwise, let <var title="">parent</var>
|
|
be the <code><a href="the-button-element.html#the-select-element">select</a></code> element on which the
|
|
<code><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> is rooted.</p></li>
|
|
|
|
<li><p>Act as if the DOM Core <code title="dom-Node-insertBefore"><a href="infrastructure.html#dom-node-insertbefore">insertBefore()</a></code> method was
|
|
invoked on the <var title="">parent</var> node, with <var title="">element</var> as the first argument and <var title="">reference</var> as the second argument.</p>
|
|
|
|
</li></ol><p>The <dfn id="dom-htmloptionscollection-remove" title="dom-HTMLOptionsCollection-remove"><code>remove(<var title="">index</var>)</code></dfn> method must act according to
|
|
the following algorithm:</p>
|
|
|
|
<ol><li><p>If the number of nodes <a href="#represented-by-the-collection">represented by the
|
|
collection</a> is zero, abort these steps.</p></li>
|
|
|
|
<li><p>If <var title="">index</var> is not a number greater than or
|
|
equal to 0 and less than the number of nodes <a href="#represented-by-the-collection">represented by
|
|
the collection</a>, let <var title="">element</var> be the first
|
|
element in the collection. Otherwise, let <var title="">element</var> be the <var title="">index</var>th element
|
|
in the collection.</p></li>
|
|
|
|
<li><p>Remove <var title="">element</var> from its parent
|
|
node.</p></li>
|
|
|
|
</ol><p>The <dfn id="dom-htmloptionscollection-selectedindex" title="dom-HTMLOptionsCollection-selectedIndex"><code>selectedIndex</code></dfn>
|
|
IDL attribute must act like the identically named attribute on the
|
|
<code><a href="the-button-element.html#the-select-element">select</a></code> element on which the
|
|
<code><a href="#htmloptionscollection">HTMLOptionsCollection</a></code> is rooted</p>
|
|
|
|
|
|
|
|
</div><h4 id="domtokenlist-0"><span class="secno">2.8.3 </span>DOMTokenList</h4><p>The <code><a href="#domtokenlist">DOMTokenList</a></code> interface represents an interface
|
|
to an underlying string that consists of a <a href="common-microsyntaxes.html#set-of-space-separated-tokens">set of
|
|
space-separated tokens</a>.</p><p class="note"><code><a href="#domtokenlist">DOMTokenList</a></code> objects are always
|
|
<a href="infrastructure.html#case-sensitive">case-sensitive</a>, even when the underlying string might
|
|
ordinarily be treated in a case-insensitive manner.</p><pre class="idl">interface <dfn id="domtokenlist">DOMTokenList</dfn> {
|
|
readonly attribute unsigned long <a href="#dom-tokenlist-length" title="dom-tokenlist-length">length</a>;
|
|
getter DOMString <a href="#dom-tokenlist-item" title="dom-tokenlist-item">item</a>(in unsigned long index);
|
|
boolean <a href="#dom-tokenlist-contains" title="dom-tokenlist-contains">contains</a>(in DOMString token);
|
|
void <a href="#dom-tokenlist-add" title="dom-tokenlist-add">add</a>(in DOMString token);
|
|
void <a href="#dom-tokenlist-remove" title="dom-tokenlist-remove">remove</a>(in DOMString token);
|
|
boolean <a href="#dom-tokenlist-toggle" title="dom-tokenlist-toggle">toggle</a>(in DOMString token);
|
|
<a href="#dom-tokenlist-tostring" title="dom-tokenlist-toString">stringifier</a> DOMString ();
|
|
};</pre><dl class="domintro"><dt><var title="">tokenlist</var> . <code title="dom-tokenlist-length"><a href="#dom-tokenlist-length">length</a></code></dt>
|
|
<dd>
|
|
<p>Returns the number of tokens in the string.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">element</var> = <var title="">tokenlist</var> . <code title="dom-tokenlist-item"><a href="#dom-tokenlist-item">item</a></code>(<var title="">index</var>)</dt>
|
|
<dt><var title="">tokenlist</var>[<var title="">index</var>]</dt>
|
|
<dd>
|
|
<p>Returns the token with index <var title="">index</var>. The tokens are returned in the order they are found in the underlying string.</p>
|
|
<p>Returns null if <var title="">index</var> is out of range.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">hastoken</var> = <var title="">tokenlist</var> . <code title="dom-tokenlist-contains"><a href="#dom-tokenlist-contains">contains</a></code>(<var title="">token</var>)</dt>
|
|
<dd>
|
|
<p>Returns true if the <var title="">token</var> is present; false otherwise.</p>
|
|
<p>Throws a <code><a href="#syntax_err">SYNTAX_ERR</a></code> exception if <var title="">token</var> is empty.</p>
|
|
<p>Throws an <code><a href="#invalid_character_err">INVALID_CHARACTER_ERR</a></code> exception if <var title="">token</var> contains any spaces.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">tokenlist</var> . <code title="dom-tokenlist-add"><a href="#dom-tokenlist-add">add</a></code>(<var title="">token</var>)</dt>
|
|
<dd>
|
|
<p>Adds <var title="">token</var>, unless it is already present.</p>
|
|
<p>Throws a <code><a href="#syntax_err">SYNTAX_ERR</a></code> exception if <var title="">token</var> is empty.</p>
|
|
<p>Throws an <code><a href="#invalid_character_err">INVALID_CHARACTER_ERR</a></code> exception if <var title="">token</var> contains any spaces.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">tokenlist</var> . <code title="dom-tokenlist-remove"><a href="#dom-tokenlist-remove">remove</a></code>(<var title="">token</var>)</dt>
|
|
<dd>
|
|
<p>Removes <var title="">token</var> if it is present.</p>
|
|
<p>Throws a <code><a href="#syntax_err">SYNTAX_ERR</a></code> exception if <var title="">token</var> is empty.</p>
|
|
<p>Throws an <code><a href="#invalid_character_err">INVALID_CHARACTER_ERR</a></code> exception if <var title="">token</var> contains any spaces.</p>
|
|
</dd>
|
|
|
|
<dt><var title="">hastoken</var> = <var title="">tokenlist</var> . <code title="dom-tokenlist-toggle"><a href="#dom-tokenlist-toggle">toggle</a></code>(<var title="">token</var>)</dt>
|
|
<dd>
|
|
<p>Adds <var title="">token</var> if it is not present, or removes
|
|
it if it is. Returns true if <var title="">token</var> is now
|
|
present (it was added); returns false if it is not (it was
|
|
removed).</p>
|
|
<p>Throws a <code><a href="#syntax_err">SYNTAX_ERR</a></code> exception if <var title="">token</var> is empty.</p>
|
|
<p>Throws an <code><a href="#invalid_character_err">INVALID_CHARACTER_ERR</a></code> exception if <var title="">token</var> contains any spaces.</p>
|
|
</dd>
|
|
|
|
</dl><div class="impl">
|
|
|
|
<p>The <dfn id="dom-tokenlist-length" title="dom-tokenlist-length"><code>length</code></dfn>
|
|
attribute must return the number of tokens that result from <a href="common-microsyntaxes.html#split-a-string-on-spaces" title="split a string on spaces">splitting the underlying string on
|
|
spaces</a>. This is the <var title="dom-tokenlist-length"><a href="#dom-tokenlist-length">length</a></var>.</p>
|
|
|
|
<p>The object's <a href="infrastructure.html#supported-property-indices">supported property indices</a> are the
|
|
numbers in the range zero to <span title=""><var title="dom-tokenlist-length"><a href="#dom-tokenlist-length">length</a></var>-1</span>, unless the <var title="dom-tokenlist-length"><a href="#dom-tokenlist-length">length</a></var> is zero, in which case
|
|
there are no <a href="infrastructure.html#supported-property-indices">supported property indices</a>.</p>
|
|
|
|
<p>The <dfn id="dom-tokenlist-item" title="dom-tokenlist-item"><code>item(<var title="">index</var>)</code></dfn> method must <a href="common-microsyntaxes.html#split-a-string-on-spaces" title="split a
|
|
string on spaces">split the underlying string on spaces</a>,
|
|
preserving the order of the tokens as found in the underlying
|
|
string, and then return the <var title="">index</var>th item in this
|
|
list. If <var title="">index</var> is equal to or greater than the
|
|
number of tokens, then the method must return null.</p>
|
|
|
|
<p class="example">For example, if the string is "<code title="">a b
|
|
a c</code>" then there are four tokens: the token with index 0 is
|
|
"<code title="">a</code>", the token with index 1 is "<code title="">b</code>", the token with index 2 is "<code title="">a</code>", and the token with index 3 is "<code title="">c</code>".</p>
|
|
|
|
<p>The <dfn id="dom-tokenlist-contains" title="dom-tokenlist-contains"><code>contains(<var title="">token</var>)</code></dfn> method must run the following
|
|
algorithm:</p>
|
|
|
|
<ol><li>If the <var title="">token</var> argument is the empty string,
|
|
then raise a <code><a href="#syntax_err">SYNTAX_ERR</a></code> exception and stop the
|
|
algorithm.</li>
|
|
|
|
<li>If the <var title="">token</var> argument contains any <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>, then raise an
|
|
<code><a href="#invalid_character_err">INVALID_CHARACTER_ERR</a></code> exception and stop the
|
|
algorithm.</li>
|
|
|
|
<li>Otherwise, <a href="common-microsyntaxes.html#split-a-string-on-spaces" title="split a string on spaces">split the
|
|
underlying string on spaces</a> to get the list of tokens in the
|
|
<code><a href="#domtokenlist">DOMTokenList</a></code> object's underlying string.</li>
|
|
|
|
<li>If the token indicated by <var title="">token</var> is a
|
|
<a href="infrastructure.html#case-sensitive">case-sensitive</a> match for one of the tokens in the
|
|
<code><a href="#domtokenlist">DOMTokenList</a></code> object's underlying string then return
|
|
true and stop this algorithm.</li>
|
|
|
|
<li>Otherwise, return false.</li>
|
|
|
|
</ol><p>The <dfn id="dom-tokenlist-add" title="dom-tokenlist-add"><code>add(<var title="">token</var>)</code></dfn> method must run the following
|
|
algorithm:</p>
|
|
|
|
<ol><li>If the <var title="">token</var> argument is the empty string,
|
|
then raise a <code><a href="#syntax_err">SYNTAX_ERR</a></code> exception and stop the
|
|
algorithm.</li>
|
|
|
|
<li>If the <var title="">token</var> argument contains any <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>, then raise an
|
|
<code><a href="#invalid_character_err">INVALID_CHARACTER_ERR</a></code> exception and stop the
|
|
algorithm.</li>
|
|
|
|
<li>Otherwise, <a href="common-microsyntaxes.html#split-a-string-on-spaces" title="split a string on spaces">split the
|
|
underlying string on spaces</a> to get the list of tokens in the
|
|
<code><a href="#domtokenlist">DOMTokenList</a></code> object's underlying string.</li>
|
|
|
|
<li>If the given <var title="">token</var> is a
|
|
<a href="infrastructure.html#case-sensitive">case-sensitive</a> match for one of the tokens in the
|
|
<code><a href="#domtokenlist">DOMTokenList</a></code> object's underlying string then stop the
|
|
algorithm.</li>
|
|
|
|
<li>Otherwise, if the <code><a href="#domtokenlist">DOMTokenList</a></code> object's underlying
|
|
string is not the empty string and the last character of that
|
|
string is not a <a href="common-microsyntaxes.html#space-character">space character</a>, then append a U+0020
|
|
SPACE character to the end of that string.</li>
|
|
|
|
<li>Append the value of <var title="">token</var> to the end of the
|
|
<code><a href="#domtokenlist">DOMTokenList</a></code> object's underlying string.</li>
|
|
|
|
</ol><p>The <dfn id="dom-tokenlist-remove" title="dom-tokenlist-remove"><code>remove(<var title="">token</var>)</code></dfn> method must run the following
|
|
algorithm:</p>
|
|
|
|
<ol><li>If the <var title="">token</var> argument is the empty string,
|
|
then raise a <code><a href="#syntax_err">SYNTAX_ERR</a></code> exception and stop the
|
|
algorithm.</li>
|
|
|
|
<li>If the <var title="">token</var> argument contains any <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>, then raise an
|
|
<code><a href="#invalid_character_err">INVALID_CHARACTER_ERR</a></code> exception and stop the
|
|
algorithm.</li>
|
|
|
|
<li>Otherwise, <a href="common-microsyntaxes.html#remove-a-token-from-a-string" title="remove a token from a string">remove
|
|
the given <var title="">token</var> from the underlying
|
|
string</a>.</li>
|
|
|
|
</ol><p>The <dfn id="dom-tokenlist-toggle" title="dom-tokenlist-toggle"><code>toggle(<var title="">token</var>)</code></dfn> method must run the following
|
|
algorithm:</p>
|
|
|
|
<ol><li>If the <var title="">token</var> argument is the empty string,
|
|
then raise a <code><a href="#syntax_err">SYNTAX_ERR</a></code> exception and stop the
|
|
algorithm.</li>
|
|
|
|
<li>If the <var title="">token</var> argument contains any <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>, then raise an
|
|
<code><a href="#invalid_character_err">INVALID_CHARACTER_ERR</a></code> exception and stop the
|
|
algorithm.</li>
|
|
|
|
<li>Otherwise, <a href="common-microsyntaxes.html#split-a-string-on-spaces" title="split a string on spaces">split the
|
|
underlying string on spaces</a> to get the list of tokens in the
|
|
<code><a href="#domtokenlist">DOMTokenList</a></code> object's underlying string.</li>
|
|
|
|
<li>If the given <var title="">token</var> is a
|
|
<a href="infrastructure.html#case-sensitive">case-sensitive</a> match for one of the tokens in the
|
|
<code><a href="#domtokenlist">DOMTokenList</a></code> object's underlying string then <a href="common-microsyntaxes.html#remove-a-token-from-a-string" title="remove a token from a string">remove the given <var title="">token</var> from the underlying string</a> and stop the
|
|
algorithm, returning false.</li>
|
|
|
|
<li>Otherwise, if the <code><a href="#domtokenlist">DOMTokenList</a></code> object's underlying
|
|
string is not the empty string and the last character of that
|
|
string is not a <a href="common-microsyntaxes.html#space-character">space character</a>, then append a U+0020
|
|
SPACE character to the end of that string.</li>
|
|
|
|
<li>Append the value of <var title="">token</var> to the end of the
|
|
<code><a href="#domtokenlist">DOMTokenList</a></code> object's underlying string.</li>
|
|
|
|
<li>Return true.</li>
|
|
|
|
</ol><p>A <code><a href="#domtokenlist">DOMTokenList</a></code> object must <dfn id="dom-tokenlist-tostring" title="dom-tokenlist-toString">stringify</dfn> to the value of the
|
|
<code><a href="#domtokenlist">DOMTokenList</a></code> object's underlying string.</p>
|
|
|
|
</div><h4 id="domsettabletokenlist-0"><span class="secno">2.8.4 </span>DOMSettableTokenList</h4><p>The <code><a href="#domsettabletokenlist">DOMSettableTokenList</a></code> interface is the same as the
|
|
<code><a href="#domtokenlist">DOMTokenList</a></code> interface, except that it allows the
|
|
underlying string to be directly changed.</p><pre class="idl">interface <dfn id="domsettabletokenlist">DOMSettableTokenList</dfn> : <a href="#domtokenlist">DOMTokenList</a> {
|
|
attribute DOMString <a href="#dom-domsettabletokenlist-value" title="dom-DOMSettableTokenList-value">value</a>;
|
|
};</pre><dl class="domintro"><dt><var title="">tokenlist</var> . <code title="dom-DOMSettableTokenList-value"><a href="#dom-domsettabletokenlist-value">value</a></code></dt>
|
|
<dd>
|
|
<p>Returns the underlying string.</p>
|
|
<p>Can be set, to change the underlying string.</p>
|
|
</dd>
|
|
|
|
</dl><div class="impl">
|
|
|
|
<p>An object implementing the <code><a href="#domsettabletokenlist">DOMSettableTokenList</a></code>
|
|
interface must act as defined for the <code><a href="#domtokenlist">DOMTokenList</a></code>
|
|
interface, except for the <code title="dom-DOMSettableTokenList-value"><a href="#dom-domsettabletokenlist-value">value</a></code> attribute defined
|
|
here.</p>
|
|
|
|
<p>The <dfn id="dom-domsettabletokenlist-value" title="dom-DOMSettableTokenList-value"><code>value</code></dfn>
|
|
attribute must return the underlying string on getting, and must
|
|
replace the underlying string with the new value on setting.</p>
|
|
|
|
</div><div class="impl">
|
|
|
|
<h4 id="safe-passing-of-structured-data"><span class="secno">2.8.5 </span>Safe passing of structured data</h4>
|
|
|
|
<p>When a user agent is required to obtain a <dfn id="structured-clone">structured
|
|
clone</dfn> of a value, it must run the following algorithm, which
|
|
either returns a separate value, or throws an exception.</p>
|
|
|
|
<ol><li><p>Let <var title="">input</var> be the value being
|
|
cloned.</p></li>
|
|
|
|
<li><p>Let <var title="">memory</var> be an association list of
|
|
pairs of objects, initially empty. This is used to handle duplicate
|
|
references. In each pair of objects, one is called the
|
|
<em>source</em> object and the other the <em>destination</em>
|
|
object.</p></li>
|
|
|
|
<li><p>Let <var title="">output</var> be the value resulting from
|
|
calling the <a href="#internal-structured-cloning-algorithm">internal structured cloning algorithm</a> with
|
|
<var title="">input</var> and <var title="">memory</var>.</p></li>
|
|
|
|
<li><p>Return <var title="">output</var>.</p></li>
|
|
|
|
</ol><p>The <dfn id="internal-structured-cloning-algorithm">internal structured cloning algorithm</dfn> is always
|
|
called with two arguments, <var title="">input</var> and <var title="">memory</var>, and its behavior is as follows:</p>
|
|
|
|
<ol><li><p>If <var title="">input</var> is the source object of a pair
|
|
of objects in <var title="">memory</var>, then return the
|
|
destination object in that pair of objects and abort these
|
|
steps.</p></li>
|
|
|
|
<li><p>If <var title="">input</var> is a primitive value, then
|
|
return that value and abort these steps.</p></li>
|
|
|
|
<li>
|
|
|
|
<p>The <var title="">input</var> value is an object. Jump to the
|
|
appropriate step below:</p>
|
|
|
|
<dl class="switch"><dt>If <var title="">input</var> is a Boolean object</dt>
|
|
|
|
<dd><p>Let <var title="">output</var> be a newly constructed Boolean object with the same value as <var title="">input</var>.</p></dd>
|
|
|
|
<dt>If <var title="">input</var> is a Number object</dt>
|
|
|
|
<dd><p>Let <var title="">output</var> be a newly constructed Number object with the same value as <var title="">input</var>.</p></dd>
|
|
|
|
<dt>If <var title="">input</var> is a String object</dt>
|
|
|
|
<dd><p>Let <var title="">output</var> be a newly constructed String object with the same value as <var title="">input</var>.</p></dd>
|
|
|
|
<dt>If <var title="">input</var> is a <code>Date</code> object</dt>
|
|
|
|
<dd><p>Let <var title="">output</var> be a newly constructed <code>Date</code> object with the same value as <var title="">input</var>.</p></dd>
|
|
|
|
<dt>If <var title="">input</var> is a <code>RegExp</code> object</dt>
|
|
|
|
<dd>
|
|
|
|
<p>Let <var title="">output</var> be a newly constructed <code>RegExp</code> object with the same pattern and flags as <var title="">input</var>.</p>
|
|
|
|
<p class="note">The value of the <code title="">lastIndex</code> property is not copied.</p>
|
|
|
|
</dd>
|
|
|
|
<dt>If <var title="">input</var> is a <code>ImageData</code> object</dt>
|
|
|
|
<dd><p>Let <var title="">output</var> be a newly constructed <code>ImageData</code> object
|
|
with the same <code title="dom-imagedata-width">width</code> and
|
|
<code title="dom-imagedata-height">height</code> as <var title="">input</var>, and with a newly constructed
|
|
<code>CanvasPixelArray</code> for its <code title="dom-imagedata-data">data</code> attribute, with the same
|
|
<code title="dom-canvaspixelarray-length">length</code> and pixel
|
|
values as the <var title="">input</var>'s.</p></dd>
|
|
|
|
<dt>If <var title="">input</var> is a <code><a href="infrastructure.html#file">File</a></code> object</dt>
|
|
|
|
<dd><p>Let <var title="">output</var> be a newly constructed <code><a href="infrastructure.html#file">File</a></code> object corresponding to the same underlying data.</p></dd>
|
|
|
|
<dt>If <var title="">input</var> is a <code><a href="infrastructure.html#blob">Blob</a></code> object</dt>
|
|
|
|
<dd><p>Let <var title="">output</var> be a newly constructed <code><a href="infrastructure.html#blob">Blob</a></code> object corresponding to the same underlying data.</p></dd>
|
|
|
|
<dt>If <var title="">input</var> is a <code><a href="infrastructure.html#filelist">FileList</a></code> object</dt>
|
|
|
|
<dd><p>Let <var title="">output</var> be a newly constructed <code><a href="infrastructure.html#filelist">FileList</a></code> object containing a list of newly constructed <code><a href="infrastructure.html#file">File</a></code> objects corresponding to the same underlying data as those in <var title="">input</var>, maintaining their relative order.</p></dd>
|
|
|
|
<dt>If <var title="">input</var> is an Array object</dt>
|
|
|
|
<dd><p>Let <var title="">output</var> be a newly constructed empty <code>Array</code> object.</p></dd>
|
|
|
|
<dt>If <var title="">input</var> is an Object object</dt>
|
|
|
|
<dd><p>Let <var title="">output</var> be a newly constructed empty <code title="">Object</code> object.</p></dd>
|
|
|
|
<dt>If <var title="">input</var> is another native object type (e.g. <code>Error</code>, <code><a href="webappapis.html#function">Function</a></code>)</dt>
|
|
<dt>If <var title="">input</var> is a host object (e.g. a DOM node)</dt>
|
|
|
|
<dd><p>Throw a <code><a href="#data_clone_err">DATA_CLONE_ERR</a></code> exception and abort
|
|
the overall <a href="#structured-clone">structured clone</a> algorithm.</p></dd>
|
|
|
|
</dl></li>
|
|
|
|
<li><p>Add a mapping from <var title="">input</var> (the source
|
|
object) to <var title="">output</var> (the destination object) to
|
|
<var title="">memory</var>.</p></li>
|
|
|
|
<li>
|
|
|
|
<p>If <var title="">input</var> is an Array object or an Object
|
|
object, then, for each enumerable property in <var title="">input</var>, add a new property to <var title="">output</var> having the same name, and having a value
|
|
created from invoking the <a href="#internal-structured-cloning-algorithm">internal structured cloning
|
|
algorithm</a> recursively with the value of the property as the
|
|
"<var title="">input</var>" argument and <var title="">memory</var> as the "<var title="">memory</var>"
|
|
argument. The order of the properties in the <var title="">input</var> and <var title="">output</var> objects must
|
|
be the same.</p>
|
|
|
|
<p class="note">This does not walk the prototype chain.</p>
|
|
|
|
<p class="note">Property descriptors, setters, getters, and
|
|
analogous features are not copied in this process. For example,
|
|
the property in the input could be marked as read-only, but in the
|
|
output it would just have the default state (typically read-write,
|
|
though that could depend on the scripting environment).</p>
|
|
|
|
</li>
|
|
|
|
<li><p>Return <var title="">output</var>.</p></li>
|
|
|
|
</ol><p class="note">This algorithm preserves cycles and preserves the
|
|
identity of duplicate objects in graphs.</p>
|
|
|
|
</div><h4 id="domstringmap-0"><span class="secno">2.8.6 </span>DOMStringMap</h4><p>The <code><a href="#domstringmap">DOMStringMap</a></code> interface represents a set of
|
|
name-value pairs. It exposes these using the scripting language's
|
|
native mechanisms for property access.</p><div class="impl">
|
|
|
|
<p>When a <code><a href="#domstringmap">DOMStringMap</a></code> object is instantiated, it is
|
|
associated with three algorithms, one for getting the list of
|
|
name-value pairs, one for setting names to certain values, and one
|
|
for deleting names.</p>
|
|
|
|
<pre class="idl">interface <dfn id="domstringmap">DOMStringMap</dfn> {
|
|
<a href="#dom-domstringmap-nameditem" title="dom-DOMStringMap-namedItem">getter</a> DOMString (in DOMString name);
|
|
<a href="#dom-domstringmap-setitem" title="dom-DOMStringMap-setItem">setter</a> void (in DOMString name, in DOMString value);
|
|
<a href="#dom-domstringmap-additem" title="dom-DOMStringMap-addItem">creator</a> void (in DOMString name, in DOMString value);
|
|
<a href="#dom-domstringmap-removeitem" title="dom-DOMStringMap-removeItem">deleter</a> void (in DOMString name);
|
|
};</pre>
|
|
|
|
<p>The <a href="infrastructure.html#supported-property-names">supported property names</a> on a
|
|
<code><a href="#domstringmap">DOMStringMap</a></code> object at any instant are the names of
|
|
each pair returned from the algorithm for getting the list of
|
|
name-value pairs at that instant.</p>
|
|
|
|
<p>To <dfn id="dom-domstringmap-nameditem" title="dom-DOMStringMap-namedItem">determine the value of
|
|
a named property</dfn> <var title="">name</var> in a
|
|
<code><a href="#domstringmap">DOMStringMap</a></code>, the user agent must return the value
|
|
component of the name-value pair whose name component is <var title="">name</var> in the list returned by the algorithm for
|
|
getting the list of name-value pairs.</p>
|
|
|
|
<p>To set the value of a <dfn id="dom-domstringmap-additem" title="dom-DOMStringMap-addItem">new</dfn> or <dfn id="dom-domstringmap-setitem" title="dom-DOMStringMap-setItem">existing</dfn> named property <var title="">name</var> to value <var title="">value</var>, the
|
|
algorithm for setting names to certain values must be run, passing
|
|
<var title="">name</var> as the name and the result of converting
|
|
<var title="">value</var> to a <code>DOMString</code> as the
|
|
value.</p>
|
|
|
|
<p>To <dfn id="dom-domstringmap-removeitem" title="dom-DOMStringMap-removeItem">delete an existing
|
|
named property</dfn> <var title="">name</var>, the algorithm for
|
|
deleting names must be run, passing <var title="">name</var> as the
|
|
name.</p>
|
|
|
|
<p class="note">The <code><a href="#domstringmap">DOMStringMap</a></code> interface definition
|
|
here is only intended for JavaScript environments. Other language
|
|
bindings will need to define how <code><a href="#domstringmap">DOMStringMap</a></code> is to be
|
|
implemented for those languages.</p>
|
|
|
|
</div><div class="example">
|
|
|
|
<p>The <code title="dom-dataset"><a href="elements.html#dom-dataset">dataset</a></code> attribute on
|
|
elements exposes the <code title="attr-data-*"><a href="elements.html#attr-data">data-*</a></code>
|
|
attributes on the element.</p>
|
|
|
|
<p>Given the following fragment and elements with similar
|
|
constructions:</p>
|
|
|
|
<pre><img class="tower" id="tower5" data-x="12" data-y="5"
|
|
data-ai="robotarget" data-hp="46" data-ability="flames"
|
|
src="towers/rocket.png alt="Rocket Tower"></pre>
|
|
|
|
<p>...one could imagine a function <code title="">splashDamage()</code> that takes some arguments, the first
|
|
of which is the element to process:</p>
|
|
|
|
<pre>function splashDamage(node, x, y, damage) {
|
|
if (node.classList.contains('tower') && // checking the 'class' attribute
|
|
node.dataset.x == x && // reading the 'data-x' attribute
|
|
node.dataset.y == y) { // reading the 'data-y' attribute
|
|
var hp = parseInt(node.dataset.hp); // reading the 'data-hp' attribute
|
|
hp = hp - damage;
|
|
if (hp < 0) {
|
|
hp = 0;
|
|
node.dataset.ai = 'dead'; // setting the 'data-ai' attribute
|
|
delete node.dataset.ability; // removing the 'data-ability' attribute
|
|
}
|
|
node.dataset.hp = hp; // setting the 'data-hp' attribute
|
|
}
|
|
}</pre>
|
|
|
|
</div><h4 id="dom-feature-strings"><span class="secno">2.8.7 </span>DOM feature strings</h4><p>DOM3 Core defines mechanisms for checking for interface support,
|
|
and for obtaining implementations of interfaces, using <a href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMFeatures">feature
|
|
strings</a>. <a href="references.html#refsDOMCORE">[DOMCORE]</a></p><p>Authors are strongly discouraged from using these, as they are
|
|
notoriously unreliable and imprecise. Authors are encouraged to rely
|
|
on explicit feature testing or the graceful degradation behavior
|
|
intrinsic to some of the features in this specification.</p><div class="impl">
|
|
|
|
<p>For historical reasons, user agents should return the true value
|
|
when the <dfn id="hasfeature" title="hasFeature"><code>hasFeature(<var title="">feature</var>, <var title="">version</var>)</code></dfn>
|
|
method of the <code><a href="infrastructure.html#domimplementation">DOMImplementation</a></code> interface is invoked
|
|
with <var title="">feature</var> set to either "<code title="">HTML</code>" or "<code title="">XHTML</code>" and <var title="">version</var> set to either "<code>1.0</code>" or
|
|
"<code>2.0</code>".</p>
|
|
|
|
</div><h4 id="exceptions"><span class="secno">2.8.8 </span>Exceptions</h4><p>The following are <code><a href="infrastructure.html#domexception">DOMException</a></code> codes. <a href="references.html#refsDOMCORE">[DOMCORE]</a></p><ol class="brief"><li value="1"><dfn id="index_size_err"><code>INDEX_SIZE_ERR</code></dfn></li>
|
|
<li value="2"><dfn id="domstring_size_err"><code>DOMSTRING_SIZE_ERR</code></dfn></li>
|
|
<li value="3"><dfn id="hierarchy_request_err"><code>HIERARCHY_REQUEST_ERR</code></dfn></li>
|
|
<li value="4"><dfn id="wrong_document_err"><code>WRONG_DOCUMENT_ERR</code></dfn></li>
|
|
<li value="5"><dfn id="invalid_character_err"><code>INVALID_CHARACTER_ERR</code></dfn></li>
|
|
<li value="6"><dfn id="no_data_allowed_err"><code>NO_DATA_ALLOWED_ERR</code></dfn></li>
|
|
<li value="7"><dfn id="no_modification_allowed_err"><code>NO_MODIFICATION_ALLOWED_ERR</code></dfn></li>
|
|
<li value="8"><dfn id="not_found_err"><code>NOT_FOUND_ERR</code></dfn></li>
|
|
<li value="9"><dfn id="not_supported_err"><code>NOT_SUPPORTED_ERR</code></dfn></li>
|
|
<li value="10"><dfn id="inuse_attribute_err"><code>INUSE_ATTRIBUTE_ERR</code></dfn></li>
|
|
<li value="11"><dfn id="invalid_state_err"><code>INVALID_STATE_ERR</code></dfn></li>
|
|
<li value="12"><dfn id="syntax_err"><code>SYNTAX_ERR</code></dfn></li>
|
|
<li value="13"><dfn id="invalid_modification_err"><code>INVALID_MODIFICATION_ERR</code></dfn></li>
|
|
<li value="14"><dfn id="namespace_err"><code>NAMESPACE_ERR</code></dfn></li>
|
|
<li value="15"><dfn id="invalid_access_err"><code>INVALID_ACCESS_ERR</code></dfn></li>
|
|
<li value="16"><dfn id="validation_err"><code>VALIDATION_ERR</code></dfn></li>
|
|
<li value="17"><dfn id="type_mismatch_err"><code>TYPE_MISMATCH_ERR</code></dfn></li>
|
|
<li value="18"><dfn id="security_err"><code>SECURITY_ERR</code></dfn></li>
|
|
<li value="19"><dfn id="network_err"><code>NETWORK_ERR</code></dfn></li>
|
|
<li value="20"><dfn id="abort_err"><code>ABORT_ERR</code></dfn></li>
|
|
<li value="21"><dfn id="url_mismatch_err"><code>URL_MISMATCH_ERR</code></dfn></li>
|
|
<li value="22"><dfn id="quota_exceeded_err"><code>QUOTA_EXCEEDED_ERR</code></dfn></li>
|
|
<li value="23"><dfn id="timeout_err"><code>TIMEOUT_ERR</code></dfn></li>
|
|
<li value="25"><dfn id="data_clone_err"><code>DATA_CLONE_ERR</code></dfn></li>
|
|
</ol><div class="impl">
|
|
|
|
<pre class="idl">[Supplemental] exception DOMException {
|
|
const unsigned short <a href="#url_mismatch_err">URL_MISMATCH_ERR</a> = 21;
|
|
const unsigned short <a href="#quota_exceeded_err">QUOTA_EXCEEDED_ERR</a> = 22;
|
|
const unsigned short <a href="#data_clone_err">DATA_CLONE_ERR</a> = 25;
|
|
};</pre>
|
|
|
|
</div><div class="impl">
|
|
|
|
<h4 id="garbage-collection"><span class="secno">2.8.9 </span>Garbage collection</h4>
|
|
|
|
<p>There is an <dfn id="implied-strong-reference">implied strong reference</dfn> from any IDL
|
|
attribute that returns a pre-existing object to that object.</p>
|
|
|
|
<div class="example">
|
|
|
|
<p>For example, the <code>document.location</code> attribute means
|
|
that there is a strong reference from a <code><a href="infrastructure.html#document">Document</a></code>
|
|
object to its <code><a href="history.html#location">Location</a></code> object. Similarly, there is
|
|
always a strong reference from a <code><a href="infrastructure.html#document">Document</a></code> to any
|
|
descendant nodes, and from any node to its owner
|
|
<code><a href="infrastructure.html#document">Document</a></code>.</p>
|
|
|
|
</div>
|
|
|
|
</div></body></html>
|