diff --git a/editor/base/nsHTMLEditRules.cpp b/editor/base/nsHTMLEditRules.cpp
index 3d5ade20815b..a3d40cfe56a4 100644
--- a/editor/base/nsHTMLEditRules.cpp
+++ b/editor/base/nsHTMLEditRules.cpp
@@ -1687,7 +1687,7 @@ nsHTMLEditRules::ReturnInHeader(nsIDOMSelection *aSelection,
// merge text node with like sibling, if any
nsCOMPtr sibling;
textNode->GetNextSibling(getter_AddRefs(sibling));
- if (sibling)
+ if (sibling && mEditor->IsTextNode(sibling) && mEditor->IsEditable(sibling))
{
res = mEditor->JoinNodes(textNode,sibling,p);
if (NS_FAILED(res)) return res;
diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp
index 3d5ade20815b..a3d40cfe56a4 100644
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -1687,7 +1687,7 @@ nsHTMLEditRules::ReturnInHeader(nsIDOMSelection *aSelection,
// merge text node with like sibling, if any
nsCOMPtr sibling;
textNode->GetNextSibling(getter_AddRefs(sibling));
- if (sibling)
+ if (sibling && mEditor->IsTextNode(sibling) && mEditor->IsEditable(sibling))
{
res = mEditor->JoinNodes(textNode,sibling,p);
if (NS_FAILED(res)) return res;