Skip to content

Commit 049f19a

Browse files
committedNov 2, 2023
refactor: improved attributes-to-props, dom-to-react, utilities
Release-As: 5.0.5
1 parent a38ea33 commit 049f19a

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed
 

‎src/attributes-to-props.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ export default function attributesToProps(
6969

7070
// convert attribute to uncontrolled component prop (e.g., `value` to `defaultValue`)
7171
if (
72-
UNCONTROLLED_COMPONENT_ATTRIBUTES.indexOf(
72+
UNCONTROLLED_COMPONENT_ATTRIBUTES.includes(
7373
propName as UncontrolledComponentAttributes,
74-
) !== -1 &&
75-
UNCONTROLLED_COMPONENT_NAMES.indexOf(
74+
) &&
75+
UNCONTROLLED_COMPONENT_NAMES.includes(
7676
nodeName! as UncontrolledComponentNames,
77-
) !== -1 &&
77+
) &&
7878
!isInputValueOnly
7979
) {
8080
propName = getPropName('default' + attributeNameLowerCased);

‎src/dom-to-react.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export default function domToReact(
9595
props = attributesToProps(element.attribs, element.name);
9696
}
9797

98-
let children;
98+
let children: ReturnType<typeof domToReact> | undefined;
9999

100100
switch (node.type) {
101101
case 'script':

‎src/utilities.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ type ReservedSvgMathmlElements =
2929
*/
3030
export function isCustomComponent(
3131
tagName: string,
32-
props?: Record<PropertyKey, any>,
32+
props?: Record<PropertyKey, string>,
3333
): boolean {
34-
if (tagName.indexOf('-') === -1) {
34+
if (!tagName.includes('-')) {
3535
return Boolean(props && typeof props.is === 'string');
3636
}
3737

0 commit comments

Comments
 (0)
Please sign in to comment.