Skip to content

Commit

Permalink
fix(rule): template-click-events-have-key-events - support pseudo eve…
Browse files Browse the repository at this point in the history
…nts (#893)
  • Loading branch information
mohammedzamakhan authored and mgechev committed Sep 19, 2019
1 parent 5a80e90 commit 5b57bd6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/templateClickEventsHaveKeyEventsRule.ts
Expand Up @@ -56,8 +56,9 @@ class TemplateVisitorCtrl extends BasicTemplateAstVisitor {
if (isInteractiveElement(el)) {
return;
}

const hasKeyEvent = el.outputs.some(output => output.name === 'keyup' || output.name === 'keydown' || output.name === 'keypress');
const hasKeyEvent = el.outputs.some(
output => output.name.startsWith('keyup') || output.name.startsWith('keydown') || output.name.startsWith('keypress')
);

if (hasKeyEvent) {
return;
Expand Down
12 changes: 12 additions & 0 deletions test/templateClickEventsHaveKeyEventsRule.spec.ts
Expand Up @@ -158,6 +158,18 @@ describe(ruleName, () => {
assertSuccess(ruleName, source);
});

it('should work when click events are associated with key pseudo events', () => {
const source = `
@Component({
template: \`
<div (click)="onClick()" (keyup.enter)="onKeyup()"></div>
\`
})
class Bar {}
`;
assertSuccess(ruleName, source);
});

it('should work when click events are passed to custom element', () => {
const source = `
@Component({
Expand Down

0 comments on commit 5b57bd6

Please sign in to comment.