This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -3841,7 +3841,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
3841
3841
if ( propValue !== undefined ) {
3842
3842
$element . prop ( propName , propValue ) ;
3843
3843
} else {
3844
- delete $element [ 0 ] [ propName ] ;
3844
+ if ( $element . removeProp ) {
3845
+ $element . removeProp ( propName ) ;
3846
+ } else {
3847
+ delete $element [ 0 ] [ propName ] ;
3848
+ }
3845
3849
}
3846
3850
}
3847
3851
Original file line number Diff line number Diff line change @@ -90,6 +90,23 @@ describe('ngProp*', function() {
90
90
expect ( element [ 0 ] . hasOwnProperty ( 'text' ) ) . toBe ( false ) ;
91
91
} ) ) ;
92
92
93
+ // Ensure jQuery prop/removeProp are used to support fix/hooks
94
+ if ( angular . element . prototype . removeProp ) {
95
+ it ( 'should use jQuery.fn.prop() and jQuery.fn.removeProp() to support jQuery.propFix/Hooks' , inject ( function ( $rootScope , $compile ) {
96
+ $compile ( '<span ng-prop-text="myText" />' ) ( $rootScope ) ;
97
+ spyOn ( angular . element . fn , 'prop' ) . and . callThrough ( ) ;
98
+ spyOn ( angular . element . fn , 'removeProp' ) . and . callThrough ( ) ;
99
+
100
+ $rootScope . myText = 'a value' ;
101
+ $rootScope . $digest ( ) ;
102
+ expect ( angular . element . fn . prop ) . toHaveBeenCalledWith ( 'text' , 'a value' ) ;
103
+
104
+ $rootScope . myText = undefined ;
105
+ $rootScope . $digest ( ) ;
106
+ expect ( angular . element . fn . removeProp ) . toHaveBeenCalledWith ( 'text' ) ;
107
+ } ) ) ;
108
+ }
109
+
93
110
it ( 'should support mixed case using underscore-separated names' , inject ( function ( $rootScope , $compile ) {
94
111
var element = $compile ( '<span ng-prop-a_bcd_e="value" />' ) ( $rootScope ) ;
95
112
$rootScope . value = 123 ;
You can’t perform that action at this time.
0 commit comments