Commit 0368606c authored by John Resig's avatar John Resig

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

Make sure that the contents of the element is still in place when html(Function) is called. Fixes #6733.
parent e3c4e578
...@@ -248,10 +248,8 @@ jQuery.fn.extend({ ...@@ -248,10 +248,8 @@ jQuery.fn.extend({
} else if ( jQuery.isFunction( value ) ) { } else if ( jQuery.isFunction( value ) ) {
this.each(function(i){ this.each(function(i){
var self = jQuery(this), old = self.html(); var self = jQuery(this);
self.empty().append(function(){ self.html( value.call(this, i, self.html()) );
return value.call( this, i, old );
});
}); });
} else { } else {
......
...@@ -955,6 +955,17 @@ test("html(String)", function() { ...@@ -955,6 +955,17 @@ test("html(String)", function() {
test("html(Function)", function() { test("html(Function)", function() {
testHtml(functionReturningObj); 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() { test("html(Function) with incoming value", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment