Browse Source

Moved early return in `deleteContent`... earlier.

Szymon Cofalik 6 years ago
parent
commit
0938b7c6fe
1 changed files with 7 additions and 7 deletions
  1. 7 7
      packages/ckeditor5-engine/src/model/utils/deletecontent.js

+ 7 - 7
packages/ckeditor5-engine/src/model/utils/deletecontent.js

@@ -60,16 +60,16 @@ export default function deleteContent( model, selection, options = {} ) {
 		return;
 	}
 
-	const schema = model.schema;
+	const selRange = selection.getFirstRange();
 
-	model.change( writer => {
-		const selRange = selection.getFirstRange();
+	// If the selection is already removed, don't do anything.
+	if ( selRange.root.rootName == '$graveyard' ) {
+		return;
+	}
 
-		// If the selection is already removed, don't do anything.
-		if ( selRange.root.rootName == '$graveyard' ) {
-			return;
-		}
+	const schema = model.schema;
 
+	model.change( writer => {
 		// 1. Replace the entire content with paragraph.
 		// See: https://github.com/ckeditor/ckeditor5-engine/issues/1012#issuecomment-315017594.
 		if ( !options.doNotResetEntireContent && shouldEntireContentBeReplacedWithParagraph( schema, selection ) ) {