diff --git a/compat/src/render.js b/compat/src/render.js index 62dcef0c7e..f18cbd896b 100644 --- a/compat/src/render.js +++ b/compat/src/render.js @@ -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. @@ -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]; @@ -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;