@@ -4750,21 +4750,28 @@ describe('$compile', function() {
4750
4750
scope : {
4751
4751
attr : '@' ,
4752
4752
attrAlias : '@attr' ,
4753
+ $attrAlias : '@$attr$' ,
4753
4754
ref : '=' ,
4754
4755
refAlias : '= ref' ,
4756
+ $refAlias : '= $ref$' ,
4755
4757
reference : '=' ,
4756
4758
optref : '=?' ,
4757
4759
optrefAlias : '=? optref' ,
4760
+ $optrefAlias : '=? $optref$' ,
4758
4761
optreference : '=?' ,
4759
4762
colref : '=*' ,
4760
4763
colrefAlias : '=* colref' ,
4764
+ $colrefAlias : '=* $colref$' ,
4761
4765
owRef : '<' ,
4762
4766
owRefAlias : '< owRef' ,
4767
+ $owRefAlias : '< $owRef$' ,
4763
4768
owOptref : '<?' ,
4764
4769
owOptrefAlias : '<? owOptref' ,
4770
+ $owOptrefAlias : '<? $owOptref$' ,
4765
4771
expr : '&' ,
4766
4772
optExpr : '&?' ,
4767
4773
exprAlias : '&expr' ,
4774
+ $exprAlias : '&$expr$' ,
4768
4775
constructor : '&?'
4769
4776
} ,
4770
4777
link : function ( scope ) {
@@ -5183,76 +5190,85 @@ describe('$compile', function() {
5183
5190
5184
5191
describe ( 'attribute' , function ( ) {
5185
5192
it ( 'should copy simple attribute' , inject ( function ( ) {
5186
- compile ( '<div><span my-component attr="some text">' ) ;
5193
+ compile ( '<div><span my-component attr="some text" $attr$="some other text" >' ) ;
5187
5194
5188
5195
expect ( componentScope . attr ) . toEqual ( 'some text' ) ;
5189
5196
expect ( componentScope . attrAlias ) . toEqual ( 'some text' ) ;
5197
+ expect ( componentScope . $attrAlias ) . toEqual ( 'some other text' ) ;
5190
5198
expect ( componentScope . attrAlias ) . toEqual ( componentScope . attr ) ;
5191
5199
} ) ) ;
5192
5200
5193
5201
it ( 'should copy an attribute with spaces' , inject ( function ( ) {
5194
- compile ( '<div><span my-component attr=" some text ">' ) ;
5202
+ compile ( '<div><span my-component attr=" some text " $attr$=" some other text " >' ) ;
5195
5203
5196
5204
expect ( componentScope . attr ) . toEqual ( ' some text ' ) ;
5197
5205
expect ( componentScope . attrAlias ) . toEqual ( ' some text ' ) ;
5206
+ expect ( componentScope . $attrAlias ) . toEqual ( ' some other text ' ) ;
5198
5207
expect ( componentScope . attrAlias ) . toEqual ( componentScope . attr ) ;
5199
5208
} ) ) ;
5200
5209
5201
5210
it ( 'should set up the interpolation before it reaches the link function' , inject ( function ( ) {
5202
5211
$rootScope . name = 'misko' ;
5203
- compile ( '<div><span my-component attr="hello {{name}}">' ) ;
5212
+ compile ( '<div><span my-component attr="hello {{name}}" $attr$="hi {{name}}" >' ) ;
5204
5213
expect ( componentScope . attr ) . toEqual ( 'hello misko' ) ;
5205
5214
expect ( componentScope . attrAlias ) . toEqual ( 'hello misko' ) ;
5215
+ expect ( componentScope . $attrAlias ) . toEqual ( 'hi misko' ) ;
5206
5216
} ) ) ;
5207
5217
5208
5218
it ( 'should update when interpolated attribute updates' , inject ( function ( ) {
5209
- compile ( '<div><span my-component attr="hello {{name}}">' ) ;
5219
+ compile ( '<div><span my-component attr="hello {{name}}" $attr$="hi {{name}}" >' ) ;
5210
5220
5211
5221
$rootScope . name = 'igor' ;
5212
5222
$rootScope . $apply ( ) ;
5213
5223
5214
5224
expect ( componentScope . attr ) . toEqual ( 'hello igor' ) ;
5215
5225
expect ( componentScope . attrAlias ) . toEqual ( 'hello igor' ) ;
5226
+ expect ( componentScope . $attrAlias ) . toEqual ( 'hi igor' ) ;
5216
5227
} ) ) ;
5217
5228
} ) ;
5218
5229
5219
5230
5220
5231
describe ( 'object reference' , function ( ) {
5221
5232
it ( 'should update local when origin changes' , inject ( function ( ) {
5222
- compile ( '<div><span my-component ref="name">' ) ;
5233
+ compile ( '<div><span my-component ref="name" $ref$="name" >' ) ;
5223
5234
expect ( componentScope . ref ) . toBeUndefined ( ) ;
5224
5235
expect ( componentScope . refAlias ) . toBe ( componentScope . ref ) ;
5236
+ expect ( componentScope . $refAlias ) . toBe ( componentScope . ref ) ;
5225
5237
5226
5238
$rootScope . name = 'misko' ;
5227
5239
$rootScope . $apply ( ) ;
5228
5240
5229
5241
expect ( $rootScope . name ) . toBe ( 'misko' ) ;
5230
5242
expect ( componentScope . ref ) . toBe ( 'misko' ) ;
5231
5243
expect ( componentScope . refAlias ) . toBe ( 'misko' ) ;
5244
+ expect ( componentScope . $refAlias ) . toBe ( 'misko' ) ;
5232
5245
5233
5246
$rootScope . name = { } ;
5234
5247
$rootScope . $apply ( ) ;
5235
5248
expect ( componentScope . ref ) . toBe ( $rootScope . name ) ;
5236
5249
expect ( componentScope . refAlias ) . toBe ( $rootScope . name ) ;
5250
+ expect ( componentScope . $refAlias ) . toBe ( $rootScope . name ) ;
5237
5251
} ) ) ;
5238
5252
5239
5253
5240
5254
it ( 'should update local when both change' , inject ( function ( ) {
5241
- compile ( '<div><span my-component ref="name">' ) ;
5255
+ compile ( '<div><span my-component ref="name" $ref$="name" >' ) ;
5242
5256
$rootScope . name = { mark :123 } ;
5243
5257
componentScope . ref = 'misko' ;
5244
5258
5245
5259
$rootScope . $apply ( ) ;
5246
5260
expect ( $rootScope . name ) . toEqual ( { mark :123 } ) ;
5247
5261
expect ( componentScope . ref ) . toBe ( $rootScope . name ) ;
5248
5262
expect ( componentScope . refAlias ) . toBe ( $rootScope . name ) ;
5263
+ expect ( componentScope . $refAlias ) . toBe ( $rootScope . name ) ;
5249
5264
5250
5265
$rootScope . name = 'igor' ;
5251
5266
componentScope . ref = { } ;
5252
5267
$rootScope . $apply ( ) ;
5253
5268
expect ( $rootScope . name ) . toEqual ( 'igor' ) ;
5254
5269
expect ( componentScope . ref ) . toBe ( $rootScope . name ) ;
5255
5270
expect ( componentScope . refAlias ) . toBe ( $rootScope . name ) ;
5271
+ expect ( componentScope . $refAlias ) . toBe ( $rootScope . name ) ;
5256
5272
} ) ) ;
5257
5273
5258
5274
it ( 'should not break if local and origin both change to the same value' , inject ( function ( ) {
@@ -5382,26 +5398,30 @@ describe('$compile', function() {
5382
5398
5383
5399
describe ( 'optional object reference' , function ( ) {
5384
5400
it ( 'should update local when origin changes' , inject ( function ( ) {
5385
- compile ( '<div><span my-component optref="name">' ) ;
5401
+ compile ( '<div><span my-component optref="name" $optref$="name" >' ) ;
5386
5402
expect ( componentScope . optRef ) . toBeUndefined ( ) ;
5387
5403
expect ( componentScope . optRefAlias ) . toBe ( componentScope . optRef ) ;
5404
+ expect ( componentScope . $optRefAlias ) . toBe ( componentScope . optRef ) ;
5388
5405
5389
5406
$rootScope . name = 'misko' ;
5390
5407
$rootScope . $apply ( ) ;
5391
5408
expect ( componentScope . optref ) . toBe ( $rootScope . name ) ;
5392
5409
expect ( componentScope . optrefAlias ) . toBe ( $rootScope . name ) ;
5410
+ expect ( componentScope . $optrefAlias ) . toBe ( $rootScope . name ) ;
5393
5411
5394
5412
$rootScope . name = { } ;
5395
5413
$rootScope . $apply ( ) ;
5396
5414
expect ( componentScope . optref ) . toBe ( $rootScope . name ) ;
5397
5415
expect ( componentScope . optrefAlias ) . toBe ( $rootScope . name ) ;
5416
+ expect ( componentScope . $optrefAlias ) . toBe ( $rootScope . name ) ;
5398
5417
} ) ) ;
5399
5418
5400
5419
it ( 'should not throw exception when reference does not exist' , inject ( function ( ) {
5401
5420
compile ( '<div><span my-component>' ) ;
5402
5421
5403
5422
expect ( componentScope . optref ) . toBeUndefined ( ) ;
5404
5423
expect ( componentScope . optrefAlias ) . toBeUndefined ( ) ;
5424
+ expect ( componentScope . $optrefAlias ) . toBeUndefined ( ) ;
5405
5425
expect ( componentScope . optreference ) . toBeUndefined ( ) ;
5406
5426
} ) ) ;
5407
5427
} ) ;
@@ -5419,16 +5439,18 @@ describe('$compile', function() {
5419
5439
$rootScope . query = '' ;
5420
5440
$rootScope . $apply ( ) ;
5421
5441
5422
- compile ( '<div><span my-component colref="collection | filter:query">' ) ;
5442
+ compile ( '<div><span my-component colref="collection | filter:query" $colref$="collection | filter:query" >' ) ;
5423
5443
5424
5444
expect ( componentScope . colref ) . toEqual ( $rootScope . collection ) ;
5425
5445
expect ( componentScope . colrefAlias ) . toEqual ( componentScope . colref ) ;
5446
+ expect ( componentScope . $colrefAlias ) . toEqual ( componentScope . colref ) ;
5426
5447
5427
5448
$rootScope . query = 'Gab' ;
5428
5449
$rootScope . $apply ( ) ;
5429
5450
5430
5451
expect ( componentScope . colref ) . toEqual ( [ $rootScope . collection [ 0 ] ] ) ;
5431
5452
expect ( componentScope . colrefAlias ) . toEqual ( [ $rootScope . collection [ 0 ] ] ) ;
5453
+ expect ( componentScope . $colrefAlias ) . toEqual ( [ $rootScope . collection [ 0 ] ] ) ;
5432
5454
} ) ) ;
5433
5455
5434
5456
it ( 'should update origin scope when isolate scope changes' , inject ( function ( ) {
@@ -5456,23 +5478,26 @@ describe('$compile', function() {
5456
5478
5457
5479
describe ( 'one-way binding' , function ( ) {
5458
5480
it ( 'should update isolate when the identity of origin changes' , inject ( function ( ) {
5459
- compile ( '<div><span my-component ow-ref="obj">' ) ;
5481
+ compile ( '<div><span my-component ow-ref="obj" $ow-ref$="obj" >' ) ;
5460
5482
5461
5483
expect ( componentScope . owRef ) . toBeUndefined ( ) ;
5462
5484
expect ( componentScope . owRefAlias ) . toBe ( componentScope . owRef ) ;
5485
+ expect ( componentScope . $owRefAlias ) . toBe ( componentScope . owRef ) ;
5463
5486
5464
5487
$rootScope . obj = { value : 'initial' } ;
5465
5488
$rootScope . $apply ( ) ;
5466
5489
5467
5490
expect ( $rootScope . obj ) . toEqual ( { value : 'initial' } ) ;
5468
5491
expect ( componentScope . owRef ) . toEqual ( { value : 'initial' } ) ;
5469
5492
expect ( componentScope . owRefAlias ) . toBe ( componentScope . owRef ) ;
5493
+ expect ( componentScope . $owRefAlias ) . toBe ( componentScope . owRef ) ;
5470
5494
5471
5495
// This changes in both scopes because of reference
5472
5496
$rootScope . obj . value = 'origin1' ;
5473
5497
$rootScope . $apply ( ) ;
5474
5498
expect ( componentScope . owRef . value ) . toBe ( 'origin1' ) ;
5475
5499
expect ( componentScope . owRefAlias . value ) . toBe ( 'origin1' ) ;
5500
+ expect ( componentScope . $owRefAlias . value ) . toBe ( 'origin1' ) ;
5476
5501
5477
5502
componentScope . owRef = { value : 'isolate1' } ;
5478
5503
componentScope . $apply ( ) ;
@@ -5483,17 +5508,19 @@ describe('$compile', function() {
5483
5508
$rootScope . $apply ( ) ;
5484
5509
expect ( componentScope . owRef . value ) . toBe ( 'isolate1' ) ;
5485
5510
expect ( componentScope . owRefAlias . value ) . toBe ( 'origin2' ) ;
5511
+ expect ( componentScope . $owRefAlias . value ) . toBe ( 'origin2' ) ;
5486
5512
5487
5513
// Change does propagate because object identity changes
5488
5514
$rootScope . obj = { value : 'origin3' } ;
5489
5515
$rootScope . $apply ( ) ;
5490
5516
expect ( componentScope . owRef . value ) . toBe ( 'origin3' ) ;
5491
5517
expect ( componentScope . owRef ) . toBe ( $rootScope . obj ) ;
5492
5518
expect ( componentScope . owRefAlias ) . toBe ( $rootScope . obj ) ;
5519
+ expect ( componentScope . $owRefAlias ) . toBe ( $rootScope . obj ) ;
5493
5520
} ) ) ;
5494
5521
5495
5522
it ( 'should update isolate when both change' , inject ( function ( ) {
5496
- compile ( '<div><span my-component ow-ref="name">' ) ;
5523
+ compile ( '<div><span my-component ow-ref="name" $ow-ref$="name" >' ) ;
5497
5524
5498
5525
$rootScope . name = { mark :123 } ;
5499
5526
componentScope . owRef = 'misko' ;
@@ -5502,13 +5529,15 @@ describe('$compile', function() {
5502
5529
expect ( $rootScope . name ) . toEqual ( { mark :123 } ) ;
5503
5530
expect ( componentScope . owRef ) . toBe ( $rootScope . name ) ;
5504
5531
expect ( componentScope . owRefAlias ) . toBe ( $rootScope . name ) ;
5532
+ expect ( componentScope . $owRefAlias ) . toBe ( $rootScope . name ) ;
5505
5533
5506
5534
$rootScope . name = 'igor' ;
5507
5535
componentScope . owRef = { } ;
5508
5536
$rootScope . $apply ( ) ;
5509
5537
expect ( $rootScope . name ) . toEqual ( 'igor' ) ;
5510
5538
expect ( componentScope . owRef ) . toBe ( $rootScope . name ) ;
5511
5539
expect ( componentScope . owRefAlias ) . toBe ( $rootScope . name ) ;
5540
+ expect ( componentScope . $owRefAlias ) . toBe ( $rootScope . name ) ;
5512
5541
} ) ) ;
5513
5542
5514
5543
describe ( 'initialization' , function ( ) {
@@ -5705,17 +5734,19 @@ describe('$compile', function() {
5705
5734
5706
5735
it ( 'should not update origin when identity of isolate changes' , inject ( function ( ) {
5707
5736
$rootScope . name = { mark :123 } ;
5708
- compile ( '<div><span my-component ow-ref="name">' ) ;
5737
+ compile ( '<div><span my-component ow-ref="name" $ow-ref$="name" >' ) ;
5709
5738
5710
5739
expect ( $rootScope . name ) . toEqual ( { mark :123 } ) ;
5711
5740
expect ( componentScope . owRef ) . toBe ( $rootScope . name ) ;
5712
5741
expect ( componentScope . owRefAlias ) . toBe ( $rootScope . name ) ;
5742
+ expect ( componentScope . $owRefAlias ) . toBe ( $rootScope . name ) ;
5713
5743
5714
5744
componentScope . owRef = 'martin' ;
5715
5745
$rootScope . $apply ( ) ;
5716
5746
expect ( $rootScope . name ) . toEqual ( { mark : 123 } ) ;
5717
5747
expect ( componentScope . owRef ) . toBe ( 'martin' ) ;
5718
5748
expect ( componentScope . owRefAlias ) . toEqual ( { mark : 123 } ) ;
5749
+ expect ( componentScope . $owRefAlias ) . toEqual ( { mark : 123 } ) ;
5719
5750
} ) ) ;
5720
5751
5721
5752
@@ -5862,45 +5893,51 @@ describe('$compile', function() {
5862
5893
5863
5894
describe ( 'optional one-way binding' , function ( ) {
5864
5895
it ( 'should update local when origin changes' , inject ( function ( ) {
5865
- compile ( '<div><span my-component ow-optref="name">' ) ;
5896
+ compile ( '<div><span my-component ow-optref="name" $ow-optref$="name" >' ) ;
5866
5897
5867
5898
expect ( componentScope . owOptref ) . toBeUndefined ( ) ;
5868
5899
expect ( componentScope . owOptrefAlias ) . toBe ( componentScope . owOptref ) ;
5900
+ expect ( componentScope . $owOptrefAlias ) . toBe ( componentScope . owOptref ) ;
5869
5901
5870
5902
$rootScope . name = 'misko' ;
5871
5903
$rootScope . $apply ( ) ;
5872
5904
expect ( componentScope . owOptref ) . toBe ( $rootScope . name ) ;
5873
5905
expect ( componentScope . owOptrefAlias ) . toBe ( $rootScope . name ) ;
5906
+ expect ( componentScope . $owOptrefAlias ) . toBe ( $rootScope . name ) ;
5874
5907
5875
5908
$rootScope . name = { } ;
5876
5909
$rootScope . $apply ( ) ;
5877
5910
expect ( componentScope . owOptref ) . toBe ( $rootScope . name ) ;
5878
5911
expect ( componentScope . owOptrefAlias ) . toBe ( $rootScope . name ) ;
5912
+ expect ( componentScope . $owOptrefAlias ) . toBe ( $rootScope . name ) ;
5879
5913
} ) ) ;
5880
5914
5881
5915
it ( 'should not throw exception when reference does not exist' , inject ( function ( ) {
5882
5916
compile ( '<div><span my-component>' ) ;
5883
5917
5884
5918
expect ( componentScope . owOptref ) . toBeUndefined ( ) ;
5885
5919
expect ( componentScope . owOptrefAlias ) . toBeUndefined ( ) ;
5920
+ expect ( componentScope . $owOptrefAlias ) . toBeUndefined ( ) ;
5886
5921
} ) ) ;
5887
5922
} ) ;
5888
5923
} ) ;
5889
5924
} ) ;
5890
5925
5891
5926
describe ( 'executable expression' , function ( ) {
5892
5927
it ( 'should allow expression execution with locals' , inject ( function ( ) {
5893
- compile ( '<div><span my-component expr="count = count + offset">' ) ;
5928
+ compile ( '<div><span my-component expr="count = count + offset" $expr$="count = count + offset" >' ) ;
5894
5929
$rootScope . count = 2 ;
5895
5930
5896
5931
expect ( typeof componentScope . expr ) . toBe ( 'function' ) ;
5897
5932
expect ( typeof componentScope . exprAlias ) . toBe ( 'function' ) ;
5933
+ expect ( typeof componentScope . $exprAlias ) . toBe ( 'function' ) ;
5898
5934
5899
5935
expect ( componentScope . expr ( { offset : 1 } ) ) . toEqual ( 3 ) ;
5900
5936
expect ( $rootScope . count ) . toEqual ( 3 ) ;
5901
5937
5902
5938
expect ( componentScope . exprAlias ( { offset : 10 } ) ) . toEqual ( 13 ) ;
5903
- expect ( $rootScope . count ) . toEqual ( 13 ) ;
5939
+ expect ( componentScope . $exprAlias ( { offset : 10 } ) ) . toEqual ( 23 ) ;
5940
+ expect ( $rootScope . count ) . toEqual ( 23 ) ;
5904
5941
} ) ) ;
5905
5942
} ) ;
5906
5943
@@ -5918,17 +5955,21 @@ describe('$compile', function() {
5918
5955
expect ( componentScope . $$isolateBindings . attr . mode ) . toBe ( '@' ) ;
5919
5956
expect ( componentScope . $$isolateBindings . attr . attrName ) . toBe ( 'attr' ) ;
5920
5957
expect ( componentScope . $$isolateBindings . attrAlias . attrName ) . toBe ( 'attr' ) ;
5958
+ expect ( componentScope . $$isolateBindings . $attrAlias . attrName ) . toBe ( '$attr$' ) ;
5921
5959
expect ( componentScope . $$isolateBindings . ref . mode ) . toBe ( '=' ) ;
5922
5960
expect ( componentScope . $$isolateBindings . ref . attrName ) . toBe ( 'ref' ) ;
5923
5961
expect ( componentScope . $$isolateBindings . refAlias . attrName ) . toBe ( 'ref' ) ;
5962
+ expect ( componentScope . $$isolateBindings . $refAlias . attrName ) . toBe ( '$ref$' ) ;
5924
5963
expect ( componentScope . $$isolateBindings . reference . mode ) . toBe ( '=' ) ;
5925
5964
expect ( componentScope . $$isolateBindings . reference . attrName ) . toBe ( 'reference' ) ;
5926
5965
expect ( componentScope . $$isolateBindings . owRef . mode ) . toBe ( '<' ) ;
5927
5966
expect ( componentScope . $$isolateBindings . owRef . attrName ) . toBe ( 'owRef' ) ;
5928
5967
expect ( componentScope . $$isolateBindings . owRefAlias . attrName ) . toBe ( 'owRef' ) ;
5968
+ expect ( componentScope . $$isolateBindings . $owRefAlias . attrName ) . toBe ( '$owRef$' ) ;
5929
5969
expect ( componentScope . $$isolateBindings . expr . mode ) . toBe ( '&' ) ;
5930
5970
expect ( componentScope . $$isolateBindings . expr . attrName ) . toBe ( 'expr' ) ;
5931
5971
expect ( componentScope . $$isolateBindings . exprAlias . attrName ) . toBe ( 'expr' ) ;
5972
+ expect ( componentScope . $$isolateBindings . $exprAlias . attrName ) . toBe ( '$expr$' ) ;
5932
5973
5933
5974
var firstComponentScope = componentScope ,
5934
5975
first$$isolateBindings = componentScope . $$isolateBindings ;
0 commit comments