#364 ✓resolved
Webbles

#readAttribute('class') returns wrong results in IE8

Reported by Webbles | September 30th, 2008 @ 05:13 PM | in 1.6.1

It appears that IE8 doesn't need the renaming of class to className when calling readAttribute. If you create a standards compliant page (to force it to use IE8 code paths) and then call $('something').readAttribute('class'), you'll get null. But if you do $('something').getAttribute('class'), you'll get the actual class name. There might be other renamings that are done for IE that are break IE8 but I only discovered the 'class' as it broke my site.

Comments and changes to this ticket

  • Xanadu

    Xanadu October 1st, 2008 @ 02:59 AM

    • Tag set to ie8

    There are probably quicker and more sophicated ways to do this, but here's something I came up with:

    
      Element._attributeTranslations = {
        read: {
          names: {
            'class': navigator.userAgent.indexOf('MSIE 8') > -1 ? 'class' : 'className',
            'for':   'htmlFor'
          },
    

    navigator.userAgent.indexOf('MSIE 8') obviously checks the browser version, but I think feature detection (something like if (Element.className)) would be better. Of course pre-checking it would improve performance...

    (I have not tested the example code, since I have no IE8 on my computer!)

  • Juriy Zaytsev

    Juriy Zaytsev October 1st, 2008 @ 06:56 PM

    • Assigned user set to “Juriy Zaytsev”
    • Title changed from “IE8 doesn't like readAttribute('class')” to “#readAttribute('class') returns wrong results in IE8”
    • State changed from “new” to “bug”
    • Milestone set to 1.7
    • Tag cleared.
  • Juriy Zaytsev

    Juriy Zaytsev October 1st, 2008 @ 07:00 PM

    Could someone test if IE8 behaves the same way with for/htmlFor?

    Thanks.

  • Xanadu

    Xanadu October 1st, 2008 @ 07:56 PM

    Did a little google search on the subject, I found this page on the dojo trac stating that IE8 uses htmlFor.

  • Xanadu

    Xanadu October 2nd, 2008 @ 03:13 PM

    A better resource at MSDN.aspx)

    When setting the CLASS attribute using this method, set the sName to be "className", which is the corresponding Dynamic HTML (DHTML) property.

  • Xanadu

    Xanadu October 2nd, 2008 @ 03:16 PM

    The right URL: http://msdn.microsoft.com/en-us/...

    (The bracket in the URL breaks the URL formatting - not really bug in Lighthouse, I guess)

  • Andrew Dupont

    Andrew Dupont October 3rd, 2008 @ 06:45 PM

    • Milestone changed from 1.7 to 1.6.1
    • Tag set to attributes, dom, needs_patch
  • Juriy Zaytsev

    Juriy Zaytsev October 7th, 2008 @ 06:28 AM

    I feel hesitant to mark it as 1.6.0.4. It's not clear what IE is up to and how later revisions will behave.

    Can we move it to 1.6.1?

  • Xanadu

    Xanadu October 7th, 2008 @ 01:55 PM

    IE8 is still beta, right? As long as it is still in development, there's hurry to fix this bug, like Juriy said.

  • Tobie Langel

    Tobie Langel October 7th, 2008 @ 06:39 PM

    Proper testing should allow us to just avoid sniffing.

  • Andrew Dupont

    Andrew Dupont February 28th, 2009 @ 09:33 PM

    • State changed from “bug” to “resolved”

    This was fixed a while back when I made all the changes necessary to get the DOM tests passing in IE8.

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:10 AM

    • Tag changed from attributes, dom, needs_patch to needs_patch, section:dom

    [not-tagged:"dom" tagged:"section:dom" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:28 AM

    • Tag changed from needs_patch, section:dom to missing:patch, section:dom

    [not-tagged:"needs_patch" tagged:"missing:patch" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:37 AM

    • Tag changed from missing:patch, section:dom to needs:patch, section:dom

    [not-tagged:"missing:patch" tagged:"needs:patch" bulk edit command]

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

Pages