#455 ✓fixed_in_master_branch
Jay Baker

ID selector case (in)sensitivity in IE6

Reported by Jay Baker | November 20th, 2008 @ 06:27 PM | in 2.0

IE6 incorrectly finds the elements with the ID selector (though not with class selectors) when we give the wrong case. These two selectors find element 'aBc1' when they shouldn't:

@@@javascript $$('table#abc1') $$('#abc1')



...although these don't find the td.De class things when then
shouldn't:

@@@javascript
$$('#abc1 td.de')
$$('td.de')

[side note: IE document.getElementById also ignores case (and for that matter will happily return an element with the given value as a name rather than as an ID). Since Prototype does try to smooth out browser diffs. $('abc1'), since it uses the underlying document.getElementById, also has this case-insensitivity issue on IE.]

Comments and changes to this ticket

  • T.J. Crowder
  • Tobie Langel

    Tobie Langel November 20th, 2008 @ 10:24 PM

    • State changed from “new” to “bug”
    • Milestone set to 2.0
    • Assigned user set to “Tobie Langel”
  • Juriy Zaytsev

    Juriy Zaytsev November 20th, 2008 @ 11:30 PM

    • State changed from “bug” to “new”
    • Milestone cleared.
    • Assigned user cleared.

    Shouldn't simple comparison of id's (string given to $ and actual value of element's id) solve this?

    
    diff --git a/src/dom.js b/src/dom.js
    index 87bdbac..36dbeaf 100644
    --- a/src/dom.js
    +++ b/src/dom.js
    @@ -4,8 +4,12 @@ function $(element) {
           elements.push($(arguments[i]));
         return elements;
       }
    -  if (Object.isString(element))
    +  if (Object.isString(element)) {
    +    var id = element;
         element = document.getElementById(element);
    +    // work around bugs in IE's `getElementById`
    +    if (element.id !== id) return null;
    +  }
       return Element.extend(element);
     }
    
  • Juriy Zaytsev

    Juriy Zaytsev November 20th, 2008 @ 11:30 PM

    • Assigned user set to “Tobie Langel”
    • State changed from “new” to “bug”
    • Milestone set to 2.0
  • Tobie Langel

    Tobie Langel November 20th, 2008 @ 11:37 PM

    I suppose that also depends on the Doctype being used.

  • Juriy Zaytsev

    Juriy Zaytsev November 20th, 2008 @ 11:54 PM

    I added it to CFT (under the name - DOCUMENT_GETELEMENTBYID_IGNORES_CASE) http://yura.thinkweb2.com/cft/

    IE8 seems to have this fixed (as well as name/id confusion), but IE<=7 are affected in both standard/quirks modes.

  • Jay Baker

    Jay Baker November 20th, 2008 @ 11:55 PM

    No, with or without a doctype, it works just as badly - it finds elements in a case-insensitive manner.

  • Jay Baker

    Jay Baker November 21st, 2008 @ 12:10 AM

    yes, the id value of the returned element is correct for that (returned) element, however more than one element's id's may differ only in case, so it won't find one that is actually present and spelled correctly if it is not the first encountered.

  • T.J. Crowder

    T.J. Crowder November 16th, 2009 @ 04:50 PM

    • Tag cleared.
    • Assigned user cleared.

    [responsible:none bulk edit command]

  • Diego Perini

    Diego Perini December 21st, 2009 @ 12:32 AM

    • Tag set to iebug

    Just to confirm the described IE6/IE7 bug with multiple id written in different cases (lower/upper/mixed).

    That's a GEBID bug in IE6/IE7. The fix Juriy suggests can solve this exact problem, but there are more bugs in the same method so maybe resorting to getAttribute() or getAttributeNode() can cover some of the other bugs too.

    Diego

  • Tobie Langel

    Tobie Langel February 25th, 2010 @ 09:50 PM

    • State changed from “bug” to “fixed_in_trunk”
    • Tag cleared.

    Thanks for your ticket.

    This should be fixed in the current master branch.

    You may build Prototype from source or wait until our next official release to benefit from it.

    I am closing this ticket as fixed_in_trunk. Thank you for your understanding.

  • Tobie Langel

    Tobie Langel March 1st, 2010 @ 12:15 AM

    • State changed from “fixed_in_trunk” to “fixed_in_master_branch”

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