setAttribute('multiple', 'multiple') on an select element does not give an select element with attribute&value pair multiple="multiple"

RESOLVED FIXED

Status

()

Core
DOM: Core & HTML
RESOLVED FIXED
15 years ago
10 years ago

People

(Reporter: Brian Donovan, Unassigned)

Tracking

Trunk
x86
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

15 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4a) Gecko/20030401
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4a) Gecko/20030401

 I'm working on a JavaScript class that uses the DOM to create forms on the fly
and discovered that I could not set the multiple attribute of SELECT elements to
"multiple" (considered XHTML best practice) or, in fact, to any other value.

The simplest way of reproducing this phenom is to create a select element, set
the multiple attribute, then check it :

var nodeSelect = document.createElement('select');
nodeSelect.setAttribute('multiple', 'multiple');
alert('value of multiple attribute : ' + nodeSelect.getAttribute('multiple'));

nodeSelect.getAttribute('multiple') returns only an empty string...

Also see the selected=selected bug (#203751 :
http://bugzilla.mozilla.org/show_bug.cgi?id=203751) - similar problem. Moz is
setting the attribute values to empty strings.

Reproducible: Always

Steps to Reproduce:
Looks like <select> implements StringToAttribute but not AttributeToString. 
Hence the problem -- StringToAttribute just sets the HTMLValue to the empty
string for boolean HTML attrs.

We may want some semi-general solution for this (eg <img> elements have the same
problem with "ismap", and I suspect it's just a problem all over).

Sicking?  Care to roll this into your rewrite?
Status: UNCONFIRMED → NEW
Ever confirmed: true

Comment 2

15 years ago
See my comment in bug 203751, same analysis as bz, it's a general problem, so we
need a general solution :-)
Hmm.. IMHO the correct solution for this is to not let StringToAttribute have
any special handling for "boolean" attributes. Then we should only check that
the attribute exists rather then check its value (which might be what we already
do).

Enforcing that the value of "multiple" is "multiple" IMHO falls under
validation, but i coule be convinced of otherwise.
sicking, sounds good to me.
Fixed by the checkin for bug 232706 
Status: NEW → RESOLVED
Last Resolved: 14 years ago
Depends on: 232706
Resolution: --- → FIXED

Updated

10 years ago
Component: DOM: Core → DOM: Core & HTML
QA Contact: desale → general
You need to log in before you can comment on or make changes to this bug.