File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 1
1
import Component from '@glimmer/component' ;
2
+ import { action } from '@ember/object' ;
2
3
3
4
export default class EsButtonComponent extends Component {
4
5
// default value
5
6
_onClicked = ( ) => { } ;
7
+ _type = "button" ;
6
8
7
9
constructor ( ) {
8
10
super ( ...arguments ) ;
@@ -14,8 +16,16 @@ export default class EsButtonComponent extends Component {
14
16
} else {
15
17
this . _onClicked = this . args . onClicked ;
16
18
}
19
+
20
+ if ( ! this . args . type ) {
21
+ // eslint-disable-next-line no-console
22
+ console . warn ( new Error ( 'Button created with no @type defined - defaulting to `type="button"`' ) ) ;
23
+ } else {
24
+ this . _type = this . args . type ;
25
+ }
17
26
}
18
27
28
+ @action
19
29
buttonClicked ( ) {
20
30
this . _onClicked ( ) ;
21
31
}
Original file line number Diff line number Diff line change 1
1
<button
2
2
class ={{ if @secondary " es-button-secondary" " es-button" }}
3
3
aria-label ={{ @label }}
4
- onclick ={{ action this.buttonClicked }}
4
+ type ={{ this._type }}
5
5
...attributes
6
+ {{ on " click" this.buttonClicked }}
6
7
>
7
8
{{ #if hasBlock }}
8
9
{{ yield }}
9
10
{{ else }}
10
11
{{ @label }}
11
12
{{ /if }}
12
- </button >
13
+ </button >
You can’t perform that action at this time.
0 commit comments