Bug Tracker

Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#408 closed bug (wontfix)

name attribute removed in Internet Explorer

Reported by: sam Owned by:
Priority: major Milestone: 1.1a
Component: core Version: 1.1a
Keywords: Cc:
Blocked by: Blocking:

Description

When I create an input element with a name, the name gets removed when I add it to another element (e.g. a form). the name gets added fine (as indicated by the first alert), but no longer exists after adding (second alert lacks name attribute).

$(
      function()
      {
              var action = $("<input type=hidden>").attr(
              {
                         "name": "whattodo",
                         "value": "delete"
              });
              alert(action[0].name); // name seems to be added fine
              alert($("<form>").append(action).html()); // where has name gone?
      }

)

Change History (5)

comment:1 Changed 14 years ago by john

Milestone: 1.1
Version: 1.01.1

This sounds like an issue with Internet Explorer and .getAttribute().

comment:2 Changed 14 years ago by brandon

This happens without the use of jQuery as well as pointed out by Dave Methvin on the list.

comment:3 Changed 14 years ago by Dave

This turns out to be one of those persistent IE bugs, well documented here with some unappetizing workarounds:

http://www.easy-reader.net/archives/2005/09/02/death-to-bad-dom-implementations/

The problem I see for applying any of these in jQuery is that there isn't a convenient way to detect the situation and apply the workaround.

comment:4 Changed 14 years ago by joern

The easiert way to workaround this is to provide the name in the first string, that is:

$(
      function()
      {
              var action = $("<input name='whattodo' type='hidden'>").attr(
              {
                         "value": "delete"
              });
              alert(action[0].name); // name seems to be added fine
              alert($("<form>").append(action).html());
      }

)

Any other ideas? This workaround can hardly be integrated into jQuery, therefore I'd just place a note somewhere in the documentation. But where? $(String)? attr(String, String)?

comment:5 Changed 14 years ago by joern

Resolution: wontfix
Status: newclosed

Added a note in the documentation of attr(String, Object) for this issue.

Note: See TracTickets for help on using tickets.