Skip to content

Blank className error #65

@HenryDavies

Description

@HenryDavies

Whitespace-only classNames (e.g. class=" ") are currently added with the pattern ".", causing the following error:

Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Document': '.' is not a valid selector.

Here's the relevant bit of code in match.js:

if (attributeName === 'class') {
  const className = attributeValue.trim().replace(/\s+/g, '.')
  pattern = `.${className}`
}

I see a few potential fixes:

  • Still using the blank class as a selector, just keeping it as [class=' '] instead of converting to dot version
  • Not using it as a selector - continuing to next attribute
  • Only using as a selector if there are no non-blank attributes to use

Happy to put a fix in if helpful, just not sure which is best

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions