Skip to content

Commit

Permalink
Merge pull request #1148 from ssi02014/refac/type
Browse files Browse the repository at this point in the history
refactor: improved attributes-to-props, dom-to-react, utilities
  • Loading branch information
remarkablemark authored Nov 2, 2023
2 parents a38ea33 + 049f19a commit a41c6de
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 a41c6de

Please sign in to comment.