dperini / nwsapi

Fast CSS Selectors API Engine
MIT License
105 stars 36 forks source link

Attribute selector [data-x='],'] not recognized as valid selector #34

Closed ZhangYiJiang closed 1 year ago

ZhangYiJiang commented 4 years ago

NWSAPI incorrectly reports the selector [data-x='],'] (selecting elements with data-x attribute value of exactly ], - eg. <div data-x='],'></div>) as invalid. This is in fact a valid selector (at least in as much as browsers seem to recognize it just fine - I've not dug into the CSS grammar to check if it is).

Neither ] nor , alone seem to trigger the invalid selector error, and it is possible to work around it by escaping both characters ], as \]\, in the value.

JSFiddle repro: https://jsfiddle.net/2wemxrp3/

dperini commented 4 years ago

@ZhangYiJiang thank you for your time and effort notifying about this new issue. I am currently applying fixes for other issues so, if possible, I will include a fix for this too. It is very useful to always include a minimal reproducible case as you did, it will ease the debug. By the end of the next weekend I should be able to fix most pending issues. Have fun.

slavaleleka commented 1 year ago

seems like the issue is caused by , after ] inside attribute value

and it is still reproducible in latest jsdom with nwsapi v2.2.2