focusNode.js.flow 607 B

12345678910111213141516171819202122232425
  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. * @providesModule focusNode
  8. */
  9. 'use strict';
  10. /**
  11. * @param {DOMElement} node input/textarea to focus
  12. */
  13. function focusNode(node) {
  14. // IE8 can throw "Can't move focus to the control because it is invisible,
  15. // not enabled, or of a type that does not accept the focus." for all kinds of
  16. // reasons that are too expensive and fragile to test.
  17. try {
  18. node.focus();
  19. } catch (e) {}
  20. }
  21. module.exports = focusNode;