Ticket #3746 (closed bug: invalid)
Unexpected return from .contains when using ':first-child' selector
| Reported by: | culyun | Owned by: | john |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.3 |
| Component: | selector | Version: | 1.2.6 |
| Keywords: | ':first-child', ':first', 'contains', 'children' | Cc: | culyun |
| Blocking: | Blocked by: |
Description
Environment
IE 6.0.2900.2180.xpsp_sp2_gdr.080814-1233 FF 2.0.0.32 Opera 9.62
Example
jQuery(document).ready(function() {
var html = ; html += '<form class="the-form">'; html += 'silly text'; html += '<img class="silly-img" src="potato.jpg"/>'; html += '</form>';
create an unattached dom wrapped inside a jquery
var dom = $(document.createElement('div')).html(html); var form = dom.find('.the-form');
As I read the documentation the output from the use of ':first' and 'first-child' selectors, should be identical in the case of a trivial (single-element) selection set
var firstElem = form.children(':first'); ok, returns silly-img var firstNode = form.contents(':first'); ok, returns 'silly text'
firstElem = form.children(':first-child'); ok, returns silly-img firstNode = form.contents(':first-child'); fail, returns silly-img. should return 'silly text'
}
Attachments
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

