Skip to content

Commit

Permalink
refactor: improved attributes-to-props, dom-to-react, utilities
Browse files Browse the repository at this point in the history
Release-As: 5.0.5
  • Loading branch information
ssi02014 committed Nov 2, 2023
1 parent a38ea33 commit 049f19a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/attributes-to-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/dom-to-react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default function domToReact(
props = attributesToProps(element.attribs, element.name);
}

let children;
let children: ReturnType<typeof domToReact> | undefined;

switch (node.type) {
case 'script':
Expand Down
4 changes: 2 additions & 2 deletions src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ type ReservedSvgMathmlElements =
*/
export function isCustomComponent(
tagName: string,
props?: Record<PropertyKey, any>,
props?: Record<PropertyKey, string>,
): boolean {
if (tagName.indexOf('-') === -1) {
if (!tagName.includes('-')) {
return Boolean(props && typeof props.is === 'string');
}

Expand Down

0 comments on commit 049f19a

Please sign in to comment.