Skip to content

Commit c242faf

Browse files
authored
Call tolowercase only when needed (#4881)
1 parent b0d9195 commit c242faf

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

compat/src/render.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const REACT_ELEMENT_TYPE = Symbol.for('react.element');
3030

3131
const CAMEL_PROPS =
3232
/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
33-
const ON_ANI = /^on(Ani|Tra|Tou|BeforeInp|Compo)/;
3433
const CAMEL_REPLACE = /[A-Z0-9]/g;
3534
const IS_DOM = typeof document !== 'undefined';
3635

@@ -143,7 +142,6 @@ function handleDomVNode(vnode) {
143142
continue;
144143
}
145144

146-
let lowerCased = i.toLowerCase();
147145
if (i === 'style' && typeof value === 'object') {
148146
for (let key in value) {
149147
if (typeof value[key] === 'number' && !IS_NON_DIMENSIONAL.test(key)) {
@@ -165,9 +163,10 @@ function handleDomVNode(vnode) {
165163
// value will be used as the file name and the file will be called
166164
// "true" upon downloading it.
167165
value = '';
168-
} else if (lowerCased === 'translate' && value === 'no') {
166+
} else if (i === 'translate' && value === 'no') {
169167
value = false;
170-
} else if (lowerCased[0] === 'o' && lowerCased[1] === 'n') {
168+
} else if (i[0] === 'o' && i[1] === 'n') {
169+
let lowerCased = i.toLowerCase();
171170
if (lowerCased === 'ondoubleclick') {
172171
i = 'ondblclick';
173172
} else if (
@@ -180,24 +179,22 @@ function handleDomVNode(vnode) {
180179
i = 'onfocusin';
181180
} else if (lowerCased === 'onblur') {
182181
i = 'onfocusout';
183-
} else if (ON_ANI.test(i)) {
182+
}
183+
184+
// Add support for onInput and onChange, see #3561
185+
// if we have an oninput prop already change it to oninputCapture
186+
if (lowerCased === 'oninput') {
184187
i = lowerCased;
188+
if (normalizedProps[i]) {
189+
i = 'oninputCapture';
190+
}
185191
}
186192
} else if (isNonDashedType && CAMEL_PROPS.test(i)) {
187193
i = i.replace(CAMEL_REPLACE, '-$&').toLowerCase();
188194
} else if (value === null) {
189195
value = undefined;
190196
}
191197

192-
// Add support for onInput and onChange, see #3561
193-
// if we have an oninput prop already change it to oninputCapture
194-
if (lowerCased === 'oninput') {
195-
i = lowerCased;
196-
if (normalizedProps[i]) {
197-
i = 'oninputCapture';
198-
}
199-
}
200-
201198
normalizedProps[i] = value;
202199
}
203200

0 commit comments

Comments
 (0)