Skip to main content

Bug Tracker

Side navigation

#10573 closed bug (invalid)

Opened October 25, 2011 03:11PM UTC

Closed October 27, 2011 10:09PM UTC

exception in jQuery(selector [, conext])

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7b2
Keywords: Cc:
Blocked by: Blocking:

This isn't exactly a bug but could maybe be handled better

If there is a <table> tag inside a <tr> tag, without an intervening <td> tag then jquery raises an exception when trying to do a selection on it. Other types of tags under a <tr> tag do not cause this problem.

jQuery selecting is also a bit unintuitive when there is not a root element to the passed in document, perhaps an informative error message would be useful here?

var invalidhtml = '<tr><form action="" method="post"><table><tr><td></td></tr></table></form></tr>';        

var validhtml = '<tr><form action="" method="post"></form></tr>';        

var validhtml2 = '<table><tr><td><form action="" method="post"><table><tr><td></td></tr></table></form></td></tr></table>';        

var validhtml3 = '<tr><td><form action="" method="post"><table><tr><td></td></tr></table></form></td></tr>';        

var form = $("form", validhtml);
form = $("form", validhtml2);
form = $("form", validhtml3);
form = $("form", invalidhtml); // crash here in ie, or a silent fail in decent browsers

I couldn't get jsfiddle to run it but here is the link anyway, the code is right I think.

Attachments (0)
Change History (1)

Changed October 27, 2011 10:09PM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed

Invalid HTML pretty much closes the ticket. Trying to anticipate and give reasonable error messages for every possible problem is just too difficult and takes a lot more code than we can afford to write.

Also, I should point out that there is no jQuery signature of the form jQuery(selector, htmlstring) .