mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
committed by
Paul O’Shannessy
parent
ea1ab5501d
commit
ce612904ef
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user