diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
index 4db01da6ff6..067db688f37 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
@@ -1844,10 +1844,6 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
// Time to change the document
nsAutoEditBatch beginBatching(this);
- // Try to replace body contents first
- res = SelectAll();
- if (NS_FAILED(res)) return res;
-
nsReadingIterator endtotal;
aSourceString.EndReading(endtotal);
@@ -1877,6 +1873,9 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
}
if (NS_FAILED(res)) return res;
+ res = SelectAll();
+ if (NS_FAILED(res)) return res;
+
if (!foundbody) {
NS_NAMED_LITERAL_STRING(body, "");
// XXX Without recourse to some parser/content sink/docshell hackery