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

added stringify boolean non standard props to tag #11

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

Conversation

pavyarov
Copy link

@pavyarov pavyarov commented Apr 4, 2019

Added stringify boolean attributes, because it causes Warning at console.

Btw standard React behavior is just omit non-standard boolean attributes. Maybe better way is omit boolean values?

image

DOM Attributes in React 16

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 95.851% when pulling 21d1cd6 on pavyarov:master into 30e1d59 on redneckz:master.

@@ -0,0 +1,13 @@
// @flow

const BOOLEAN_DOM_ATTRIBUTES = ['checked', 'selected', 'disabled', 'readonly', 'multiple', 'ismap'];
Copy link
Owner

Choose a reason for hiding this comment

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

Деградация к React 15.
Лучше идти от attrs.


const BOOLEAN_DOM_ATTRIBUTES = ['checked', 'selected', 'disabled', 'readonly', 'multiple', 'ismap'];

export function stringifyBooleanProps(obj?: {} = {}): { [string]: mixed } {
Copy link
Owner

Choose a reason for hiding this comment

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

нужна сериализация в строку как для булевых так и для других типов атрибутов

return Object.entries(obj).reduce(
(acc, [key, value]) =>
(typeof obj[key] === 'boolean' && !BOOLEAN_DOM_ATTRIBUTES.includes(key)
? { ...acc, [key]: String(value) }
Copy link
Owner

Choose a reason for hiding this comment

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

для false в новой спеке лучше вообще выбрасывать ключ

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