-
Notifications
You must be signed in to change notification settings - Fork 15
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
Handle fact value with null value #1878
Conversation
@@ -46,6 +46,10 @@ export const treeify = (name, data) => ({ | |||
const { [key]: element } = data; | |||
const dataType = typeof element; | |||
|
|||
if (element == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the piece of code which fixes the actual error
5f68c24
to
cc67448
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a tiny comment.
) : ( | ||
<span className={className}>{`${data}`}</span> | ||
); | ||
if (data === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, this is needed because typeof null
is object
, right? 😄
Besides this I am wondering whether it would make sense having this check in ObjectTree
itself. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, this is needed because typeof null is object, right? 😄
Yes, it is a bug in js that it won't be fixed in 10000 years.
Besides this I am wondering whether it would make sense having this check in ObjectTree itself. wdyt?
We have the same fix in the ObjectTree. We need to have in both places because we can get a plain fact value, so we don't always use ObjectTree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine with that 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey man thanks codewise LGTM!
Description
Handle
null
value in theObjectTree
. Without this fix theObject.keys(data)
above panics.Related to: trento-project/wanda#297
PD: As the objectree treats arrays and objects as the same, I think having the
{}
is good enough.How was this tested?
UT added