Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#14023 closed bug (invalid)

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: if(l)

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

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

Change History (8)

comment:1 Changed 10 years ago by dmethvin

Owner: set to 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 jsfiddle.net or jsbin.com for the example.

comment:2 Changed 10 years ago by trac-o-bot

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!

comment:3 Changed 10 years ago by Jonathan Allard <[email protected]…>

Here's a case I believe reproduces the bug:


comment:4 Changed 10 years ago by dmethvin

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

comment:5 Changed 10 years ago by Jonathan Allard <[email protected]…>

Well then, but there is one that accepts an array of DOM elements: http://jsfiddle.net/joallard/5rJfw/1/

comment:6 Changed 10 years ago by dmethvin

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

comment:7 Changed 10 years ago by Jonathan Allard <[email protected]…>

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 $()

comment:8 Changed 10 years ago by Jonathan Allard <[email protected]…>

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

Note: See TracTickets for help on using tickets.