[jQuery] find() on DocumentFragment not returning consistent results

[jQuery] find() on DocumentFragment not returning consistent results


Hello all,
I'm looking at a simple case of a DocumentFragment node which has a
span as a child. If I do $(fragment).children().filter("span") then
that finds the span as expected. But $(fragment).find("span") returns
nothing. Shouldn't the second query return something if the first
does?
Sample code:
var fragment = document.createDocumentFragment();
fragment.appendChild(document.createElement("span"));
var filterChildrenSet = $(fragment).children().filter("span");
alert('Results found using $(fragment).children().filter("span") =
' + filterChildrenSet.length); // 1
var findSet = $(fragment).find("span");
alert('Results found using $(fragment).find("span") = ' +
findSet.length); // 0??
The only place I've found anyone describing a problem with find() and
document fragments was in this thread:
http://groups.google.com/group/jquery-en/browse_thread/thread/a37b7aea6314fe21/
(Not sure if it's helpful, but as a simple investigation on the
"foreign document theory", I checked and found that
fragment.ownerDocument == $(fragment).children().filter("span").get
(0).ownerDocument == document)
Any ideas? Thanks!
---
http://hostilefork.com