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

Proposal: Support check types #121

Open
fisker opened this issue May 21, 2021 · 3 comments
Open

Proposal: Support check types #121

fisker opened this issue May 21, 2021 · 3 comments

Comments

@fisker
Copy link

fisker commented May 21, 2021

For this code [1, '1', true, 'true'], there is no way to distinguish number/boolean and string (expect use [raw=], which is not safe).

I can see two solutions:

  1. Treat quoted attribute value as string, otherwise as literal value

    [value="1"] matches '1' not 1, [value="true"] matches 'true' not true, this can also prevent [value<2] unwanted matches sting '1'.

    I understand this will be a breaking change, but I still think worth to do it.

  2. Add a new pseudo selector :type([value], 'string') or something like this.

@brettz9
Copy link
Contributor

brettz9 commented May 21, 2021

I'd favor the second approach myself, as I think the first approach would introduce a dynamic different from CSS selectors which have no semantic difference between quotes or no quotes.

@fisker
Copy link
Author

fisker commented Feb 1, 2023

Maybe we can support [value="1" number] like i and s in CSS Attribute selector?

@fisker
Copy link
Author

fisker commented Feb 1, 2023

Wow, I found a workaround Literal[value="1"][value.constructor.name="Number"] 😄

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

No branches or pull requests

2 participants