{"size": 791, "ext": "js", "max_stars_repo_path": "src/scripts/utils/selection.js", "max_stars_repo_name": "eduardoportilho/YnabExtension", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/scripts/utils/selection.js", "max_issues_repo_name": "eduardoportilho/YnabExtension", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/scripts/utils/selection.js", "max_forks_repo_name": "eduardoportilho/YnabExtension", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.4230769231, "max_line_length": 83, "alphanum_fraction": 0.6927939317}
/**
 * @typedef {DomSelectionRange} DOM elements of a selection range
 * @property {Element} start - Element on the beginning of the selection.
 * @property {Element} end - Element on the end of the selection.
 */

module.exports = {
  /**
   * Get the DOM elements contained in the user selection.
   * @param  {Window} aWindow - Window object.
   * @return {DomSelectionRange} Selection range.
   */
  getSelectedElements: (aWindow) => {
    // Selection object: https://developer.mozilla.org/en-US/docs/Web/API/Selection
    var selection = aWindow.getSelection()

    var startNode = selection.anchorNode || selection.extentNode
    var endNode = selection.focusNode  || selection.baseNode

    return {
      start: startNode.parentElement,
      end: endNode.parentElement
    }
  }
}
