esquery icon indicating copy to clipboard operation
esquery copied to clipboard

Proposal: Support check types

Open fisker opened this issue 4 years ago • 3 comments

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.

fisker avatar May 21 '21 06:05 fisker

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.

brettz9 avatar May 21 '21 22:05 brettz9

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

fisker avatar Feb 01 '23 08:02 fisker

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

fisker avatar Feb 01 '23 08:02 fisker