This project is archived and is in readonly mode.

#110 ✓invalid
schnixe

$( "id" ) finds elements without id in IE 7

Reported by schnixe | August 16th, 2009 @ 12:13 AM


<html>
  <head></head>
  <body>
  <form id="mootest" action="">
    <fieldset>
      <input type="radio" name="test1" value="1" />
      <input type="radio" name="test1" value="2" />
      <input type="radio" name="test1" value="3" />
    </fieldset>
  </form>
  <script src="mootools-1.2.3-core.js" type="text/javascript"></script>
  <script type="text/javascript">
     alert( $( "test1" ) )
  </script>
</body>
</html>

now guess what happens: firefox alerts null, but ie alerts [object] ???

ie simply finds the first element with that name, because of that bug i need to
change some lines to


if ( $("id") && $("id").id  ) ...

-> obviously ugly

Comments and changes to this ticket

  • schnixe

    schnixe August 17th, 2009 @ 10:46 AM

    ok folx, seems to be a std behaviour of our dear IE.

    see: http://msdn.microsoft.com/en-us/library/ms536437%28VS.85%29.aspx

    it says:

    Return Value

    Returns the first object with the specified ID or NAME.
    

    --> now this is not a mootools bug, i tested it with getElementById and indeed, IE returns the first object with that name.

    but nevertheless it would be fine, if mootools would fix that IE stupidity...
    i will have a look how other frameworks handle that...

    schnix

  • schnixe

    schnixe August 17th, 2009 @ 10:48 AM

    lol, see the note below that ie reference:

    New for Windows Internet Explorer 8 Internet Explorer 8 and later. In IE8 mode, getElementById performs a case-sensitive match on the ID attribute only. In IE7 mode and previous modes, this method performs a case-insensitive match on both the ID and NAME attributes, which might produce unexpected results. For more information, see Defining Document Compatibility.

  • schnixe

    schnixe August 17th, 2009 @ 11:00 AM

    lol update again:

    my ie8 did not fix that behaviour... still getting unexpected results...

    prototype and jquery return [object] as well.

    now i think it's up to you mootools developer to implement it or not,
    i would appreciate that...

    thx
    schnix

  • Scott Kyle

    Scott Kyle August 17th, 2009 @ 04:17 PM

    • Assigned user set to “Scott Kyle”
    • State changed from “new” to “invalid”

    Thanks for reporting this. It most likely will be fixed in 2.0. I'm going to close this as invalid because you accidentally filed it under -more and reopen it under -core.

Create your profile

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

The MooTools Extensions

People watching this ticket

Pages