-
Notifications
You must be signed in to change notification settings - Fork 64
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 string properties after computed properties correctly #91
Conversation
Sorry for the syntax error. I try to fix this and also try to add a fix for this issue this weekend. And BTW: thanks for this great tool! |
it currently compiles to ```js var obj; foo(( obj = {}, obj['computed'] = 1, obj.'some-var' = 2, obj )); ```
Not the most elegant way to fix this. Any tipps are appreciated. |
Thanks for the patch, this looks alright! |
@@ -175,7 +175,15 @@ export default class ObjectExpression extends Node { | |||
while (code.original[c] !== ']') c += 1; | |||
c += 1; | |||
} | |||
if (prop.shorthand) { | |||
if (prop.key.type === 'Literal' && !prop.computed) { | |||
console.log('' + code) |
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 removed that in a follow-up
prop.key.end + 1, | ||
'[' + code.slice(prop.start, prop.key.end) + '] = ' | ||
); | ||
console.log('' + code) |
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.
Removed that, too.
code.overwrite( | ||
prop.start, | ||
prop.key.end + 1, | ||
'[' + code.slice(prop.start, prop.key.end) + '] = ' |
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 think it would be better to remove the trailing whitespace, since hypothetical whitespace between the colon and the property value would be preserved, anyway.
it currently compiles to