fb55/domutils

How can I remove/replace an attribute?

ivanjeremic opened this issue · 8 comments

Is there any API for removing/replacing an attribute? If not how would I do it with domutils?

fb55 commented

You likely want to use Cheerio for this — the relevant functions are removeAttr and attr.

@fb55 since Cheerio's release isn't out yet, are there any options available for this today?

@fb55 since Cheerio's release isn't out yet, are there any options available for this today?

Just use jsdom

@ivanjeremic I've had issues with jsdom that I don't experience with htmlparser2. Namely the ability to add/update Angular attributes like [customAttr] or (myOutputProp). It also doesn't seem to be possible to retain camel casing on attributes, which htmlParser2 preserves.

fb55 commented

This functionality is available in Cheerio. The unavailability of new loading methods shouldn't make Cheerio less useful.

Maybe jsdom/jsdom#2477 (comment)

Their general stance is that if it's not supported in the browser, they're not going to implement it. That's why that issue was closed without comment.

This functionality is available in Cheerio. The unavailability of new loading methods shouldn't make Cheerio less useful.

@fb55 Yes, and it works great, but ESM support is critical for us. And according to these two issues, that hasn't been released: cheeriojs/cheerio#3098, cheeriojs/cheerio#2774 Any chance the 1.0 release will make it out soon? I'd love to be able to use it.