Skip to main content

Bug Tracker

Side navigation

#408 closed bug (wontfix)

Opened November 17, 2006 05:40PM UTC

Closed December 11, 2006 09:16AM UTC

Last modified June 19, 2007 07:00AM UTC

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?
      }

)
Attachments (0)
Change History (5)

Changed November 17, 2006 09:39PM UTC by john comment:1

milestone: → 1.1
version: 1.01.1

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

Changed November 25, 2006 08:28PM UTC by brandon comment:2

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

Changed November 28, 2006 03:44AM UTC by Dave comment:3

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.

Changed December 02, 2006 01:40PM UTC by joern comment:4

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)?

Changed December 11, 2006 09:16AM UTC by joern comment:5

resolution: → wontfix
status: newclosed

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