Bug Tracker

Modify

Ticket #6358 (closed bug: patchwelcome)

Opened 3 years ago

Last modified 21 months ago

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:
Blocking: Blocked by:

Description

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

comment:1 Changed 3 years ago by dmethvin

  • Component changed from unfiled to selector

comment:2 Changed 3 years ago by dmethvin

  • Priority set to high
  • Status changed from new to open
  • Milestone changed from 1.4.3 to 1.4.5

 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 2 years ago by timmywil

  • Blocked by 5637 added

comment:4 Changed 23 months ago by john

  • Owner set to timmywil
  • Status changed from open to assigned
  • Milestone changed from 1.next to 1.7

comment:5 Changed 21 months ago by timmywil

  • Blocked by 5637 removed

comment:6 Changed 21 months ago by timmywil

  • Status changed from assigned to closed
  • Resolution set to patchwelcome

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":

[selected="selected"]

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.