Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to escape values in selectors #554

Open
SteffenDE opened this issue Mar 6, 2024 · 0 comments
Open

Add functionality to escape values in selectors #554

SteffenDE opened this issue Mar 6, 2024 · 0 comments
Labels

Comments

@SteffenDE
Copy link
Contributor

Feature goal

In the browser, there is the CSS.escape function that is very useful when constructing CSS selectors. It would be great if Floki had a similar functionality. Instead of Floki.find(html, "##{id} .foo") we could write Floki.find(html, "##{Floki.css_escape(id)} .foo"). This could be especially useful in LiveView tests.

Relates to: #551
Relates to: phoenixframework/phoenix_live_view#3159
Relates to: phoenixframework/phoenix_live_view#3145

iex> Floki.css_escape("abc?")
"abc\\?"
iex> Floki.css_escape("abc[]")
"abc\\[\\]"

Dependencies

A functionality like this would require Floki to be able to properly parse the escaped values. I'm not sure if this is currently always the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant