Cheerio: empty attributes are appended with =""

Created on 21 Apr 2015  路  9Comments  路  Source: cheeriojs/cheerio

Original element:

<div class="user-menu" dropdown-toggle>

After using cheerio on file:

<div class="user-menu" dropdown-toggle="">

For some reason cheerio is appending all empty attributes with =""

Most helpful comment

Please reopen this issue, it's still broken!

All 9 comments

XHTML standard defines attr=attr for empty attributes.

Anyway to turn this off?

IMHO this should become the default behavior in non-XML mode. PRs for the dom-serializer module very appreciated.

@fb55, I sent a PR to fix this issue.
Please review and merge

Well I have the opposite problem :)
I'm working with xhtml and default="" is converted into default.

Problem come from that line :

if (!value && booleanAttributes[key]){

default is part of the booleanAttributes array.
So I guess we should check about xmlMode sooner.

Do you want a pull request ?

since dom-serializer ist not published to npm and cheerio is not updated to that new version yet, this issue is not fixed

Please reopen this issue, it's still broken!

Any chance of a new release of dom-serializer to fix this issue?

Was this page helpful?
0 / 5 - 0 ratings