-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fix undefined bug for template strings. #45
Conversation
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.
Yes, this is correct- template literals always toString directly, and null
and undefined
toString to "null"
and "undefined"
respectively.
@evcohen Thank you!
The issue only pertained to But if I apply the fix in my fork and run with Separate issue? |
@@ -20,7 +20,7 @@ export default function extractValueFromTemplateLiteral(value) { | |||
if (type === 'TemplateElement') { | |||
return raw + part.value.raw; | |||
} else if (type === 'Identifier') { | |||
return part.name === 'undefined' ? raw : `${raw}{${part.name}}`; | |||
return part.name === 'undefined' ? `${raw}${part.name}` : `${raw}{${part.name}}`; |
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 should check for both "undefined" or "null", perhaps?
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.
I initially tried this myself but for null
the part.name
is actually undefined
and the part.value.raw
throws a TypeError so it seems that something is happening higher up already.
uh oh it looks like this may have been a breaking change. eslint-plugin-jsx-a11y tests are failing on v2.1.0 |
Which tests? Is it possible the tests were incorrect? |
Yes that looks to be the case. Fixing now |
Fixes #40
cc: @AlmeroSteyn is this the expectation?