HTML Standard Tracker

Filter

File a bug

SVNBugCommentTime (UTC)
2290WF2: select.add, select.remove, select.options.add, select.options.remove2008-10-07 04:54
@@ -4817,27 +4817,32 @@
   </ol>
 
 
 <!--
 http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E...%0A%3Cform%20name%3D%22a%22%3E%3Cinput%20id%3D%22x%22%20name%3D%22y%22%3E%3Cinput%20name%3D%22x%22%20id%3D%22y%22%3E%3C/form%3E%0A%3Cscript%3E%0A%20%20var%20x%3B%0A%20%20w%28x%20%3D%20document.forms%5B%27a%27%5D%5B%27x%27%5D%29%3B%0A%20%20w%28x.length%29%3B%0A%20%20x%5B0%5D.parentNode.removeChild%28x%5B0%5D%29%3B%0A%20%20w%28x.length%29%3B%0A%20%20w%28x%20%3D%3D%20document.forms%5B%27a%27%5D%5B%27x%27%5D%29%3B%0A%3C/script%3E%0A
 -->
 
 
   <h5>HTMLOptionsCollection</h5>
 
-  <p>The <code>HTMLOptionsCollection</code> interface represents
-  a list of <code>option</code> elements.</p>
+  <p>The <code>HTMLOptionsCollection</code> interface represents a
+  list of <code>option</code> elements. It is always rooted on a
+  <code>select</code> element and has attributes and methods that
+  manipulate that element's descendants.</p>
 
   <pre class="idl">interface <dfn>HTMLOptionsCollection</dfn> {
            attribute unsigned long <span title="dom-HTMLOptionsCollection-length">length</span>;
   [IndexGetter] <span>HTMLOptionElement</span> <span title="dom-HTMLOptionsCollection-item">item</span>(in unsigned long index);
   [NameGetter] Object <span title="dom-HTMLOptionsCollection-namedItem">namedItem</span>(in DOMString name);
+  void <span title="dom-HTMLOptionsCollection-add">add</span>(in <span>HTMLElement</span> element, in <span>HTMLElement</span> before);
+  void <span title="dom-HTMLOptionsCollection-add">add</span>(in <span>HTMLElement</span> element, in long before);
+  void <span title="dom-HTMLOptionsCollection-remove">remove</span>(in long index);
 };</pre>
 
   <p>On getting, the <dfn
   title="dom-HTMLOptionsCollection-length"><code>length</code></dfn>
   attribute must return the number of nodes <span>represented by the
   collection</span>.</p>
 
   <p>On setting, the behavior depends on whether the new value is
   equal to, greater than, or less than the number of nodes
   <span>represented by the collection</span> at that time. If the
@@ -4888,26 +4893,89 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..
    are those that have either an <code title="attr-id">id</code>
    attribute or a <code title="attr-option-name">name</code> attribute
    equal to <var title="">key</var>. The nodes in the
    <code>NodeList</code> object must be sorted in <span>tree
    order</span>.</li>
 
    <li>Return that <code>NodeList</code> object.</li>
 
   </ol>
 
+  <p>The <dfn 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>option</code>
+   or <code>optgroup</code> element, then return and abort these
+   steps.</li>
+
+   <li><p>If <var title="">element</var> is an ancestor of the
+   <code>select</code> element element on which the
+   <code>HTMLOptionsCollection</code> is rooted, then throw a
+   <code>HIERARCHY_REQUEST_ERR</code> exception.</li>
+
+   <li><p>If <var title="">before</var> is an element, but that
+   element isn't a descendant of the <code>select</code> element
+   element on which the <code>HTMLOptionsCollection</code> is rooted,
+   then throw a <code>NOT_FOUND_ERR</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.</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>select</code> element element on which the
+   <code>HTMLOptionsCollection</code> is rooted.</p></li>
+
+   <li><p>Act as if the DOM Core <code
+   title="dom-insertBefore">insertBefore()</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>
+
+  </ol>
+
+  <p>The <dfn
+  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 <span>represented by the
+   collection</span> is zero, abort these steps.</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 <span>represented by
+   the collection</span>, 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>
+
   <!-- see also http://ln.hixie.ch/?start=1161042744&count=1 -->
 
-  <p class="XXX">We may want to add <code>add()</code> and
-  <code>remove()</code> methods here too because IE implements
-  HTMLSelectElement and HTMLOptionsCollection on the same object, and
-  so people use them almost interchangeably in the wild.</p>
 
 
   <h4>DOMTokenList</h4>
 
   <p>The <code>DOMTokenList</code> interface represents an interface
   to an underlying string that consists of an <span>unordered set of
   unique space-separated tokens</span>.</p>
 
   <p>Which string underlies a particular <code>DOMTokenList</code>
   object is defined when the object is created. It might be a content
