Skip to content

Commit 893fba8

Browse files
committed
Make SelectEventPlugin not throw for range inputs
Accessing .selectionStart on a non-text input will throw (see http://www.w3.org/TR/2009/WD-html5-20090423/editing.html#textFieldSelection), so check that the input has selection capabilities before accessing the property. Fixes facebook#437.
1 parent 44ad2b5 commit 893fba8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/eventPlugins/SelectEventPlugin.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var EventConstants = require('EventConstants');
2222
var EventPluginHub = require('EventPluginHub');
2323
var EventPropagators = require('EventPropagators');
2424
var ExecutionEnvironment = require('ExecutionEnvironment');
25+
var ReactInputSelection = require('ReactInputSelection');
2526
var SyntheticEvent = require('SyntheticEvent');
2627

2728
var getActiveElement = require('getActiveElement');
@@ -65,7 +66,8 @@ var mouseDown = false;
6566
* @param {object}
6667
*/
6768
function getSelection(node) {
68-
if ('selectionStart' in node) {
69+
if ('selectionStart' in node &&
70+
ReactInputSelection.hasSelectionCapabilities(node)) {
6971
return {
7072
start: node.selectionStart,
7173
end: node.selectionEnd

0 commit comments

Comments
 (0)