Side navigation
#3746 closed bug (invalid)
Opened December 24, 2008 01:13AM UTC
Closed January 04, 2009 03:47PM UTC
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 (2)
Changed December 25, 2008 08:50PM UTC by comment:1
cc: | → culyun |
---|---|
component: | unfilled → selector |
owner: | flesler → john |
Changed January 04, 2009 03:47PM UTC by comment:2
resolution: | → invalid |
---|---|
status: | new → closed |
:first-child only matches elements, not text nodes - this is expected with the CSS Selector specification.