@@ -128,13 +128,7 @@ function $CompileProvider($provide) {
128128 COMMENT_DIRECTIVE_REGEXP = / ^ \s * d i r e c t i v e \: \s * ( [ \d \w \- _ ] + ) \s + ( .* ) $ / ,
129129 CLASS_DIRECTIVE_REGEXP = / ( ( [ \d \w \- _ ] + ) (?: \: ( [ ^ ; ] + ) ) ? ; ? ) / ,
130130 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 ] * \> $ / ;
138132
139133
140134 this . directive = function registerDirective ( name , directiveFactory ) {
@@ -861,44 +855,29 @@ function $CompileProvider($provide) {
861855
862856
863857 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 ) ;
869859
870- if ( specialAttrDir && isBooleanAttr ( node , name ) ) {
871- value = true ;
872- }
873860
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 ;
878863
879864 directives . push ( {
880865 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 ) ;
900871 }
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+ } )
902881 } ) ;
903882 }
904883
@@ -945,15 +924,12 @@ function $CompileProvider($provide) {
945924 var booleanKey = isBooleanAttr ( this . $element [ 0 ] , key . toLowerCase ( ) ) ;
946925
947926 if ( booleanKey ) {
948- value = toBoolean ( value ) ;
949927 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 ;
955929 }
956930
931+ this [ key ] = value ;
932+
957933 // translate normalized key to actual key
958934 if ( attrName ) {
959935 this . $attr [ key ] = attrName ;
0 commit comments