From 501ec7b37bbc948634a98c94d44526f10afae7ac Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sat, 17 May 2008 16:16:27 -0700 Subject: [PATCH] Fixes a problem where Editor.dirty() returned true spuriously in Firefox, even when nothing was changed. The bug arose because Firefox shows br tags as "
" even when they are initially "
". This meant that the initial and current html didn't match up, so dirty() returned true even though nothing had changed. In IE, there's a similar problem because IE likes to uppercase all tags. That will be fixed in a subsequent commit. --- static/js/Editor.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/static/js/Editor.js b/static/js/Editor.js index d820202..c786097 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -709,7 +709,12 @@ Editor.prototype.summarize = function () { } Editor.prototype.dirty = function () { - if ( this.document.body.innerHTML == this.initial_text ) + // the replace() calls here cause the comparison to ignore difference between, for instance, + // "
" and "
" + var original_html = this.initial_text.replace( /\s*\/>/g, ">" ); + var current_html = this.document.body.innerHTML.replace( /\s*\/>/g, ">" ); + + if ( current_html == original_html ) return false; return true;