@@ -128,13 +128,7 @@ function $CompileProvider($provide) {
128
128
COMMENT_DIRECTIVE_REGEXP = / ^ \s * d i r e c t i v e \: \s * ( [ \d \w \- _ ] + ) \s + ( .* ) $ / ,
129
129
CLASS_DIRECTIVE_REGEXP = / ( ( [ \d \w \- _ ] + ) (?: \: ( [ ^ ; ] + ) ) ? ; ? ) / ,
130
130
CONTENT_REGEXP = / \< \< c o n t e n t \> \> / i,
131
- HAS_ROOT_ELEMENT = / ^ \< [ \s \S ] * \> $ / ,
132
- SIDE_EFFECT_ATTRS = { } ;
133
-
134
- forEach ( 'src,href,multiple,selected,checked,disabled,readonly,required' . split ( ',' ) , function ( name ) {
135
- SIDE_EFFECT_ATTRS [ name ] = name ;
136
- SIDE_EFFECT_ATTRS [ directiveNormalize ( 'ng_' + name ) ] = name ;
137
- } ) ;
131
+ HAS_ROOT_ELEMENT = / ^ \< [ \s \S ] * \> $ / ;
138
132
139
133
140
134
this . directive = function registerDirective ( name , directiveFactory ) {
@@ -861,44 +855,29 @@ function $CompileProvider($provide) {
861
855
862
856
863
857
function addAttrInterpolateDirective ( node , directives , value , name ) {
864
- var interpolateFn = $interpolate ( value , true ) ,
865
- realName = SIDE_EFFECT_ATTRS [ name ] ,
866
- specialAttrDir = ( realName && ( realName !== name ) ) ;
867
-
868
- realName = realName || name ;
858
+ var interpolateFn = $interpolate ( value , true ) ;
869
859
870
- if ( specialAttrDir && isBooleanAttr ( node , name ) ) {
871
- value = true ;
872
- }
873
860
874
- // no interpolation found and we are not a side-effect attr -> ignore
875
- if ( ! interpolateFn && ! specialAttrDir ) {
876
- return ;
877
- }
861
+ // no interpolation found -> ignore
862
+ if ( ! interpolateFn ) return ;
878
863
879
864
directives . push ( {
880
865
priority : 100 ,
881
- compile : function ( element , attr ) {
882
- if ( interpolateFn ) {
883
- return function ( scope , element , attr ) {
884
- if ( name === 'class' ) {
885
- // we need to interpolate classes again, in the case the element was replaced
886
- // and therefore the two class attrs got merged - we want to interpolate the result
887
- interpolateFn = $interpolate ( attr [ name ] , true ) ;
888
- }
889
-
890
- // we define observers array only for interpolated attrs
891
- // and ignore observers for non interpolated attrs to save some memory
892
- attr . $observers [ realName ] = [ ] ;
893
- attr [ realName ] = undefined ;
894
- scope . $watch ( interpolateFn , function ( value ) {
895
- attr . $set ( realName , value ) ;
896
- } ) ;
897
- } ;
898
- } else {
899
- attr . $set ( realName , value ) ;
866
+ compile : valueFn ( function ( scope , element , attr ) {
867
+ if ( name === 'class' ) {
868
+ // we need to interpolate classes again, in the case the element was replaced
869
+ // and therefore the two class attrs got merged - we want to interpolate the result
870
+ interpolateFn = $interpolate ( attr [ name ] , true ) ;
900
871
}
901
- }
872
+
873
+ // we define observers array only for interpolated attrs
874
+ // and ignore observers for non interpolated attrs to save some memory
875
+ attr . $observers [ name ] = [ ] ;
876
+ attr [ name ] = undefined ;
877
+ scope . $watch ( interpolateFn , function ( value ) {
878
+ attr . $set ( name , value ) ;
879
+ } ) ;
880
+ } )
902
881
} ) ;
903
882
}
904
883
@@ -945,15 +924,12 @@ function $CompileProvider($provide) {
945
924
var booleanKey = isBooleanAttr ( this . $element [ 0 ] , key . toLowerCase ( ) ) ;
946
925
947
926
if ( booleanKey ) {
948
- value = toBoolean ( value ) ;
949
927
this . $element . prop ( key , value ) ;
950
- this [ key ] = value ;
951
- attrName = key = booleanKey ;
952
- value = value ? booleanKey : undefined ;
953
- } else {
954
- this [ key ] = value ;
928
+ attrName = booleanKey ;
955
929
}
956
930
931
+ this [ key ] = value ;
932
+
957
933
// translate normalized key to actual key
958
934
if ( attrName ) {
959
935
this . $attr [ key ] = attrName ;
0 commit comments