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

feat: support boolean attributes #652

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

@@ -299,6 +300,7 @@ exports.lib = {};
exports.lib.mdurl = require('mdurl');
exports.lib.ucmicro = require('uc.micro');

exports.isNil = isNil;
Copy link
Member

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

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.

None yet

3 participants