Test the behavior for undefined
value in custom attributes
#59
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.
A few months ago @Krinkle identified an API problem when passing
undefined
to the cookie value. Basically in that situation, the return of a function that is supposed to generate a cookie value should not be interpreted as a getter.Now we have a similar situation with the cookie attributes. The documentation doesn't say that
undefined
is a valid input for a cookie attribute, so the intent of the code just assumes the value will be truthy and uses&&
to check for it. The only actual benefit of using logical&&
operator was to reduce a few bytes gzipped when they were removed in bulk here.Fortunately,
[undefined].join('')
returns""
in the operation to persist the cookie, so it doesn't writec=v; path=/undefined
fordomain: undefined
like what happened to theexpires: false
attribute.Unfortunately that is not tested.
undefined
value, which might not be wise since it will become implicitly supported and cannot be changed in any future minor version bump.Example:
Is it worth testing this behavior?