Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

call toString in html() (see ticket #10604)

  • Loading branch information...
commit 66920cfeb2c488eb377b1ce4e1246dcd44c5359f 1 parent 9026688
@chriswu000 authored
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/manipulation.js
4 src/manipulation.js
@@ -247,6 +247,10 @@ jQuery.fn.extend({
self.html(, i, self.html()) );
+ } else if ( jQuery.isFunction( value.toString ) ) {
+ var self = jQuery( this );
+ self.html( value.toString() );
} else {
this.empty().append( value );

6 comments on commit 66920cf


This may require a bit more work as most things have a toString function.


Sorry, I'm not sure I understand. I don't call toString until after html() checks if it's a string or a function. Is there something more that I need to check?




Would it be enough to avoid calling toString if value is a DOM element? E.g.,

else if ( jQuery.isFunction( value.toString ) && value.nodeType === undefined )

Checking just for nodeType seems a bit weak though. Is there an idiomatic and/or better way that jQuery code checks for this?


I believe jQuery has its own variation of an isElement method. It doesn't really matter now as the original ticket was closed as a won't fix.


Thanks; I don't see an isElement method, but I did find this code for determining if something is an element: isElement = this.nodeType === 1

Please sign in to comment.
Something went wrong with that request. Please try again.