Skip to content

Commit

Permalink
Fix event handling when input name='nodeName'
Browse files Browse the repository at this point in the history
  • Loading branch information
jimfb authored and jim committed Mar 22, 2016
1 parent 40c4635 commit cc10815
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/renderers/dom/client/ReactInputSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ function isInDocument(node) {
var ReactInputSelection = {

hasSelectionCapabilities: function(elem) {
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
return nodeName && (
(nodeName === 'input' && elem.type === 'text') ||
nodeName === 'textarea' ||
return nodeName && (elem instanceof window.HTMLTextAreaElement ||
((elem instanceof window.HTMLInputElement && elem.type === 'text') ||
elem.contentEditable === 'true'
);
},
Expand Down
7 changes: 3 additions & 4 deletions src/renderers/dom/client/eventPlugins/ChangeEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ var activeElementValueProp = null;
* SECTION: handle `change` event
*/
function shouldUseChangeEvent(elem) {
var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
return (
nodeName === 'select' ||
(nodeName === 'input' && elem.type === 'file')
elem instanceof window.HTMLSelectElement ||
(elem instanceof window.HTMLInputElement && elem.type === 'file')
);
}

Expand Down Expand Up @@ -307,7 +306,7 @@ function shouldUseClickEvent(elem) {
// This approach works across all browsers, whereas `change` does not fire
// until `blur` in IE8.
return (
(elem.nodeName && elem.nodeName.toLowerCase() === 'input') &&
(elem instanceof window.HTMLInputElement) &&
(elem.type === 'checkbox' || elem.type === 'radio')
);
}
Expand Down
7 changes: 3 additions & 4 deletions src/shared/utils/isTextInputElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ var supportedInputTypes = {
};

function isTextInputElement(elem) {
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
return nodeName && (
(nodeName === 'input' && supportedInputTypes[elem.type]) ||
nodeName === 'textarea'
return (
elem instanceof window.HTMLTextAreaElement ||
(elem instanceof window.HTMLInputElement && supportedInputTypes[elem.type])
);
}

Expand Down

0 comments on commit cc10815

Please sign in to comment.