Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General performance improvements for folks using compat #4459

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions compat/src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const CAMEL_PROPS =
/^(?: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]/;
const ON_ANI = /^on(Ani|Tra|Tou|BeforeInp|Compo)/;
const CAMEL_REPLACE = /[A-Z0-9]/g;

const IS_DOM = typeof document !== 'undefined';

// Input types for which onchange should not be converted to oninput.
Expand Down Expand Up @@ -135,6 +134,7 @@ function handleDomVNode(vnode) {
type = vnode.type,
normalizedProps = {};

let isNonDashedType = type.indexOf('-') === -1;
for (let i in props) {
let value = props[i];

Expand Down Expand Up @@ -164,21 +164,23 @@ function handleDomVNode(vnode) {
value = '';
} else if (lowerCased === 'translate' && value === 'no') {
value = false;
} else if (lowerCased === 'ondoubleclick') {
i = 'ondblclick';
} else if (
lowerCased === 'onchange' &&
(type === 'input' || type === 'textarea') &&
!onChangeInputType(props.type)
) {
lowerCased = i = 'oninput';
} else if (lowerCased === 'onfocus') {
i = 'onfocusin';
} else if (lowerCased === 'onblur') {
i = 'onfocusout';
} else if (ON_ANI.test(i)) {
i = lowerCased;
} else if (type.indexOf('-') === -1 && CAMEL_PROPS.test(i)) {
} else if (lowerCased[0] === 'o' && lowerCased[1] === 'n') {
if (lowerCased === 'ondoubleclick') {
i = 'ondblclick';
} else if (
lowerCased === 'onchange' &&
(type === 'input' || type === 'textarea') &&
!onChangeInputType(props.type)
) {
lowerCased = i = 'oninput';
} else if (lowerCased === 'onfocus') {
i = 'onfocusin';
} else if (lowerCased === 'onblur') {
i = 'onfocusout';
} else if (ON_ANI.test(i)) {
i = lowerCased;
}
} else if (isNonDashedType && CAMEL_PROPS.test(i)) {
i = i.replace(CAMEL_REPLACE, '-$&').toLowerCase();
} else if (value === null) {
value = undefined;
Expand Down
Loading