瀏覽代碼

Avoid ternary operators.

Piotrek Koszuliński 5 年之前
父節點
當前提交
4674066135
共有 1 個文件被更改,包括 15 次插入3 次删除
  1. 15 3
      packages/ckeditor5-engine/src/model/position.js

+ 15 - 3
packages/ckeditor5-engine/src/model/position.js

@@ -230,7 +230,11 @@ export default class Position {
 		const parent = this.parent;
 		const textNode = getTextNode( this, parent );
 
-		return textNode === null ? parent.getChild( parent.offsetToIndex( this.offset ) ) : null;
+		if ( textNode !== null ) {
+			return null;
+		}
+
+		return parent.getChild( parent.offsetToIndex( this.offset ) );
 	}
 
 	/**
@@ -245,7 +249,11 @@ export default class Position {
 		const parent = this.parent;
 		const textNode = getTextNode( this, parent );
 
-		return textNode === null ? parent.getChild( parent.offsetToIndex( this.offset ) - 1 ) : null;
+		if ( textNode !== null ) {
+			return null;
+		}
+
+		return parent.getChild( parent.offsetToIndex( this.offset ) - 1 );
 	}
 
 	/**
@@ -1073,5 +1081,9 @@ export default class Position {
 function getTextNode( position, positionParent ) {
 	const node = positionParent.getChild( positionParent.offsetToIndex( position.offset ) );
 
-	return ( node && node.is( 'text' ) && node.startOffset < position.offset ) ? node : null;
+	if ( node && node.is( 'text' ) && node.startOffset < position.offset ) {
+		return node;
+	}
+
+	return null;
 }