Actions: HTML selector only supports alphanumeric CSS classes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 39.9k
- Forks
- 3.4k
- Avg merge
- 7h 27m
- Merged PRs (30d)
- 222
Description
Bug description
PostHog doesn't support HTML selector matches with CSS classes that contain non-alphanumeric characters. This becomes a problem for sites that use Tailwind CSS. If a customer is strictly using Tailwind, targeting HTML selectors becomes tricky.
Examples:
.rounded-sm
button[class="rounded-sm"]
.py-2.5 (notice the dot used _within_ the class)
.border-[1.5px]
.!ml-auto
Example HTML for an element like this (defined in this action):
Here's what PostHog sees:
It's worth noting that, while the class in the DOM shows like text-[15px], the Tailwind class it's actually referencing (as seen in the Styles tab in Inspector) escapes characters like [, ], .:
.text-\[15px\] {
font-size: 15px;
}
I also tried creating an action that escaped the non-alphanumeric characters (like .border-\[1\.5px\]) but it returns a 500 error when trying to calculate:
Somewhat related: https://github.com/PostHog/posthog/issues/3047
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue does not name a file, test, or entry point. Start by tracing HTML selector matching and the action calculation path using the linked action examples, then reproduce selectors such as .py-2.5 and .border-[1.5px]. Done means selectors containing non-alphanumeric or escaped characters match correctly without a 500 error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, html, tailwindcss
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100