Skip to content

HTML_LOWER_CASE regex incorrectly lowercases custom element properties #451

@baspinarenes

Description

@baspinarenes

Bug

The HTML_LOWER_CASE regex used to determine which attributes should be lowercased
can falsely match custom element properties. For example, passing channelId to a
custom element results in channelid because the regex matches the ch prefix
(intended for charSet).

Reproduction

// Code
<my-fragment channelId="abc123" />
// Expected
<my-fragment channelId="abc123" />
// Actual
<my-fragment channelid="abc123" />

Cause

The regex ^(?:accessK|auto[A-Z]|cell|ch|col|...) uses broad prefixes that can
match unrelated property names on custom elements.

Proposed fix

Replace the regex with an explicit Set of known camelCase HTML attribute names
and use .has() instead of .test().

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