diff --git a/projects/Closure/87/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java b/projects/Closure/87/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java index 9498fa6..6c4ee4a 100644 --- a/projects/Closure/87/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java +++ b/projects/Closure/87/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java @@ -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; } }