Skip to content
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

Set null instead of undefined in V8Objects for null values in Java Map #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GrahamBorland
Copy link
Contributor

This changes V8ObjectUtils.toV8Object() so that it sets null instead of undefined when it encounters a null 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 JS null fit better than undefined. It's not like someone just forgot to initialise a field or variable, which is what undefined 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 and undefined differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant