focusNode.js 578 B

123456789101112131415161718192021222324
  1. /**
  2. * Copyright (c) 2013-present, Facebook, Inc.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. */
  8. 'use strict';
  9. /**
  10. * @param {DOMElement} node input/textarea to focus
  11. */
  12. function focusNode(node) {
  13. // IE8 can throw "Can't move focus to the control because it is invisible,
  14. // not enabled, or of a type that does not accept the focus." for all kinds of
  15. // reasons that are too expensive and fragile to test.
  16. try {
  17. node.focus();
  18. } catch (e) {}
  19. }
  20. module.exports = focusNode;