Skip to main content

Bug Tracker

Side navigation

#14023 closed bug (invalid)

Opened June 14, 2013 12:57PM UTC

Closed June 29, 2013 08:50AM UTC

Last modified July 02, 2013 11:04PM UTC

DomManip can pass null to buildFragment if element array contains Document object at index 0

Reported by: anonymous Owned by: anonymous
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.1
Keywords: Cc:
Blocked by: Blocking:

in DomManip if ''this'' is an array it builds a fragment based on first element in array (index 0). The problem is if this[0] is a Document object calling owenerDocument is undefined which generates exception in buildFragment. I ran into this when upgrading struts2jquery in my existing application.

Line: 6258

if ( l ) {

fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this );


I believe a safe patch would be:


var doc = (this[ 0 ].ownerDocument) ? this[ 0 ].ownerDocument : this[0];

ragment = jQuery.buildFragment( args, doc, false, !allowIntersection && this );


Attachments (0)
Change History (8)

Changed June 14, 2013 05:19PM UTC by dmethvin comment:1

owner: → anonymous
status: newpending

Can you provide a test case showing how calling a public jQuery interface would cause this? That will help us understand the best way to address it. Please use or for the example.

Changed June 29, 2013 08:50AM UTC by trac-o-bot comment:2

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Changed July 02, 2013 04:05AM UTC by Jonathan Allard <> comment:3

Here's a case I believe reproduces the bug:

Changed July 02, 2013 12:45PM UTC by dmethvin comment:4

There is no documented signature of $() that accepts an array of jQuery objects.

Changed July 02, 2013 07:00PM UTC by Jonathan Allard <> comment:5

Well then, but there is one that accepts an array of DOM elements:

Changed July 02, 2013 07:49PM UTC by dmethvin comment:6

True, but not an array of array of DOM elements.

Changed July 02, 2013 11:02PM UTC by Jonathan Allard <> comment:7

I fail to see how the case is an array of arrays, may you elaborate? .get() returning an Element, making an array with that (array of Elements), passing it to $()

Changed July 02, 2013 11:04PM UTC by Jonathan Allard <> comment:8

Ah, never mind, I've found my mistake. Thank you.