0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -05:00

Fix bug in FF on enter.

This commit is contained in:
Neil Jenkins 2011-11-02 18:46:45 +11:00
parent a91df2db4c
commit 953ee3bfc7
2 changed files with 5 additions and 1 deletions

View file

@ -988,7 +988,7 @@ document.addEventListener( 'DOMContentLoaded', function () {
// Save undo checkpoint // Save undo checkpoint
recordUndoState( range ); recordUndoState( range );
getRangeAndRemoveBookmark( range ); getRangeAndRemoveBookmark( range );
// Selected text is overwritten, therefore delete the contents // Selected text is overwritten, therefore delete the contents
// to collapse selection. // to collapse selection.
if ( !range.collapsed ) { if ( !range.collapsed ) {
@ -1002,6 +1002,8 @@ document.addEventListener( 'DOMContentLoaded', function () {
splitTag = nextTag[ tag ], splitTag = nextTag[ tag ],
nodeAfterSplit; nodeAfterSplit;
// If this is a malformed bit of document, just play it safe
// and insert a <br>.
if ( !block ) { if ( !block ) {
range._insertNode( createElement( 'BR' ) ); range._insertNode( createElement( 'BR' ) );
range.collapse( false ); range.collapse( false );

View file

@ -107,6 +107,8 @@ implement( Text, {
getLength: function () { getLength: function () {
return this.length; return this.length;
}, },
// The text node is essentially its own contents.
empty: function () { return this; },
isLike: function ( node ) { isLike: function ( node ) {
return node.nodeType === TEXT_NODE; return node.nodeType === TEXT_NODE;
}, },