Opened 14 years ago
Closed 14 years ago
#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 |
Blocked by: | Blocking: |
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 (1)
Change History (3)
Changed 14 years ago by
Attachment: | jQuery_1_2_6_contains_returns_incorrect_result.js added |
---|
comment:1 Changed 14 years ago by
Cc: | culyun added |
---|---|
Component: | unfilled → selector |
Owner: | changed from flesler to john |
comment:2 Changed 14 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
:first-child only matches elements, not text nodes - this is expected with the CSS Selector specification.