X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcore.js;h=a11ceb430dbc160459d1a9ebc3800b22dfd5b2ff;hb=9155d298ae8738ece29d4b2edfd32c578aebb27a;hp=78f0cae2d77e5c9c8b2c2d27a64994e9e2fe0bd0;hpb=1eae1541b8b4ca054d63d48f07001f55fa52fa5d;p=jquery.git diff --git a/src/core.js b/src/core.js index 78f0cae..a11ceb4 100644 --- a/src/core.js +++ b/src/core.js @@ -206,20 +206,22 @@ jQuery.fn = jQuery.prototype = { }, wrapAll: function( html ) { - if ( this[0] ) + if ( this[0] ) { // The elements to wrap the target around - jQuery( html, this[0].ownerDocument ) - .clone() - .insertBefore( this[0] ) - .map(function(){ - var elem = this; + var wrap = jQuery( html, this[0].ownerDocument ).clone(); + + if ( this[0].parentNode ) + wrap.insertBefore( this[0] ); - while ( elem.firstChild ) - elem = elem.firstChild; + wrap.map(function(){ + var elem = this; - return elem; - }) - .append(this); + while ( elem.firstChild ) + elem = elem.firstChild; + + return elem; + }).append(this); + } return this; }, @@ -961,7 +963,7 @@ jQuery.extend({ // Safari mis-reports the default selected property of a hidden option // Accessing the parent's selectedIndex property fixes it - if ( name == "selected" ) + if ( name == "selected" && elem.parentNode ) elem.parentNode.selectedIndex; // If applicable, access the attribute via the DOM 0 way