@@ -3006,14 +3006,21 @@ describe('$compile', function() {
3006
3006
scope : {
3007
3007
attr : '@' ,
3008
3008
attrAlias : '@attr' ,
3009
+ attrVerbose : 'interpolate:' ,
3010
+ attrAliasVerbose : 'interpolate:attr' ,
3009
3011
ref : '=' ,
3010
3012
refAlias : '= ref' ,
3013
+ refVerbose : 'bind:' ,
3014
+ refAliasVerbose : 'bind: ref' ,
3011
3015
reference : '=' ,
3012
3016
optref : '=?' ,
3013
3017
optrefAlias : '=? optref' ,
3014
- optreference : '=?' ,
3018
+ optrefVerbose : 'bind:optional:' ,
3019
+ optrefAliasVerbose : 'bind:optional: optref' ,
3015
3020
expr : '&' ,
3016
- exprAlias : '&expr'
3021
+ exprAlias : '&expr' ,
3022
+ exprVerbose : 'eval:' ,
3023
+ exprAliasVerbose : 'eval:expr'
3017
3024
} ,
3018
3025
link : function ( scope ) {
3019
3026
componentScope = scope ;
@@ -3277,68 +3284,83 @@ describe('$compile', function() {
3277
3284
3278
3285
describe ( 'attribute' , function ( ) {
3279
3286
it ( 'should copy simple attribute' , inject ( function ( ) {
3280
- compile ( '<div><span my-component attr="some text">' ) ;
3287
+ compile ( '<div><span my-component attr="some text" attr-verbose="some text" >' ) ;
3281
3288
3282
3289
expect ( componentScope . attr ) . toEqual ( 'some text' ) ;
3283
3290
expect ( componentScope . attrAlias ) . toEqual ( 'some text' ) ;
3284
- expect ( componentScope . attrAlias ) . toEqual ( componentScope . attr ) ;
3291
+ expect ( componentScope . attrVerbose ) . toEqual ( 'some text' ) ;
3292
+ expect ( componentScope . attrAliasVerbose ) . toEqual ( 'some text' ) ;
3285
3293
} ) ) ;
3286
3294
3287
3295
it ( 'should set up the interpolation before it reaches the link function' , inject ( function ( ) {
3288
3296
$rootScope . name = 'misko' ;
3289
- compile ( '<div><span my-component attr="hello {{name}}">' ) ;
3297
+ compile ( '<div><span my-component attr="hello {{name}}" attr-verbose="hello {{name}}" >' ) ;
3290
3298
expect ( componentScope . attr ) . toEqual ( 'hello misko' ) ;
3291
3299
expect ( componentScope . attrAlias ) . toEqual ( 'hello misko' ) ;
3300
+ expect ( componentScope . attrVerbose ) . toEqual ( 'hello misko' ) ;
3301
+ expect ( componentScope . attrAliasVerbose ) . toEqual ( 'hello misko' ) ;
3292
3302
} ) ) ;
3293
3303
3294
3304
it ( 'should update when interpolated attribute updates' , inject ( function ( ) {
3295
- compile ( '<div><span my-component attr="hello {{name}}">' ) ;
3305
+ compile ( '<div><span my-component attr="hello {{name}}" attr-verbose="hello {{name}}" >' ) ;
3296
3306
3297
3307
$rootScope . name = 'igor' ;
3298
3308
$rootScope . $apply ( ) ;
3299
3309
3300
3310
expect ( componentScope . attr ) . toEqual ( 'hello igor' ) ;
3301
3311
expect ( componentScope . attrAlias ) . toEqual ( 'hello igor' ) ;
3312
+ expect ( componentScope . attrVerbose ) . toEqual ( 'hello igor' ) ;
3313
+ expect ( componentScope . attrAliasVerbose ) . toEqual ( 'hello igor' ) ;
3302
3314
} ) ) ;
3303
3315
} ) ;
3304
3316
3305
3317
3306
3318
describe ( 'object reference' , function ( ) {
3307
3319
it ( 'should update local when origin changes' , inject ( function ( ) {
3308
- compile ( '<div><span my-component ref="name">' ) ;
3320
+ compile ( '<div><span my-component ref="name" ref-verbose="name" >' ) ;
3309
3321
expect ( componentScope . ref ) . toBe ( undefined ) ;
3310
- expect ( componentScope . refAlias ) . toBe ( componentScope . ref ) ;
3322
+ expect ( componentScope . refAlias ) . toBe ( undefined ) ;
3323
+ expect ( componentScope . refVerbose ) . toBe ( undefined ) ;
3324
+ expect ( componentScope . refAliasVerbose ) . toBe ( undefined ) ;
3311
3325
3312
3326
$rootScope . name = 'misko' ;
3313
3327
$rootScope . $apply ( ) ;
3314
3328
3315
3329
expect ( $rootScope . name ) . toBe ( 'misko' ) ;
3316
3330
expect ( componentScope . ref ) . toBe ( 'misko' ) ;
3317
3331
expect ( componentScope . refAlias ) . toBe ( 'misko' ) ;
3332
+ expect ( componentScope . refVerbose ) . toBe ( 'misko' ) ;
3333
+ expect ( componentScope . refAliasVerbose ) . toBe ( 'misko' ) ;
3318
3334
3319
3335
$rootScope . name = { } ;
3320
3336
$rootScope . $apply ( ) ;
3321
3337
expect ( componentScope . ref ) . toBe ( $rootScope . name ) ;
3322
3338
expect ( componentScope . refAlias ) . toBe ( $rootScope . name ) ;
3339
+ expect ( componentScope . refVerbose ) . toBe ( $rootScope . name ) ;
3340
+ expect ( componentScope . refAliasVerbose ) . toBe ( $rootScope . name ) ;
3323
3341
} ) ) ;
3324
3342
3325
3343
3326
3344
it ( 'should update local when both change' , inject ( function ( ) {
3327
- compile ( '<div><span my-component ref="name">' ) ;
3345
+ compile ( '<div><span my-component ref="name" ref-verbose="name" >' ) ;
3328
3346
$rootScope . name = { mark :123 } ;
3329
3347
componentScope . ref = 'misko' ;
3330
3348
3331
3349
$rootScope . $apply ( ) ;
3332
3350
expect ( $rootScope . name ) . toEqual ( { mark :123 } ) ;
3333
3351
expect ( componentScope . ref ) . toBe ( $rootScope . name ) ;
3334
3352
expect ( componentScope . refAlias ) . toBe ( $rootScope . name ) ;
3353
+ expect ( componentScope . refVerbose ) . toBe ( $rootScope . name ) ;
3354
+ expect ( componentScope . refAliasVerbose ) . toBe ( $rootScope . name ) ;
3335
3355
3336
3356
$rootScope . name = 'igor' ;
3337
3357
componentScope . ref = { } ;
3338
3358
$rootScope . $apply ( ) ;
3339
3359
expect ( $rootScope . name ) . toEqual ( 'igor' ) ;
3340
3360
expect ( componentScope . ref ) . toBe ( $rootScope . name ) ;
3341
3361
expect ( componentScope . refAlias ) . toBe ( $rootScope . name ) ;
3362
+ expect ( componentScope . refVerbose ) . toBe ( $rootScope . name ) ;
3363
+ expect ( componentScope . refAliasVerbose ) . toBe ( $rootScope . name ) ;
3342
3364
} ) ) ;
3343
3365
3344
3366
it ( 'should not break if local and origin both change to the same value' , inject ( function ( ) {
@@ -3455,44 +3477,60 @@ describe('$compile', function() {
3455
3477
3456
3478
describe ( 'optional object reference' , function ( ) {
3457
3479
it ( 'should update local when origin changes' , inject ( function ( ) {
3458
- compile ( '<div><span my-component optref="name">' ) ;
3459
- expect ( componentScope . optRef ) . toBe ( undefined ) ;
3460
- expect ( componentScope . optRefAlias ) . toBe ( componentScope . optRef ) ;
3480
+ compile ( '<div><span my-component optref="name" optref-verbose="name">' ) ;
3481
+ expect ( componentScope . optref ) . toBe ( undefined ) ;
3482
+ expect ( componentScope . optrefAlias ) . toBe ( undefined ) ;
3483
+ expect ( componentScope . optrefVerbose ) . toBe ( undefined ) ;
3484
+ expect ( componentScope . optrefAliasVerbose ) . toBe ( undefined ) ;
3461
3485
3462
3486
$rootScope . name = 'misko' ;
3463
3487
$rootScope . $apply ( ) ;
3464
3488
expect ( componentScope . optref ) . toBe ( $rootScope . name ) ;
3465
3489
expect ( componentScope . optrefAlias ) . toBe ( $rootScope . name ) ;
3490
+ expect ( componentScope . optrefVerbose ) . toBe ( $rootScope . name ) ;
3491
+ expect ( componentScope . optrefAliasVerbose ) . toBe ( $rootScope . name ) ;
3466
3492
3467
3493
$rootScope . name = { } ;
3468
3494
$rootScope . $apply ( ) ;
3469
3495
expect ( componentScope . optref ) . toBe ( $rootScope . name ) ;
3470
3496
expect ( componentScope . optrefAlias ) . toBe ( $rootScope . name ) ;
3497
+ expect ( componentScope . optrefVerbose ) . toBe ( $rootScope . name ) ;
3498
+ expect ( componentScope . optrefAliasVerbose ) . toBe ( $rootScope . name ) ;
3471
3499
} ) ) ;
3472
3500
3473
3501
it ( 'should not throw exception when reference does not exist' , inject ( function ( ) {
3474
3502
compile ( '<div><span my-component>' ) ;
3475
3503
3476
3504
expect ( componentScope . optref ) . toBe ( undefined ) ;
3477
3505
expect ( componentScope . optrefAlias ) . toBe ( undefined ) ;
3478
- expect ( componentScope . optreference ) . toBe ( undefined ) ;
3506
+ expect ( componentScope . optrefVerbose ) . toBe ( undefined ) ;
3507
+ expect ( componentScope . optrefAliasVerbose ) . toBe ( undefined ) ;
3479
3508
} ) ) ;
3480
3509
} ) ;
3481
3510
3482
3511
3483
3512
describe ( 'executable expression' , function ( ) {
3484
3513
it ( 'should allow expression execution with locals' , inject ( function ( ) {
3485
- compile ( '<div><span my-component expr="count = count + offset">' ) ;
3514
+ compile ( '<div><span my-component expr="count = count + offset" ' +
3515
+ 'expr-verbose="count = count + offset">' ) ;
3486
3516
$rootScope . count = 2 ;
3487
3517
3488
3518
expect ( typeof componentScope . expr ) . toBe ( 'function' ) ;
3489
3519
expect ( typeof componentScope . exprAlias ) . toBe ( 'function' ) ;
3520
+ expect ( typeof componentScope . exprVerbose ) . toBe ( 'function' ) ;
3521
+ expect ( typeof componentScope . exprAliasVerbose ) . toBe ( 'function' ) ;
3490
3522
3491
3523
expect ( componentScope . expr ( { offset : 1 } ) ) . toEqual ( 3 ) ;
3492
3524
expect ( $rootScope . count ) . toEqual ( 3 ) ;
3493
3525
3494
3526
expect ( componentScope . exprAlias ( { offset : 10 } ) ) . toEqual ( 13 ) ;
3495
3527
expect ( $rootScope . count ) . toEqual ( 13 ) ;
3528
+
3529
+ expect ( componentScope . exprVerbose ( { offset : 1 } ) ) . toEqual ( 14 ) ;
3530
+ expect ( $rootScope . count ) . toEqual ( 14 ) ;
3531
+
3532
+ expect ( componentScope . exprAliasVerbose ( { offset : 10 } ) ) . toEqual ( 24 ) ;
3533
+ expect ( $rootScope . count ) . toEqual ( 24 ) ;
3496
3534
} ) ) ;
3497
3535
} ) ;
3498
3536
@@ -3510,14 +3548,20 @@ describe('$compile', function() {
3510
3548
expect ( componentScope . $$isolateBindings . attr . mode ) . toBe ( '@' ) ;
3511
3549
expect ( componentScope . $$isolateBindings . attr . attrName ) . toBe ( 'attr' ) ;
3512
3550
expect ( componentScope . $$isolateBindings . attrAlias . attrName ) . toBe ( 'attr' ) ;
3551
+ expect ( componentScope . $$isolateBindings . attrVerbose . attrName ) . toBe ( 'attrVerbose' ) ;
3552
+ expect ( componentScope . $$isolateBindings . attrAliasVerbose . attrName ) . toBe ( 'attr' ) ;
3513
3553
expect ( componentScope . $$isolateBindings . ref . mode ) . toBe ( '=' ) ;
3514
3554
expect ( componentScope . $$isolateBindings . ref . attrName ) . toBe ( 'ref' ) ;
3515
3555
expect ( componentScope . $$isolateBindings . refAlias . attrName ) . toBe ( 'ref' ) ;
3556
+ expect ( componentScope . $$isolateBindings . refVerbose . attrName ) . toBe ( 'refVerbose' ) ;
3557
+ expect ( componentScope . $$isolateBindings . refAliasVerbose . attrName ) . toBe ( 'ref' ) ;
3516
3558
expect ( componentScope . $$isolateBindings . reference . mode ) . toBe ( '=' ) ;
3517
3559
expect ( componentScope . $$isolateBindings . reference . attrName ) . toBe ( 'reference' ) ;
3518
3560
expect ( componentScope . $$isolateBindings . expr . mode ) . toBe ( '&' ) ;
3519
3561
expect ( componentScope . $$isolateBindings . expr . attrName ) . toBe ( 'expr' ) ;
3520
3562
expect ( componentScope . $$isolateBindings . exprAlias . attrName ) . toBe ( 'expr' ) ;
3563
+ expect ( componentScope . $$isolateBindings . exprVerbose . attrName ) . toBe ( 'exprVerbose' ) ;
3564
+ expect ( componentScope . $$isolateBindings . exprAliasVerbose . attrName ) . toBe ( 'expr' ) ;
3521
3565
3522
3566
var firstComponentScope = componentScope ,
3523
3567
first$$isolateBindings = componentScope . $$isolateBindings ;
0 commit comments