Bug Tracker

Opened 13 years ago

Closed 13 years ago

#804 closed bug (fixed)

$(string exp, element|jQuery context) won't handle jQuery as context

Reported by: rb@… Owned by:
Priority: major Milestone: 1.1
Component: ajax Version: 1.1
Keywords: context Cc:
Blocked by: Blocking:

Description

$(a, c) gets passed on to find(a, c) if a is a non-html string; find(a, c) then checks that is an element, setting it to document if its not. This means that passing in a jQuery object as context does no good at all.

Change History (4)

comment:1 Changed 13 years ago by joern

See also #805.

var wnd = $("#some-id");
var form = $("form", wnd);

would result returning of all forms in document. The result is due to changing of jQuery.find() function, it does not support jQuery object as the second parameter, only DOM Element. 

comment:2 Changed 13 years ago by joern

This is the result of a late optimization.

1.0.4:

// Handle HTML strings
	if ( typeof a  == "string" ) {
		// HANDLE: $(html) -> $(array)
		var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
		if ( m )
			a = jQuery.clean( [ m[1] ] );
		
		// HANDLE: $(expr)
		else
			return new jQuery( c ).find( a );
	}

1.1:

// Handle HTML strings
	if ( typeof a  == "string" ) {
		var m = /^[^<]*(<.+>)[^>]*$/.exec(a);

		a = m ?
			// HANDLE: $(html) -> $(array)
			jQuery.clean( [ m[1] ] ) :
		
			// HANDLE: $(expr)
			jQuery.find( a, c );
	}

comment:3 Changed 13 years ago by rich.manalan

Hi... anyone know if this is going to be fixed? or will this be how context selectors work as of 1.1?

Rich

comment:4 Changed 13 years ago by joern

Resolution: fixed
Status: newclosed

Fixed in revision 1100, reverting the change. For further optimizations, the added test should ensure compability.

Note: See TracTickets for help on using tickets.