Skip to content

Commit

Permalink
Merge pull request danielearwicker#19 from creately/fix-selec-method
Browse files Browse the repository at this point in the history
Fix selec method
  • Loading branch information
thani-sh authored Feb 15, 2019
2 parents 02bca34 + 40b6095 commit c509386
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ var prototype = node.derive({
return;
}
this.selection.start = Math.max(0, ordinal);
this.selection.end = Math.max(
this.selection.end = Math.min(
typeof ordinalEnd === 'number' ? ordinalEnd : this.selection.start,
this.frame.length - 1
);
Expand All @@ -438,6 +438,9 @@ var prototype = node.derive({
*/
this.notifySelectionChanged(takeFocus);
},
selectFrom: function( start, takeFocus ){
this.select( start, this.frame.length - 1, takeFocus );
},
selectAll: function(){
this.select( 0, this.frame.length - 1, true );
},
Expand Down
6 changes: 4 additions & 2 deletions test/doc.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ test('save function should return the selected content with default styles appli
]);
});

test('select function should take end of text if end index is not specified', () => {
document.select( 3 );
test('select function should take end of text if second param is `end` ', () => {
document.selectFrom( 3 );
expect( document.selectedRange().save()).toEqual([
{
text: 'here',
Expand All @@ -65,6 +65,8 @@ test('select function should take end of text if end index is not specified', ()
script: 'normal',
},
]);

});



0 comments on commit c509386

Please sign in to comment.