Skip to content

Commit 0eb219f

Browse files
committed
fix lint on es-button
1 parent 6dec76c commit 0eb219f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

addon/components/es-button.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import Component from '@glimmer/component';
2+
import { action } from '@ember/object';
23

34
export default class EsButtonComponent extends Component {
45
// default value
56
_onClicked = () => {};
7+
_type = "button";
68

79
constructor() {
810
super(...arguments);
@@ -14,8 +16,16 @@ export default class EsButtonComponent extends Component {
1416
} else {
1517
this._onClicked = this.args.onClicked;
1618
}
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+
}
1726
}
1827

28+
@action
1929
buttonClicked() {
2030
this._onClicked();
2131
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<button
22
class={{if @secondary "es-button-secondary" "es-button"}}
33
aria-label={{@label}}
4-
onclick={{action this.buttonClicked}}
4+
type={{this._type}}
55
...attributes
6+
{{on "click" this.buttonClicked}}
67
>
78
{{#if hasBlock}}
89
{{yield}}
910
{{else}}
1011
{{@label}}
1112
{{/if}}
12-
</button>
13+
</button>

0 commit comments

Comments
 (0)