Set null instead of undefined in V8Objects for null values in Java Map #112
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 changes
V8ObjectUtils.toV8Object()
so that it setsnull
instead ofundefined
when it encounters anull
value in the Java Map.I appreciate that it may not always be clear which is better. I did wonder about adding a boolean flag to the public interface, or a parallel
toV8ObjectUseNull()
instead, but I wanted to solicit feedback first.My opinion: if a Java Map does contain an entry with a
null
value, then it got there because someone explicitly put it there, so the semantics of the JSnull
fit better thanundefined
. It's not like someone just forgot to initialise a field or variable, which is whatundefined
really means in JS.In any event, this change does fix a specific bug I encountered where a third-party JS library was handling
null
andundefined
differently.