Bug Tracker

Opened 14 years ago

Closed 13 years ago

Last modified 11 years ago

#4561 closed enhancement (fixed)

IE seems to be case sensitive, please either document or enhance jQuery.attr()

Reported by: borg42 Owned by:
Priority: major Milestone: 1.4
Component: support Version: 1.3.2
Keywords: attr area map ie ie7 browser_dependent Cc:
Blocked by: Blocking:


Consider the following piece of code:

$('body').attr('bgColor', 'red');

$('body').attr('bgcolor', 'yellow');

$('#myImage').attr('usemap', '#myMap');

The result:

  • IE7: red background, two attributes present on the BODY tag, imagemap broken
  • FF3: yellow background, one attribute is present on the BODY tag, imagemap works

IE's being case sensitive here seems wrong for me. Anyway, as jQuery is a cross-browser library, it'd be great if it rendered the same result in these major browsers, or at least documented this caveat at attr().

Setting major prio instead of minor since this is an evil one (and no "normal" prio exists):

  • It might affect a handful of attributes: className, httpEquiv, aLink, bgColor (confirmed), vLink, acceptCharset, tabIndex, accessKey, readOnly (seems not affected), useMap (confirmed), htmlFor, dateTime, isMap, codeBase, codeType, noHref, cellPadding, cellSpacing, chOff, vAlign, colSpan, noWrap, rowSpan, frameBorder, longDesc, marginHeight, marginWidth, noResize - and possibly others.
  • attr() is a pretty widely used method, developers should know about its caveats. Even if one knows about the case sensitivity problem of setAttribute in IE, he/she can't know how exactly has jQuery implemented attr().
  • When starting off with jQuery, attr() seems and behaves cross-browser, but apparently it's not, it's not exactly a nice surprise to learn that.
  • It affects attribute useMap, and that might lead to false error repors regarding jQuery imagemap support.

See also http://www.quirksmode.org/bugreports/archives/2005/07/Setting_accesskey_attribute_using_setAttribute_is_.html .

Possible hint for a fix: http://msdn.microsoft.com/en-us/library/ms536429(VS.85,loband).aspx , parameter iFlags.

Using Windows XP SP2, IE 7.0.5730.13, FF 3.0.8, jQuery 1.3.2 min, XHTML doctype. Haven't tested in other IE versions and doctypes.

(For Googlers: if your dynamically generated image map doesn't work in ie7/ie, look for

attr('usemap', '#something')

and replace with

attr('useMap', '#something')

notice the case of the letter M. gotta love ie..)

Attachments (1)

case.html (1.2 KB) - added by borg42 14 years ago.
test file

Download all attachments as: .zip

Change History (6)

Changed 14 years ago by borg42

Attachment: case.html added

test file

comment:1 Changed 14 years ago by dmethvin

need: PatchReview

Instead of bgColor, why not use css? I suspect that's why this hasn't been reported in the past. A few of those like htmlFor are already handled internally, but I don't know about the others so it seems like it's worth a review.

comment:2 Changed 14 years ago by borg42

I only used bgColor there to make the test case easy to understand.

My real problem was when I wanted to generate an image map, and attr('usemap', '#mymap') failed in IE...

comment:3 Changed 14 years ago by aheckmann

I can confirm that frameBorder is case sensitive in Internet Explorer. I feel this is a bug and should be fixed. Passing "frameborder" into attr fails in IE.

comment:4 Changed 14 years ago by aheckmann

This was already fixed in Prototype: http://dev.rubyonrails.org/ticket/11068

comment:5 Changed 13 years ago by john

Component: unfilledsupport
Milestone: 1.4
Resolution: fixed
Status: newclosed

Fixed both useMap and frameBorder as they both have valid (and modern) use cases.


Note: See TracTickets for help on using tickets.