-
-
Notifications
You must be signed in to change notification settings - Fork 222
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: minify infinity in expressions #841
Conversation
@@ -0,0 +1,6 @@ | |||
let x = [1 / 0, 1 / 0]; | |||
let y = [{ | |||
a: Infinity |
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.
Should expect a: 1 / 0
, I think.
@@ -27,11 +27,16 @@ module.exports = function({ types: t }) { | |||
if (path.parentPath.isMemberExpression()) { | |||
return; | |||
} | |||
|
|||
const bindingIds = path.parentPath.getBindingIdentifierPaths(); | |||
|
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.
Seems to work. If I'm reading it right, could
for (const id of Object.keys(bindingIds)) {
if (
id === "Infinity" &&
bindingIds[id] === path &&
// ObjectProperty is common for ObjectExpression and ObjectPattern and only
// one of them is a Binding, the other is simply a reference
!path.parentPath.parentPath.isObjectExpression()
) {
return;
}
}
be simplified to this?
if (
bindingIds["Infinity"] === path &&
// ObjectProperty is common for ObjectExpression and ObjectPattern and only
// one of them is a Binding, the other is simply a reference
!path.parentPath.parentPath.isObjectExpression()
) {
return;
}
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.
👍
Fix #839