Make sure that wrapInner works on elements that have no contents. Fixes #3552.

This commit is contained in:
jeresig 2010-01-11 16:31:31 -05:00
parent 3e9ef6f5c0
commit 23d600c66d
2 changed files with 14 additions and 2 deletions

View file

@ -77,7 +77,14 @@ jQuery.fn.extend({
wrapInner: function( html ) {
return this.each(function() {
jQuery( this ).contents().wrapAll( html );
var self = jQuery( this ), contents = self.contents();
if ( contents.length ) {
contents.wrapAll( html );
} else {
self.append( html );
}
});
},