Re: DOM2-HTML: HTMLSelectElement.add

Thomas Much wrote:
> HTMLSelectElement.add raises a DOMException(NOT_FOUND_ERR) if the "before"
> argument is not a descendant of the SELECT element. OK.
>
> But what happens if I try to add an element (passed in the "element"
> argument), that is not an OPTION element? Currently, add is directly
> delegated to Node.appendChild or Node.insertBefore - that is, I can add
> HEAD, IMG, FORM elements to the options array... That makes no sense.
>
> If the standard specifies a special operation for adding OPTIONs, it should
> deal with errors specially and raise an exception if an element other than
> OPTION is passed.
> If you want to create invalid documents you still can use the Node interface
> on the SELECT element, but the standard should not make this too ease
> IMHO...


Looking at existing implementations, Netscape does accept the element
on add. They don't do validation on this call. The element is not
returned in the list of options but does appear as a child of the
element table. IE on the other hand, does have a minimal validation in
this case and ignore the new element (ie it is a no-op in that case).
So, facing differences in implementations, we added:
[[
This method may have no effect if the new element is not an OPTION or an
OPTGROUP.
]]

Philippe,
for the DOM WG.

Received on Friday, 22 March 2002 16:18:49 UTC