How to use the aria-query.dom.keys function in aria-query

To help you get started, we’ve selected a few aria-query examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mgechev / codelyzer / src / templateClickEventsHaveKeyEventsRule.ts View on Github external
import { ElementAst } from '@angular/compiler';
import { dom } from 'aria-query';
import { IRuleMetadata, RuleFailure, Rules } from 'tslint/lib';
import { SourceFile } from 'typescript/lib/typescript';
import { NgWalker, NgWalkerConfig } from './angular/ngWalker';
import { BasicTemplateAstVisitor } from './angular/templates/basicTemplateAstVisitor';
import { isHiddenFromScreenReader } from './util/isHiddenFromScreenReader';
import { isInteractiveElement } from './util/isInteractiveElement';
import { isPresentationRole } from './util/isPresentationRole';

const domElements = new Set(dom.keys());

export class Rule extends Rules.AbstractRule {
  static readonly metadata: IRuleMetadata = {
    description: 'Ensures that the click event is accompanied with at least one key event keyup, keydown or keypress',
    options: null,
    optionsDescription: 'Not configurable.',
    rationale: 'Keyboard is important for users with physical disabilities who cannot use mouse.',
    ruleName: 'template-click-events-have-key-events',
    type: 'functionality',
    typescriptOnly: true
  };

  static readonly FAILURE_STRING = 'click must be accompanied by either keyup, keydown or keypress event for accessibility';

  apply(sourceFile: SourceFile): RuleFailure[] {
    const walkerConfig: NgWalkerConfig = { templateVisitorCtrl: TemplateVisitorCtrl };