Skip to content

Commit

Permalink
Add doc for isFullySelected
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jan 19, 2018
1 parent c61c7b7 commit 9f965f0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions editor/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@ export function documentHasSelection() {
return range && ! range.collapsed;
}

/**
* Check wether the contents of the element have been fully selected.
* Returns true if there is no possibility of full selection.
*
* @param {Element} element The element to check.
*
* @returns {Boolean} True if fully selected, false if not.
*/
export function isFullySelected( element ) {
if ( includes( [ 'INPUT', 'TEXTAREA' ], element.nodeName ) ) {
return element.selectionStart === 0 && element.value.length === element.selectionEnd;
Expand Down

0 comments on commit 9f965f0

Please sign in to comment.