Skip to content

domElements missing <search> tag (styled.search) #5608

Closed

Description

@otomad

Cannot use styled.search to create a <search> tag. Although you can use styled("search"), however the typescript typing is wrong (got never instead of HTMLElement). And the DevTools console will report Invalid DOM property `class`. Did you mean `className`? Error Component Stack, however I never type className to class by mistaken.

Solution

Add search to here:

's',
'samp',
'script',
'section',
'select',
'small',
'source',
'span',
'strong',
'style',
'sub',
'summary',
'sup',

Change the logic for determining whether it is a custom element.

propsForElement[
// handle custom elements which React doesn't properly alias
isTag(elementToBeCreated) &&
!domElements.has(elementToBeCreated as Extract<typeof domElements, string>)
? 'class'
: 'className'
] = classString;

The current logic just determine whether the tag is a known tag, otherwise it is a custom element tag. This is wrong, which will effect to the future native tags. The correct way is to check if the tag name has any hyphens.

It can be changed to this:

propsForElement[
    // handle custom elements which React doesn't properly alias
    isTag(elementToBeCreated) &&
    elementToBeCreated.includes('-')
      ? 'class'
      : 'className'
  ] = classString;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions