Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove id, class, style attribute when attribute value is empty #4395

Open
trymeouteh opened this issue Feb 1, 2025 · 1 comment
Open

Remove id, class, style attribute when attribute value is empty #4395

trymeouteh opened this issue Feb 1, 2025 · 1 comment

Comments

@trymeouteh
Copy link

For popular attribute such as id, class, and style which must have a value to be relevant are not removed from any tags when they are empty

For example...

let $ = cheerio.load('<p class="my-class">Hello World</p>', { xml: true });

$('p').removeClass('my-class');

console.log($.html());



$ = cheerio.load('<p style="color: red;">Hello World</p>', { xml: true });

$('*').css('color', '');

console.log($.html());

The output I get...

<p class="">Hello World</p>
<p style="">Hello World</p>

The output I expected...

<p>Hello World</p>
<p>Hello World</p>
@rickyssj2
Copy link

Hey, I can work on fixing this issue. Please give a like if you want my help. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants