jQuery.fn = jQuery.prototype = {
init: function( selector, context ) {
- var match, elem, ret, doc, parent;
+ var match, elem, ret, doc;
// Handle $(""), $(null), or $(undefined)
if ( !selector ) {
} else {
ret = buildFragment( [ match[1] ], [ doc ] );
- parent = ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment;
- selector = [];
-
- while ( parent.firstChild ) {
- selector.push( parent.removeChild( parent.firstChild ) );
- }
+ selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
}
// HANDLE: $("#id")
});
jQuery.each({
- parent: function(elem){return elem.parentNode;},
+ parent: function(elem){var parent = elem.parentNode; return parent && parent.nodeType !== 11 ? parent : null;},
parents: function(elem){return jQuery.dir(elem,"parentNode");},
parentsUntil: function(elem,i,until){return jQuery.dir(elem,"parentNode",until);},
next: function(elem){return jQuery.nth(elem,2,"nextSibling");},