Skip to content

Commit

Permalink
declaration properties can only contain dashes and a-z values
Browse files Browse the repository at this point in the history
In case the property starts with `--`, we will parse it as a CSS
variable which can contain a few more characters like emoji for example.

Initial reason that I included uppercase is because I was thinking about
`Webkit`, but that should be `-webkit` in CSS anyway.

Technically uppercase values are valid in CSS:
```css
BODY {
  BACKGROUND-COLOR: RED;
}
```
Play: https://play.tailwindcss.com/sUsWi0Ampe?file=css

But for the sake of the arbitrary property, let's only allow
lower-kebab-case property names.
  • Loading branch information
RobinMalfait committed Mar 5, 2025
1 parent 5f56225 commit 3887c6b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/oxide/src/extractor/arbitrary_property_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Machine for ArbitraryPropertyMachine {
//
// E.g.: `[color:red]`
// ^^^^^
Class::Alpha => cursor.advance(),
Class::AlphaLower => cursor.advance(),

// End of the property name, but there must be at least a single character
Class::Colon if cursor.pos > self.start_pos + 1 => {
Expand Down Expand Up @@ -253,8 +253,8 @@ enum Class {
#[bytes(b'-')]
Dash,

#[bytes_range(b'a'..=b'z', b'A'..=b'Z')]
Alpha,
#[bytes_range(b'a'..=b'z')]
AlphaLower,

#[bytes(b':')]
Colon,
Expand Down

0 comments on commit 3887c6b

Please sign in to comment.