File tree Expand file tree Collapse file tree 2 files changed +2
-14
lines changed
1820EN_09_Code/02_button_directive Expand file tree Collapse file tree 2 files changed +2
-14
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,8 @@ angular.module('button-directive', [])
5
5
restrict : 'E' ,
6
6
compile : function ( element , attributes ) {
7
7
element . addClass ( 'btn' ) ;
8
- if ( attributes . type === 'submit' || attributes . type === "primary" ) {
9
- attributes . $set ( 'type' , 'submit' ) ;
8
+ if ( attributes . type === 'submit' ) {
10
9
element . addClass ( 'btn-primary' ) ;
11
- } else if ( angular . isDefined ( attributes . type ) && attributes . type !== 'reset' ) {
12
- element . addClass ( 'btn-' + attributes . type ) ;
13
- attributes . $set ( 'type' , 'button' ) ;
14
10
}
15
11
if ( attributes . size ) {
16
12
element . addClass ( 'btn-' + attributes . size ) ;
Original file line number Diff line number Diff line change @@ -21,17 +21,9 @@ describe('button directive', function () {
21
21
expect ( element . hasClass ( 'btn-large' ) ) . toBe ( true ) ;
22
22
} ) ;
23
23
24
- it ( 'set button type and CSS classes correctly ' , function ( ) {
24
+ it ( 'adds primary class to submit buttons ' , function ( ) {
25
25
var element = $compile ( '<button type="submit"></button>' ) ( $rootScope ) ;
26
26
expect ( element . hasClass ( 'btn-primary' ) ) . toBe ( true ) ;
27
- expect ( element . attr ( 'type' ) ) . toBe ( 'submit' ) ;
28
-
29
- element = $compile ( '<button type="reset"></button>' ) ( $rootScope ) ;
30
- expect ( element . attr ( 'type' ) ) . toBe ( 'reset' ) ;
31
-
32
- element = $compile ( '<button type="warning"> </button>' ) ( $rootScope ) ;
33
- expect ( element . hasClass ( 'btn-warning' ) ) . toBe ( true ) ;
34
- expect ( element . attr ( 'type' ) ) . toBe ( 'button' ) ;
35
27
} ) ;
36
28
37
29
} ) ;
You can’t perform that action at this time.
0 commit comments