added stringify boolean non standard props to tag#11
Open
pavyarov wants to merge 1 commit into
Open
Conversation
redneckz
reviewed
Apr 8, 2019
| @@ -0,0 +1,13 @@ | |||
| // @flow | |||
|
|
|||
| const BOOLEAN_DOM_ATTRIBUTES = ['checked', 'selected', 'disabled', 'readonly', 'multiple', 'ismap']; | |||
Owner
There was a problem hiding this comment.
Деградация к React 15.
Лучше идти от attrs.
redneckz
reviewed
Apr 8, 2019
|
|
||
| const BOOLEAN_DOM_ATTRIBUTES = ['checked', 'selected', 'disabled', 'readonly', 'multiple', 'ismap']; | ||
|
|
||
| export function stringifyBooleanProps(obj?: {} = {}): { [string]: mixed } { |
Owner
There was a problem hiding this comment.
нужна сериализация в строку как для булевых так и для других типов атрибутов
| return Object.entries(obj).reduce( | ||
| (acc, [key, value]) => | ||
| (typeof obj[key] === 'boolean' && !BOOLEAN_DOM_ATTRIBUTES.includes(key) | ||
| ? { ...acc, [key]: String(value) } |
Owner
There was a problem hiding this comment.
для false в новой спеке лучше вообще выбрасывать ключ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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