Warn when an empty string is passed to a DOM boolean prop #13404
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.
This is the more targeted of two possible approaches to resolve #13400, the other being @gaearon's suggestion of warning on any string value passed to a boolean prop (also subsuming #13372).
Apart from my other reservation regarding a blanket warning on string values, the present approach has the advantage of being applicable to
BOOLEAN
,BOOLEANISH_STRING
andOVERLOADED_BOOLEAN
props (seeDOMProperty.js
for definitions). The latter do legitimately need to accept arbitrary string values alongside booleans; if we did go with a blanket warning, it would only make sense for the first two types, so we'd potentially still want a separate check for""
to accommodateOVERLOADED_BOOLEAN
.The one wrinkle here (that would also affect the other approach) is that I had to special-case
value
and exclude it from the warning, since it's somewhat oddly modelled as aBOOLEANISH_STRING
, making legitimate uses ofvalue=""
warn under my initial implementation. This raises a separate question, though: when isvalue
ever legitimately a boolean? (<param>
? That's a bit tenuous;value
is certainly not specced as a boolean there.) However, we can't just remove it from the whitelist, as that would break current behaviour.