Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Avoid ternary operators.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Apr 10, 2020
1 parent 3bb2fd4 commit e37cd07
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/model/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}

/**
Expand All @@ -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 );
}

/**
Expand Down Expand Up @@ -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;
}

0 comments on commit e37cd07

Please sign in to comment.