Bug Tracker

Ticket #1641 (closed bug: wontfix)

Opened 7 years ago

Last modified 2 years ago

append() in IE does not properly handle Options

Reported by: scubstev834 Owned by:
Priority: minor Milestone: 1.2.3
Component: core Version: 1.2
Keywords: append IE Option select Cc:
Blocking: Blocked by:

Description

In IE (Internet Explorer), if you append an anonymous Option the text is not rendered and even though the option is now selectable in the select box (multi-select or singular), there is no value associated. The only way around this is to append the Option as text instead of creating the DOM element.

What I did: $("#myselectbox").append( new Option( "stuff","stuff") );

What works: $("#myselectbox").append( "<option value='stuff'>stuff</option>" );

This is not a problem in Mozilla Firefox.

Change History

comment:1 Changed 7 years ago by davidserduke

  • Status changed from new to closed
  • Resolution set to wontfix
  • Milestone changed from 1.2.1 to 1.2.2

As noted by the author this is a problem with IE (works in Safari, FF, and Opera). Attempt the following code in IE:

document.getElementByTagName("select")[0].appendChild(new Option("stuff", "stuff"));

and it fails as well. IE seems to only want to use Options created with new for the Select.add() type functions.

At this point it doesn't make sense to me to add a bunch of code for this specific purpose when the author has already noted a perfectly valid workaround. So I'm going to close this bug as wontfix (although I try to avoid doing that). If someone thinks this is a bigger issue than I do, please feel free to reopen the bug with your explaination of why you think this should be fixed and it will be considered.

comment:2 Changed 7 years ago by shieldo

  • Status changed from closed to reopened
  • Resolution wontfix deleted

I don't think this should be a wontfix. A recent attempted upgrade to 1.2.2 broke previously working code for me for this reason (it worked in 1.2.1). The  documentation for append refers to append(content), and 'content' should include jQuery objects (such as a set of options). A main advantage of a JS library is that is should account for browser quirks so the developer can use them without worrying too much that the abstraction will leak. append(content) should imho do exactly what it says on the tin, in all cases. The workaround is too clumsy for dealing succinctly with multiple options.

comment:3 Changed 7 years ago by davidserduke

It was working in 1.2.1 and stopped in 1.2.2? Then I suspect it has nothing to do with this bug since this bug was never fixed. Might it be related to the clone() bug in #2184?

append() should correctly handle a set of jQuery objects that are options I agree. If it doesn't it is a different bug. Please feel free to open a new ticket for that specifically although I suspect it will be fixed when #2184 is.

comment:4 Changed 7 years ago by shieldo

Thanks so much for that hint, it seems it was indeed related to the bug in #2184. I applied the patch in [4513] and all is well. So the status of this bug should be reverted.

comment:5 Changed 7 years ago by davidserduke

  • Status changed from reopened to closed
  • Resolution set to wontfix
  • Milestone changed from 1.2.2 to 1.2.3

Thanks for getting back. :)

Putting status back to won't fix for the reasons described in the first comment.

comment:8 Changed 4 years ago by jmalin

  • Status changed from closed to reopened
  • Resolution wontfix deleted

I just spent time debugging why my Options didn't work in IE, then altering the code after I traced it back to this issue. This is absolutely a problem with how IE handles options, but it also should be fixed on the JQuery side. I love JQuery for the fact that it usually hides these kinds of details and lets me worry as a developer about functionality, not browser-compatibility issues. There is a workaround, but there shouldn't have to be one - JQuery should handle this behind the scenes, by checking to see if the browser is IE and appending options in HTML fashion in the way the workaround does.

comment:9 Changed 4 years ago by dmethvin

  • Status changed from reopened to closed
  • Resolution set to wontfix

If you review the history of this ticket you'll see that it's not something easily fixed by jQuery. I'll close the ticket again; if you can provide a patch please reopen and attach it.

Note: See TracTickets for help on using tickets.