From 893fba8373b648fa0a1370bcd3071250136dfad4 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Sun, 20 Oct 2013 14:36:43 -0700 Subject: [PATCH] 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. --- src/eventPlugins/SelectEventPlugin.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/eventPlugins/SelectEventPlugin.js b/src/eventPlugins/SelectEventPlugin.js index b96542e7235..acc3289a6b5 100644 --- a/src/eventPlugins/SelectEventPlugin.js +++ b/src/eventPlugins/SelectEventPlugin.js @@ -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