Ticket #6665 (closed defect: fixed)
Using htmlFor vs. for as an attribute getter/setter
| Reported by: | jgarfield | Owned by: | becky |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.2 |
| Component: | Dijit | Version: | 1.1.0 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
I noticed when working with the latest Editor code in Internet Explorer, the labels for 'Font Size' and 'Font Name' (when using the FontChoice?.js Plugin) don't have their tags closed, nor do they have ids associated with them.
Further investigating this, the line that was the culprit in this Plugin was the following in the setToolbar function:
label.setAttribute("for", forRef.id);
I found that in Internet Explorer (you may want to test more browsers than those that I covered), you must use 'htmlFor' instead of 'for' for the setAttribute/getAttribute call. Same goes for class vs. className.
Currently dojo.attr() only looks at tabIndex vs. tabindex for Internet Explorer. I think we should also add another case to _fixAttrName for 'for' -> 'htmlFor' and 'class' -> 'className'. The Plugin in question should also probably use dojo.attr() as well to make use of its corrections.
This also affects dojo.query!
dojo.query([for="blah"]);
versus
dojo.query([htmlFor="blah"]);
I tested the following browsers to see which ones would/wouldn't accept for and/or htmlFor, and these are the results...
IE8 - Uses htmlFor
IE7 - Uses htmlFor
IE6 - Uses htmlFor
FF3 (PC) - Uses for
FF2 (PC) - Uses for
FF1.5 (PC) - Uses for
Opera9 (PC) - Uses for
Mozilla 1.8 (PC) - Uses for
Safari 3.0 (PC) - Uses for
Safari 3.1 (PC) - Uses for
Netscape 7.2 (PC) - Uses for
Netscape 8.1 (PC) - Uses for