8000 feat: support boolean attributes by privatenumber · Pull Request #652 · markdown-it/markdown-it · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@privatenumber
Copy link

#598

Supports:

  • .attrSet('download') on Token
  • .attrs.push(['download']) on Token
  • .attrs.push(['download', null]) on Token
  • .attrs.push(['download', undefined]) on Token

exports.lib.mdurl = require('mdurl');
exports.lib.ucmicro = require('uc.micro');

exports.isNil = isNil;
Copy link
Member
@puzrin < 8000 /span> puzrin Mar 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not good idea to spread micro helpers as lib feature, when used in only one place. Such things clutter api significantly in long term.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was trying to follow the existing organization.

Where do you want it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until "helper" is not used wide, it should be in the same file where it's needed. Preferably - inlined, without separate fn at all.

@puzrin
Copy link
Member
puzrin commented Mar 22, 2020
8000

We need do discuss final data format in original issue. I don't like duality (null & undefined) for single case, especially when it's hidden behind api call.

@privatenumber
Copy link
Author

@puzrin

I'm okay with just checking against undefined, but that would mean that doing .setAttrs('attr', null) -> attr="null" is expected behavior.

Let me know what you decide and I'll update.

@puzrin
Copy link
Member
puzrin commented Mar 22, 2020

I'm okay with just checking against undefined, but that would mean that doing .setAttrs('attr', null) -> attr="null" is expected behavior.

Let me know what you decide and I'll update.

I understand. I left issue open to discuss signature proposals from other users. Did not thinked about it myself, because issue is not too hot and can be hacked at user side (without dependency on my personal opinion).

@septatrix
Copy link

I have no strong preference but would like to add that boolean attributes can also be set to their own name to signify a true value (e.g. <div hidden="hidden">Something hidden and HTML5 compliant</div>) which is what we just settled with for now.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0