From 953ee3bfc7e138a756b0be714c982af8deeeee14 Mon Sep 17 00:00:00 2001 From: Neil Jenkins Date: Wed, 2 Nov 2011 18:46:45 +1100 Subject: [PATCH] Fix bug in FF on enter. --- source/Editor.js | 4 +++- source/Node.js | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/source/Editor.js b/source/Editor.js index f959d96..bcfe3c0 100644 --- a/source/Editor.js +++ b/source/Editor.js @@ -988,7 +988,7 @@ document.addEventListener( 'DOMContentLoaded', function () { // Save undo checkpoint recordUndoState( range ); getRangeAndRemoveBookmark( range ); - + // Selected text is overwritten, therefore delete the contents // to collapse selection. if ( !range.collapsed ) { @@ -1002,6 +1002,8 @@ document.addEventListener( 'DOMContentLoaded', function () { splitTag = nextTag[ tag ], nodeAfterSplit; + // If this is a malformed bit of document, just play it safe + // and insert a
. if ( !block ) { range._insertNode( createElement( 'BR' ) ); range.collapse( false ); diff --git a/source/Node.js b/source/Node.js index c29c0c3..40de0eb 100644 --- a/source/Node.js +++ b/source/Node.js @@ -107,6 +107,8 @@ implement( Text, { getLength: function () { return this.length; }, + // The text node is essentially its own contents. + empty: function () { return this; }, isLike: function ( node ) { return node.nodeType === TEXT_NODE; },