@samitouri / QOS-React-2 / commits / 2bb69328ae

Always toLowerCase when comparing nodeName or tagName

In xml node name casing is exactly the same as the node was originally named. Make sure to convert node and tag names to lower case before making any node and tag name checks. Fixes #3960.

Tomasz Kołodziejski committed May 29, 2015 at 17:13 UTC 2bb69328ae4e8284a8fce4074dc2301c28b667b7
4 files changed +17 -12
src/renderers/dom/client/ReactInputSelection.js
+8 -5
@@ -30,9 +30,10 @@ function isInDocument(node) {
30 var ReactInputSelection = {
31
32 hasSelectionCapabilities: function(elem) {
33 - return elem && (
34 - (elem.nodeName === 'INPUT' && elem.type === 'text') ||
35 - elem.nodeName === 'TEXTAREA' ||
33 + var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
34 + return nodeName && (
35 + (nodeName === 'input' && elem.type === 'text') ||
36 + nodeName === 'textarea' ||
37 elem.contentEditable === 'true'
38 );
39 },
@@ -84,7 +85,8 @@ var ReactInputSelection = {
85 start: input.selectionStart,
86 end: input.selectionEnd
87 };
87 - } else if (document.selection && input.nodeName === 'INPUT') {
88 + } else if (document.selection &&
89 + (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
90 // IE8 input.
91 var range = document.selection.createRange();
92 // There can only be one selection per document in IE, so it must
@@ -119,7 +121,8 @@ var ReactInputSelection = {
121 if ('selectionStart' in input) {
122 input.selectionStart = start;
123 input.selectionEnd = Math.min(end, input.value.length);
122 - } else if (document.selection && input.nodeName === 'INPUT') {
124 + } else if (document.selection &&
125 + (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
126 var range = input.createTextRange();
127 range.collapse(true);
128 range.moveStart('character', start);
src/renderers/dom/client/ReactMount.js
+1 -1
@@ -519,7 +519,7 @@ var ReactMount = {
519 );
520
521 warning(
522 - container && container.tagName !== 'BODY',
522 + container && container.tagName && container.tagName.toUpperCase() !== 'BODY',
523 'render(): Rendering components directly into document.body is ' +
524 'discouraged, since its children are often manipulated by third-party ' +
525 'scripts and browser extensions. This may lead to subtle ' +
src/renderers/dom/client/eventPlugins/ChangeEventPlugin.js
+4 -3
@@ -55,9 +55,10 @@ var activeElementValueProp = null;
55 * SECTION: handle `change` event
56 */
57 function shouldUseChangeEvent(elem) {
58 + var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
59 return (
59 - elem.nodeName === 'SELECT' ||
60 - (elem.nodeName === 'INPUT' && elem.type === 'file')
60 + nodeName === 'select' ||
61 + (nodeName === 'input' && elem.type === 'file')
62 );
63 }
64
@@ -289,7 +290,7 @@ function shouldUseClickEvent(elem) {
290 // This approach works across all browsers, whereas `change` does not fire
291 // until `blur` in IE8.
292 return (
292 - elem.nodeName === 'INPUT' &&
293 + (elem.nodeName && elem.nodeName.toLowerCase() === 'input') &&
294 (elem.type === 'checkbox' || elem.type === 'radio')
295 );
296 }
src/shared/utils/isTextInputElement.js
+4 -3
@@ -33,9 +33,10 @@ var supportedInputTypes = {
33 };
34
35 function isTextInputElement(elem) {
36 - return elem && (
37 - (elem.nodeName === 'INPUT' && supportedInputTypes[elem.type]) ||
38 - elem.nodeName === 'TEXTAREA'
36 + var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
37 + return nodeName && (
38 + (nodeName === 'input' && supportedInputTypes[elem.type]) ||
39 + nodeName === 'textarea'
40 );
41 }
42