taoqf / node-html-parser

A very fast HTML parser, generating a simplified DOM, with basic element query support.
MIT License
1.12k stars 112 forks source link

search for elements by specific attribute without any value #31

Closed Jazz-Man closed 4 years ago

Jazz-Man commented 4 years ago

I added the ability to search for elements by certain attribute but without any value, for example:

const root = HTMLParser.parse('<a id="id" data-id="myid-one"><div><span class="a b" data-id="myid-two"></span><span></span><span></span></div></a>');

const test = root.querySelectorAll('[data-id]');
taoqf commented 4 years ago

Thank you.