Skip to main content

Bug Tracker

Side navigation

#804 closed bug (fixed)

Opened January 15, 2007 12:53PM UTC

Closed January 17, 2007 10:44AM UTC

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

Reported by: rb@wizzud.com 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.

Attachments (0)
Change History (4)

Changed January 15, 2007 03:02PM UTC by joern comment:1

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. 

Changed January 15, 2007 03:04PM UTC by joern comment:2

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 );
	}

Changed January 16, 2007 06:17PM UTC by rich.manalan comment:3

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

Rich

Changed January 17, 2007 10:44AM UTC by joern comment:4

resolution: → fixed
status: newclosed

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