@@ -3577,6 +3577,15 @@ describe('$compile', function() {
3577
3577
} )
3578
3578
) ;
3579
3579
3580
+ it ( 'should support non-interpolated `src` and `data-src` on the same element' ,
3581
+ inject ( function ( $rootScope , $compile ) {
3582
+ var element = $compile ( '<img src="abc" data-src="123">' ) ( $rootScope ) ;
3583
+ expect ( element . attr ( 'src' ) ) . toEqual ( 'abc' ) ;
3584
+ expect ( element . attr ( 'data-src' ) ) . toEqual ( '123' ) ;
3585
+ $rootScope . $digest ( ) ;
3586
+ expect ( element . attr ( 'src' ) ) . toEqual ( 'abc' ) ;
3587
+ expect ( element . attr ( 'data-src' ) ) . toEqual ( '123' ) ;
3588
+ } ) ) ;
3580
3589
3581
3590
it ( 'should call observer only when the attribute value changes' , function ( ) {
3582
3591
module ( function ( ) {
@@ -12084,6 +12093,49 @@ describe('$compile', function() {
12084
12093
expect ( element . attr ( 'test6' ) ) . toBe ( 'Misko' ) ;
12085
12094
} ) ) ;
12086
12095
12096
+ describe ( 'with media url attributes' , function ( ) {
12097
+ it ( 'should work with interpolated ng-attr-src' , inject ( function ( ) {
12098
+ $rootScope . name = 'some-image.png' ;
12099
+ element = $compile ( '<img ng-attr-src="{{name}}">' ) ( $rootScope ) ;
12100
+ expect ( element . attr ( 'src' ) ) . toBeUndefined ( ) ;
12101
+
12102
+ $rootScope . $digest ( ) ;
12103
+ expect ( element . attr ( 'src' ) ) . toBe ( 'some-image.png' ) ;
12104
+
12105
+ $rootScope . name = 'other-image.png' ;
12106
+ $rootScope . $digest ( ) ;
12107
+ expect ( element . attr ( 'src' ) ) . toBe ( 'other-image.png' ) ;
12108
+ } ) ) ;
12109
+
12110
+ it ( 'should work with interpolated ng-attr-data-src' , inject ( function ( ) {
12111
+ $rootScope . name = 'some-image.png' ;
12112
+ element = $compile ( '<img ng-attr-data-src="{{name}}">' ) ( $rootScope ) ;
12113
+ expect ( element . attr ( 'data-src' ) ) . toBeUndefined ( ) ;
12114
+
12115
+ $rootScope . $digest ( ) ;
12116
+ expect ( element . attr ( 'data-src' ) ) . toBe ( 'some-image.png' ) ;
12117
+
12118
+ $rootScope . name = 'other-image.png' ;
12119
+ $rootScope . $digest ( ) ;
12120
+ expect ( element . attr ( 'data-src' ) ) . toBe ( 'other-image.png' ) ;
12121
+ } ) ) ;
12122
+
12123
+ it ( 'should work alongside constant [src]-attribute and [ng-attr-data-src] attributes' , inject ( function ( ) {
12124
+ $rootScope . name = 'some-image.png' ;
12125
+ element = $compile ( '<img src="constant.png" ng-attr-data-src="{{name}}">' ) ( $rootScope ) ;
12126
+ expect ( element . attr ( 'data-src' ) ) . toBeUndefined ( ) ;
12127
+
12128
+ $rootScope . $digest ( ) ;
12129
+ expect ( element . attr ( 'src' ) ) . toBe ( 'constant.png' ) ;
12130
+ expect ( element . attr ( 'data-src' ) ) . toBe ( 'some-image.png' ) ;
12131
+
12132
+ $rootScope . name = 'other-image.png' ;
12133
+ $rootScope . $digest ( ) ;
12134
+ expect ( element . attr ( 'src' ) ) . toBe ( 'constant.png' ) ;
12135
+ expect ( element . attr ( 'data-src' ) ) . toBe ( 'other-image.png' ) ;
12136
+ } ) ) ;
12137
+ } ) ;
12138
+
12087
12139
describe ( 'when an attribute has a dash-separated name' , function ( ) {
12088
12140
it ( 'should work with different prefixes' , inject ( function ( ) {
12089
12141
$rootScope . name = 'JamieMason' ;
0 commit comments