Ticket #4692: 4692_2.patch
File 4692_2.patch, 1.8 KB (added by , 14 years ago) |
---|
-
_source/includes/scriptcompressor.js
76 76 precedence[ Token.COMMA ] = 17; 77 77 78 78 // Tokens having right-to-left associativity. 79 // From http ://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Operators:Operator_Precedence79 // From https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Operators/Operator_Precedence 80 80 var associativityRTL = {}; 81 81 associativityRTL[ Token.SETNAME ] = 82 82 associativityRTL[ Token.SETPROP ] = … … 429 429 var param = child.getNext(); 430 430 while( param ) 431 431 { 432 if ( param.getType() == Token.COMMA ) 433 out( '(' ); 434 432 435 if ( !writeNode( param ) ) 433 436 break; 434 437 438 if ( param.getType() == Token.COMMA ) 439 out( ')' ); 440 435 441 param = param.getNext(); 436 442 437 443 if ( param ) … … 1103 1109 out( lang[ type ] ); 1104 1110 1105 1111 // The right side. 1106 if ( !parenthesis ) 1107 parenthesis = ( precedence[ type ] < ( precedence[ right.getType() ] || 0 ) ); 1112 parenthesis = ( precedence[ type ] < ( precedence[ right.getType() ] || 0 ) ); 1108 1113 1109 1114 if ( !parenthesis && !associativityRTL[ type ] && !noAssociativity[ type ] ) 1110 1115 parenthesis = ( precedence[ type ] == ( precedence[ right.getType() ] || 0 ) ); -
test/test.js
288 288 [ "var a=(b)?c:d;", 289 289 "var a=b?c:d;" ], 290 290 291 [ "var a=(b=c)?d:e;" ] 291 [ "var a=(b=c)?d:e;" ], 292 293 [ "a((1,2),3);" ], 294 295 [ "(1,2)+3;" ], 296 297 [ "3+(1,2);" ], 298 299 [ "(1,2);", "1,2;" ] 292 300 ]; 293 301 294 302 var tests =