                                      offset + 1, getter_AddRefs(pNode));
        NS_ENSURE_SUCCESS(res, res);
  
-@@ -6767,16 +6734,18 @@ nsHTMLEditRules::ReturnInListItem(Select
+@@ -6767,16 +6737,18 @@ nsHTMLEditRules::ReturnInListItem(Select
          if (nodeAtom == nsGkAtoms::dd || nodeAtom == nsGkAtoms::dt) {
            int32_t itemOffset;
            nsCOMPtr<nsIDOMNode> list = nsEditor::GetNodeLocation(aListItem, &itemOffset);

 // ReturnInListItem: do the right thing for returns pressed in list items
 //
 nsresult
@@ -6706,16 +6670,19 @@ nsHTMLEditRules::ReturnInListItem(Select
     }
     else
     {

diff --git a/editor/libeditor/nsHTMLEditRules.cpp b/editor/libeditor/nsHTMLEditRules.cpp
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -482,17 +482,20 @@ nsHTMLEditRules::AfterEditInner(EditActi
          action != EditAction::insertIMEText) )
     {
       NS_ENSURE_STATE(mHTMLEditor);
       res = mHTMLEditor->CollapseAdjacentTextNodes(mDocChangeRange);
       NS_ENSURE_SUCCESS(res, res);
     }
 
     // clean up any empty nodes in the selection
-    res = RemoveEmptyNodes();
+    if ((action != EditAction::insertNode) &&
+        (action != EditAction::htmlPaste) &&
+        (action != EditAction::loadHTML))
+      res = RemoveEmptyNodes();
     NS_ENSURE_SUCCESS(res, res);
 
     // attempt to transform any unneeded nbsp's into spaces after doing various operations
     if ((action == EditAction::insertText) ||
         (action == EditAction::insertIMEText) ||
         (action == EditAction::deleteSelection) ||
         (action == EditAction::insertBreak) ||
         (action == EditAction::htmlPaste ||
@@ -1388,55 +1391,18 @@ nsHTMLEditRules::WillInsertText(EditActi
     int32_t pos = 0;
     NS_NAMED_LITERAL_STRING(newlineStr, LFSTR);
 
