Skip to content

Commit

Permalink
Replace big if with guard clause.
Browse files Browse the repository at this point in the history
  • Loading branch information
engineering-this committed Apr 9, 2019
1 parent 99d835a commit d90bc9f
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions plugins/widgetselection/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,18 @@
}

function fixSelectionInWidget( widget, prefix ) {
if ( widget ) {
var widgetOuter = widget.wrapper || widget.element,
container = range[ prefix + 'Container' ],
offset = range[ prefix + 'Offset' ],
limit = prefix === 'start' ? 0 : container.getChildCount();

if ( widgetOuter.equals( container ) && offset === limit ) {
range[ prefix === 'start' ? 'setStartBefore' : 'setEndAfter' ]( widgetOuter );
} else {
range[ prefix === 'start' ? 'setStartAfter' : 'setEndBefore' ]( widgetOuter );
}
if ( !widget ) {
return;
}
var widgetOuter = widget.wrapper || widget.element,
container = range[ prefix + 'Container' ],
offset = range[ prefix + 'Offset' ],
limit = prefix === 'start' ? 0 : container.getChildCount();

if ( widgetOuter.equals( container ) && offset === limit ) {
range[ prefix === 'start' ? 'setStartBefore' : 'setEndAfter' ]( widgetOuter );
} else {
range[ prefix === 'start' ? 'setStartAfter' : 'setEndBefore' ]( widgetOuter );
}
}
}
Expand Down

0 comments on commit d90bc9f

Please sign in to comment.