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 #437.
This commit is contained in:
Ben Alpert
2013-10-20 14:36:43 -07:00
committed by Paul O’Shannessy
parent ea1ab5501d
commit ce612904ef
+3 -1
View File
@@ -22,6 +22,7 @@ var EventConstants = require('EventConstants');
var EventPluginHub = require('EventPluginHub');
var EventPropagators = require('EventPropagators');
var ExecutionEnvironment = require('ExecutionEnvironment');
var ReactInputSelection = require('ReactInputSelection');
var SyntheticEvent = require('SyntheticEvent');
var getActiveElement = require('getActiveElement');
@@ -65,7 +66,8 @@ var mouseDown = false;
* @param {object}
*/
function getSelection(node) {
if ('selectionStart' in node) {
if ('selectionStart' in node &&
ReactInputSelection.hasSelectionCapabilities(node)) {
return {
start: node.selectionStart,
end: node.selectionEnd