Skip to content

Commit

Permalink
fixed files form Closure #87
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent b6404f8 commit feb181f
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -520,17 +520,29 @@ private boolean isFoldableExpressBlock(Node n) {
if (n.getType() == Token.BLOCK) {
if (n.hasOneChild()) {
Node maybeExpr = n.getFirstChild();
if (maybeExpr.getType() == Token.EXPR_RESULT) {
// IE has a bug where event handlers behave differently when
// their return value is used vs. when their return value is in
// an EXPR_RESULT. It's pretty freaking weird. See:
// http://code.google.com/p/closure-compiler/issues/detail?id=291
// We try to detect this case, and not fold EXPR_RESULTs
// into other expressions.
if (maybeExpr.getFirstChild().getType() == Token.CALL) {
Node calledFn = maybeExpr.getFirstChild().getFirstChild();

// We only have to worry about methods with an implicit 'this'
// param, or this doesn't happen.
if (calledFn.getType() == Token.GETELEM) {
return false;
} else if (calledFn.getType() == Token.GETPROP &&
calledFn.getLastChild().getString().startsWith("on")) {
return false;
}
}

return NodeUtil.isExpressionNode(maybeExpr);
return true;
}
return false;
}
}

Expand Down

0 comments on commit feb181f

Please sign in to comment.