-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,13 @@ | |||
// @flow | |||
|
|||
const BOOLEAN_DOM_ATTRIBUTES = ['checked', 'selected', 'disabled', 'readonly', 'multiple', 'ismap']; |
There was a problem hiding this comment.
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 } { |
There was a problem hiding this comment.
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) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
для false в новой спеке лучше вообще выбрасывать ключ
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?
DOM Attributes in React 16