postcss-selector-parser icon indicating copy to clipboard operation
postcss-selector-parser copied to clipboard

Add a selector equality check

Open nex3 opened this issue 5 years ago • 0 comments

One thing I would find very useful is the ability to check if two selectors are semantically equal. I'm currently comparing the string representations of selectors, but that doesn't capture the fact that (for example) :is(a, b) means the same thing as :is(b, a) or that [a=\-1] means the same thing as [a="-1"]. postcss-selector-parser notionally has enough information in its AST to make these comparisons, so it would be awesome if that logic was implemented and made available as an API.

For prior art, it may be useful to look at Dart Sass's AST and in particular implementations of the operator == and hash methods.

nex3 avatar Jul 20 '20 22:07 nex3