Ticket #4692: 4692_2.patch

File 4692_2.patch, 1.8 KB (added by Frederico Caldeira Knabben, 14 years ago)
  • _source/includes/scriptcompressor.js

     
    7676        precedence[ Token.COMMA ] = 17;
    7777
    7878        // Tokens having right-to-left associativity.
    79         // From http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Operators:Operator_Precedence
     79        // From https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Operators/Operator_Precedence
    8080        var associativityRTL = {};
    8181        associativityRTL[ Token.SETNAME ] =
    8282        associativityRTL[ Token.SETPROP ] =
     
    429429                                var param = child.getNext();
    430430                                while( param )
    431431                                {
     432                                        if ( param.getType() == Token.COMMA )
     433                                                out( '(' );
     434
    432435                                        if ( !writeNode( param ) )
    433436                                                break;
    434437
     438                                        if ( param.getType() == Token.COMMA )
     439                                                out( ')' );
     440
    435441                                        param = param.getNext();
    436442
    437443                                        if ( param )
     
    11031109                                out( lang[ type ] );
    11041110
    11051111                                // The right side.
    1106                                 if ( !parenthesis )
    1107                                         parenthesis = ( precedence[ type ] < ( precedence[ right.getType() ] || 0 ) );
     1112                                parenthesis = ( precedence[ type ] < ( precedence[ right.getType() ] || 0 ) );
    11081113
    11091114                                if ( !parenthesis && !associativityRTL[ type ] && !noAssociativity[ type ] )
    11101115                                        parenthesis = ( precedence[ type ] == ( precedence[ right.getType() ] || 0 ) );
  • test/test.js

     
    288288                [       "var a=(b)?c:d;",
    289289                        "var a=b?c:d;" ],
    290290
    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;" ]
    292300        ];
    293301
    294302        var tests =
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy