2021年1月19日星期二

Cheerio.js adds a ="" to all empty data-attributes. How to leave them untouched?

Issue

When using Cheerio, all data attributes that are empty, like:

<p data-title></p>

end up being refactored to this: <p data-title=""></p>.

Expected Behavior

Whenever I run this:

const cheerio = require("cheerio");    const html = cheerio.load("<p data-title></p>");  console.log(html.html()); //<p data-title=""></p>  

I want the output to be this:

<p data-title></p>

instead of this:

<p data-title=""></p>

Conclusion

Any thoughts on how I can achieve this?

Thank you!

https://stackoverflow.com/questions/65802518/cheerio-js-adds-a-to-all-empty-data-attributes-how-to-leave-them-untouched January 20, 2021 at 11:05AM

没有评论:

发表评论