dperini / nwsapi

Fast CSS Selectors API Engine
MIT License
103 stars 35 forks source link

Selector with escaped special characters gives SyntaxError #105

Open MatMoore opened 6 months ago

MatMoore commented 6 months ago

I'm trying to use a selector with an escaped special character \\! in it.

Minimal example that breaks in nwsapi 2.2.7:

<div class="abc-!-def"></div>

<script type="text/javascript" src="./node_modules/nwsapi/src/nwsapi.js" onload="NW.Dom.install()"></script>
<script>
        console.log(document.querySelectorAll(":not(.abc-\\!-def)"))
</script>

This throws Uncaught DOMException: '.abc-!-def' is not a valid selector, but it works just fine with the query selector API provided by my browser (Chrome).

If I change the selector to just .abc-\\!-def, then the selector works as expected and I do not get a syntax error.