Skip to content

Commit

Permalink
refactor(ui5-switch): subscribe event handlers within HBS template (#955
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ignipae authored and ilhan007 committed Nov 21, 2019
1 parent 7cafa78 commit 1a5903e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/main/src/Switch.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
aria-checked="{{checked}}"
aria-disabled="{{ariaDisabled}}"
aria-labelledby="{{_id}}-hiddenText"
@click="{{_onclick}}"
@keyup="{{_onkeyup}}"
@keydown="{{_onkeydown}}"
tabindex="{{tabIndex}}"
dir="{{rtl}}"
>
Expand Down
7 changes: 3 additions & 4 deletions packages/main/src/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ const metadata = {
*/
change: {},
},
_eventHandlersByConvention: true,
};

/**
Expand Down Expand Up @@ -159,11 +158,11 @@ class Switch extends UI5Element {
this.i18nBundle = getI18nBundle("@ui5/webcomponents");
}

onclick(event) {
_onclick(event) {
this.toggle();
}

onkeydown(event) {
_onkeydown(event) {
if (isSpace(event)) {
event.preventDefault();
}
Expand All @@ -173,7 +172,7 @@ class Switch extends UI5Element {
}
}

onkeyup(event) {
_onkeyup(event) {
if (isSpace(event)) {
this.toggle();
}
Expand Down

0 comments on commit 1a5903e

Please sign in to comment.