/*
 * Focus helper taken from Ember's code base:
 * https://github.com/emberjs/ember.js/blob/dfcd6f19c105543b79e440da2c4e456c1510b5ed/packages/ember-testing/lib/events/_native.js#L19-L23
 */

export default function focus(element) {
  if (!document.hasFocus || document.hasFocus()) {
    element[0].focus();
  } else {
    element.trigger('focusin');
  }
}
