From 049f19a5340cd93031460490ac7e74abd9d511aa Mon Sep 17 00:00:00 2001 From: ssi02014 Date: Fri, 3 Nov 2023 00:02:48 +0900 Subject: [PATCH] refactor: improved attributes-to-props, dom-to-react, utilities Release-As: 5.0.5 --- src/attributes-to-props.ts | 8 ++++---- src/dom-to-react.ts | 2 +- src/utilities.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/attributes-to-props.ts b/src/attributes-to-props.ts index 2fd1b15f..db403e13 100644 --- a/src/attributes-to-props.ts +++ b/src/attributes-to-props.ts @@ -69,12 +69,12 @@ export default function attributesToProps( // convert attribute to uncontrolled component prop (e.g., `value` to `defaultValue`) if ( - UNCONTROLLED_COMPONENT_ATTRIBUTES.indexOf( + UNCONTROLLED_COMPONENT_ATTRIBUTES.includes( propName as UncontrolledComponentAttributes, - ) !== -1 && - UNCONTROLLED_COMPONENT_NAMES.indexOf( + ) && + UNCONTROLLED_COMPONENT_NAMES.includes( nodeName! as UncontrolledComponentNames, - ) !== -1 && + ) && !isInputValueOnly ) { propName = getPropName('default' + attributeNameLowerCased); diff --git a/src/dom-to-react.ts b/src/dom-to-react.ts index ffe262d3..47804e54 100644 --- a/src/dom-to-react.ts +++ b/src/dom-to-react.ts @@ -95,7 +95,7 @@ export default function domToReact( props = attributesToProps(element.attribs, element.name); } - let children; + let children: ReturnType | undefined; switch (node.type) { case 'script': diff --git a/src/utilities.ts b/src/utilities.ts index e1bf8c3b..facf0fc5 100644 --- a/src/utilities.ts +++ b/src/utilities.ts @@ -29,9 +29,9 @@ type ReservedSvgMathmlElements = */ export function isCustomComponent( tagName: string, - props?: Record, + props?: Record, ): boolean { - if (tagName.indexOf('-') === -1) { + if (!tagName.includes('-')) { return Boolean(props && typeof props.is === 'string'); }