Ticket #100 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Calling wymeditor.html('') returns the contents of the editor

Reported by: jf.hovinne Owned by: jf.hovinne
Priority: major Milestone: 0.5
Component: editor Version: trunk
Keywords: api Cc:

Description

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:

WYMeditor.editor.prototype.html = function(html) {

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

possible fix: Code:

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:

WYMeditor.editor.prototype.html = function(html) {

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

See also http://forum.wymeditor.org/forum/viewtopic.php?t=296

Change History

Changed 2 years ago by jf.hovinne

  • status changed from new to closed
  • resolution set to fixed

Fixed by r503, thanks.

Note: See TracTickets for help on using tickets.