@@ -29380,28 +29448,28 @@ function AddCloud(data, x, y) { ... }</pre>
   readonly attribute <span>HTMLFormElement</span> <span title="dom-fae-form">form</span>;
            attribute boolean <span title="dom-select-multiple">multiple</span>;
            attribute DOMString <span title="dom-fe-name">name</span>;
            attribute boolean <span title="dom-select-size">size</span>;
 
   readonly attribute DOMString <span title="dom-select-type">type</span>;
 
   readonly attribute <span>HTMLOptionsCollection</span> <span title="dom-select-options">options</span>;
            attribute unsigned long <span title="dom-select-length">length</span>;
   [IndexGetter] <span>HTMLElement</span> <span title="dom-select-XXX9">XXX9</span>(in unsigned long index);
+  void <span title="dom-select-add">add</span>(in <span>HTMLElement</span> element, in <span>HTMLElement</span> before);
+  void <span title="dom-select-add">add</span>(in <span>HTMLElement</span> element, in long before);
+  void <span title="dom-select-remove">remove</span>(in long index);
 
   readonly attribute <span>HTMLOptionsCollection</span> <span title="dom-select-selectedOptions">selectedOptions</span>;
            attribute long <span title="dom-select-selectedIndex">selectedIndex</span>;
            attribute DOMString <span title="dom-select-value">value</span>;
 
-  void <span title="dom-select-add">add</span>(in <span>HTMLElement</span> element, in <span>HTMLElement</span> before);
-  void <span title="dom-select-remove">remove</span>(in long index);
-
   readonly attribute boolean <span title="dom-cva-willValidate">willValidate</span>;
   readonly attribute <span>ValidityState</span> <span title="dom-cva-validity">validity</span>;
   readonly attribute DOMString <span title="dom-cva-validationMessage">validationMessage</span>;
   boolean <span title="dom-cva-checkValidatity">checkValidity</span>();
   void <span title="dom-cva-setCustomValidity">setCustomValidity</span>(in DOMString error);
 
   readonly attribute <span>NodeList</span> <span title="dom-lfe-labels">labels</span>;
 };</pre>
    </dd> 
   </dl>
@@ -29449,44 +29517,50 @@ function AddCloud(data, x, y) { ... }</pre>
 
   <p>The <code title="attr-fae-form">form</code> attribute is used to
   explicitly associate the <code>select</code> element with its
   <span>form owner</span>. The <code title="attr-fe-name">name</code>
   attribute represents the element's name. The <code
   title="attr-fe-disabled">disabled</code> attribute is used to make
   the control non-interactive and to prevent its value from being
   submitted. The <code title="attr-fe-autofocus">autofocus</code>
   attribute controls focus.</p>
 
-  <p>The <dfn title="dom-select-type"><code>type</code></dfn>
+  <p>The <dfn title="dom-select-type"><code>type</code></dfn> DOM
   attribute, on getting, must return the string "<code
   title="">select-one</code>" if the <code
   title="attr-select-multiple">multiple</code> attribute is absent,
   and the string "<code title="">select-multiple</code>" if the <code
   title="attr-select-multiple">multiple</code> attribute is
   present.</p>
 
   <p>The <dfn title="dom-select-options"><code>options</code></dfn>
-  attribute must return an <code>HTMLOptionsCollection</code> rooted
-  at the <code>select</code> node, whose filter matches the elements
-  in the <span title="concept-select-option-list">list of
+  DOM attribute must return an <code>HTMLOptionsCollection</code>
+  rooted at the <code>select</code> node, whose filter matches the
+  elements in the <span title="concept-select-option-list">list of
   options</span>.</p>
 
-  <!-- XXX
-           attribute unsigned long <span title="dom-select-length">length</span>;
-  [IndexGetter] <span>HTMLElement</span> <span title="dom-select-XXX9">XXX9</span>(in unsigned long index);
+  <p>The <dfn title="dom-select-length"><code>length</code></dfn> DOM
+  attribute, on getting and setting, must act like the <code
+  title="dom-HTMLOptionsCollection-length">length</code> attribute on
+  the <code>HTMLOptionsCollection</code> object return by the <code
+  title="dom-select-options">options</code> attribute. Similarly, the
+  <dfn title="dom-select-add"><code>add()</code></dfn> and <dfn
+  title="dom-select-remove"><code>remove()</code></dfn> methods must
+  act like their namesake methods on that same
+  <code>HTMLOptionsCollection</code> object.</p>
+
+  <!-- XXX9 is blocked on WebIDL -->
 
+  <!-- XXX
   readonly attribute <span>HTMLOptionsCollection</span> <span title="dom-select-selectedOptions">selectedOptions</span>;
            attribute long <span title="dom-select-selectedIndex">selectedIndex</span>;
            attribute DOMString <span title="dom-select-value">value</span>;
-
-  void <span title="dom-select-add">add</span>(in <span>HTMLElement</span> element, in <span>HTMLElement</span> before);
-  void <span title="dom-select-remove">remove</span>(in long index);
   -->
 
   <p class="XXX">...</p>
 
   <p>The <dfn title="dom-select-multiple"><code>multiple</code></dfn>
   and <dfn title="dom-select-size"><code>size</code></dfn> DOM
   attributes must <span>reflect</span> the respective content
   attributes of the same name. The <code
   title="dom-select-size">size</code> DOM attribute <span>limited to
   only positive non-zero numbers</span>.</p>

|