Bug Tracker

Opened 15 years ago

Closed 15 years ago

#2787 closed bug (fixed)

Attribute filter ignores elements not appended to DOM tree

Reported by: arrix Owned by:
Priority: major Milestone: 1.2.4
Component: core Version: 1.2.3
Keywords: selector Cc:
Blocked by: Blocking:


Attribute filter ([attribute=value]) cannot select elements not appended to the document tree.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>1.2.4a Rev: 5390</title>
		<script type="text/javascript" src="../jquery/dist/jquery.js"></script>
		<script type="text/javascript">
			$(function() {
				var f = $('<form><input type="button" name="ok" value="OK"/></form>');
				alert(f.find('input[name="ok"]').length); //0 but should be 1
				alert(f.find('input[name="ok"]').length); //1

1.2.4a Rev: 5390

Change History (3)

comment:1 Changed 15 years ago by arrix

It's in selector.js jQuery.filter (near line 338)

// special case, filter by exact name
if ( !not && m[2] == 'name' && type == '=' )
	r = jQuery.grep( document.getElementsByName(m[5]), function(elem){
		return jQuery.inArray( elem, r ) != -1;	

of course document.getElementsByName only returns elements in the document tree.

comment:3 Changed 15 years ago by flesler

Resolution: fixed
Status: newclosed

Fixed, check #1960 for more details.

Note: See TracTickets for help on using tickets.