@@ -2761,18 +2761,22 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2761
2761
2762
2762
// copy the new attributes on the old attrs object
2763
2763
forEach ( src , function ( value , key ) {
2764
- if ( key === 'class' ) {
2765
- safeAddClass ( $element , value ) ;
2766
- dst [ 'class' ] = ( dst [ 'class' ] ? dst [ 'class' ] + ' ' : '' ) + value ;
2767
- } else if ( key === 'style' ) {
2768
- $element . attr ( 'style' , $element . attr ( 'style' ) + ';' + value ) ;
2769
- dst [ 'style' ] = ( dst [ 'style' ] ? dst [ 'style' ] + ';' : '' ) + value ;
2770
- // `dst` will never contain hasOwnProperty as DOM parser won't let it.
2771
- // You will get an "InvalidCharacterError: DOM Exception 5" error if you
2772
- // have an attribute like "has-own-property" or "data-has-own-property", etc.
2773
- } else if ( key . charAt ( 0 ) !== '$' && ! dst . hasOwnProperty ( key ) ) {
2774
- dst [ key ] = value ;
2775
- dstAttr [ key ] = srcAttr [ key ] ;
2764
+ // Check if we already set this attribute in the loop above
2765
+ if ( ! dst [ key ] ) {
2766
+
2767
+ if ( key === 'class' ) {
2768
+ safeAddClass ( $element , value ) ;
2769
+ dst [ 'class' ] = ( dst [ 'class' ] ? dst [ 'class' ] + ' ' : '' ) + value ;
2770
+ } else if ( key === 'style' ) {
2771
+ $element . attr ( 'style' , $element . attr ( 'style' ) + ';' + value ) ;
2772
+ dst [ 'style' ] = ( dst [ 'style' ] ? dst [ 'style' ] + ';' : '' ) + value ;
2773
+ // `dst` will never contain hasOwnProperty as DOM parser won't let it.
2774
+ // You will get an "InvalidCharacterError: DOM Exception 5" error if you
2775
+ // have an attribute like "has-own-property" or "data-has-own-property", etc.
2776
+ } else if ( key . charAt ( 0 ) !== '$' && ! dst . hasOwnProperty ( key ) ) {
2777
+ dst [ key ] = value ;
2778
+ dstAttr [ key ] = srcAttr [ key ] ;
2779
+ }
2776
2780
}
2777
2781
} ) ;
2778
2782
}
0 commit comments