Bug Tracker

Opened 13 years ago

Closed 11 years ago

#6358 closed bug (patchwelcome)

Has attribute "selected" shows different behavior with context vs. without.

Reported by: l_andrew_l Owned by: timmywil
Priority: high Milestone: 1.7
Component: selector Version: 1.4.2
Keywords: select Cc:
Blocked by: Blocking:


I've tracked this bug down to the following problem: Place a <select> element into an HTML page with an <option> element. Do not add the "selected" attribute.

var sel = $('select');

$('select option[selected]'); $('option[selected]', sel);

Both of these return different results. Using context contains the option element even though there is no selected attribute. Using Firefox 3.5.3 on Ubuntu with Firebug 1.5.3.

Change History (6)

comment:1 Changed 13 years ago by dmethvin

Component: unfiledselector

comment:2 Changed 12 years ago by dmethvin

Priority: high
Status: newopen

http://jsfiddle.net/dmethvin/UtAus/ I get consistent and correct results with Firefox 3.5, Opera 10, Chrome 7, and Safari 5. However, IE8 does not correctly return a selected option for #tock. This behavior seems to have changed between 1.4.2 and 1.4.3 only for IE.

comment:3 Changed 12 years ago by timmywil

Blocked by: 5637 added

comment:4 Changed 12 years ago by john

Milestone: 1.next1.7
Owner: set to timmywil
Status: openassigned

comment:5 Changed 11 years ago by timmywil

Blocked by: 5637 removed

comment:6 Changed 11 years ago by timmywil

Resolution: patchwelcome
Status: assignedclosed

This is an issue with IE8's qsa. I don't know why it messes up, but it is not really an issue with Sizzle. I don't think we can fix it without defacing qsa Sizzle. It would mean an additional support test and a solo attribute check just for [selected] in IE8. I don't think we want the performance hit so I suggest this should stay the way it is. This works in all browsers if selected is set to "selected":


Closing patchwelcome, but I'm of the opinion the extra code is not worth it.

Note: See TracTickets for help on using tickets.