diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp
index a28af48e2d7c..e125a3a8c3e9 100644
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -2171,7 +2171,9 @@ nsHTMLDocument::WriteCommon(const nsAString& aText,
// Save the data in cache
if (mWyciwygChannel) {
- mWyciwygChannel->WriteToCacheEntry(aText);
+ if (!aText.IsEmpty()) {
+ mWyciwygChannel->WriteToCacheEntry(aText);
+ }
if (aNewlineTerminate) {
mWyciwygChannel->WriteToCacheEntry(new_line);