Skip to content
Permalink
Browse files

Make sure that the contents of the element is still in place when htm…

…l(Function) is called. Fixes #6733.
  • Loading branch information
jeresig committed Sep 28, 2010
1 parent e3c4e57 commit 0368606c081fd15dfbcd8509734ef63c58a6b008
Showing with 13 additions and 4 deletions.
  1. +2 −4 src/manipulation.js
  2. +11 −0 test/unit/manipulation.js
@@ -248,10 +248,8 @@ jQuery.fn.extend({

} else if ( jQuery.isFunction( value ) ) {
this.each(function(i){
var self = jQuery(this), old = self.html();
self.empty().append(function(){
return value.call( this, i, old );
});
var self = jQuery(this);
self.html( value.call(this, i, self.html()) );
});

} else {
@@ -955,6 +955,17 @@ test("html(String)", function() {

test("html(Function)", function() {
testHtml(functionReturningObj);

expect(33);

QUnit.reset();

jQuery("#main").html(function(){
return jQuery(this).text();
});

ok( !/</.test( jQuery("#main").html() ), "Replace html with text." );
ok( jQuery("#main").html().length > 0, "Make sure text exists." );
});

test("html(Function) with incoming value", function() {

0 comments on commit 0368606

Please sign in to comment.
You can’t perform that action at this time.