Forum closed. New forum available at http://community.wymeditor.org/

[Bug] Calling the .html() function

Discuss features, code, contributions, ideas, suggestions, ...
For bugs, patches and feature requests, please post on the Trac:
http://trac.wymeditor.org/

[Bug] Calling the .html() function

Postby morkil on Tue Mar 11, 2008 11:24 am

Calling wymeditor.html('') returns the contents of the editor instead of removing the current html.
This happens, because empty string is evaluated as false in the function:

Code: Select all
WYMeditor.editor.prototype.html = function(html) {

  if(html) jQuery(this._doc.body).html(html);
  else return(jQuery(this._doc.body).html());
};

possible fix:
Code: Select all
WYMeditor.editor.prototype.html = function(html) {

  if(typeof html === 'string') jQuery(this._doc.body).html(html);
  else return(jQuery(this._doc.body).html());
};

alternate fix:
Code: Select all
WYMeditor.editor.prototype.html = function(html) {

  if(typeof html !== 'undefined') jQuery(this._doc.body).html(html);
  else return(jQuery(this._doc.body).html());
};


PS
Some "native" jQuery functions have this bug too.
morkil
 
Posts: 1
Joined: Tue Mar 11, 2008 11:15 am

Postby jfh on Tue Mar 11, 2008 8:35 pm

User avatar
jfh
Site Admin
 
Posts: 370
Joined: Sat Sep 23, 2006 8:43 pm
Location: Belgium


Return to Developers

Who is online

Users browsing this forum: No registered users and 1 guest