File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -589,9 +589,9 @@ Parser.prototype = {
589
589
var middle ;
590
590
var token ;
591
591
if ( ( token = this . expect ( '?' ) ) ) {
592
- middle = this . ternary ( ) ;
592
+ middle = this . assignment ( ) ;
593
593
if ( ( token = this . expect ( ':' ) ) ) {
594
- return this . ternaryFn ( left , middle , this . ternary ( ) ) ;
594
+ return this . ternaryFn ( left , middle , this . assignment ( ) ) ;
595
595
} else {
596
596
this . throwError ( 'expected :' , token ) ;
597
597
}
Original file line number Diff line number Diff line change @@ -429,6 +429,17 @@ describe('parser', function() {
429
429
expect ( scope . b ) . toEqual ( 234 ) ;
430
430
} ) ;
431
431
432
+ it ( 'should evaluate assignments in ternary operator' , function ( ) {
433
+ scope . $eval ( 'a = 1 ? 2 : 3' ) ;
434
+ expect ( scope . a ) . toBe ( 2 ) ;
435
+
436
+ scope . $eval ( '0 ? a = 2 : a = 3' ) ;
437
+ expect ( scope . a ) . toBe ( 3 ) ;
438
+
439
+ scope . $eval ( '1 ? a = 2 : a = 3' ) ;
440
+ expect ( scope . a ) . toBe ( 2 ) ;
441
+ } ) ;
442
+
432
443
it ( 'should evaluate function call without arguments' , function ( ) {
433
444
scope [ 'const' ] = function ( a , b ) { return 123 ; } ;
434
445
expect ( scope . $eval ( "const()" ) ) . toEqual ( 123 ) ;
You can’t perform that action at this time.
0 commit comments