Skip to main content

Bug Tracker

Side navigation

#4561 closed enhancement (fixed)

Opened April 20, 2009 04:35PM UTC

Closed November 11, 2009 08:12PM UTC

Last modified March 13, 2012 03:57PM UTC

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:
Description

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 April 20, 2009 04:35PM UTC.

    test file

Change History (5)

Changed April 21, 2009 02:06AM UTC by dmethvin comment:1

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.

Changed April 21, 2009 10:07AM UTC by borg42 comment:2

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...

Changed June 04, 2009 04:32PM UTC by aheckmann comment:3

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.

Changed June 04, 2009 04:33PM UTC by aheckmann comment:4

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

Changed November 11, 2009 08:12PM UTC by john comment:5

component: unfilledsupport
milestone: → 1.4
resolution: → fixed
status: newclosed

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

http://github.com/jquery/jquery/commit/5ac2e0837cd5c86acc526c5bc5c3abbe91303116