/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { ENTER, SPACE } from '@angular/cdk/keycodes'; /** Checks whether a keyboard event will trigger a native `click` event on an element. */ export function eventDispatchesNativeClick(elementRef, event) { // Synthetic events won't trigger clicks. if (!event.isTrusted) { return false; } const el = elementRef.nativeElement; const keyCode = event.keyCode; // Buttons trigger clicks both on space and enter events. if (el.nodeName === 'BUTTON' && !el.disabled) { return keyCode === ENTER || keyCode === SPACE; } // Links only trigger clicks on enter. if (el.nodeName === 'A') { return keyCode === ENTER; } // Any other elements won't dispatch clicks from keyboard events. return false; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZlbnQtZGV0ZWN0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2Nkay9tZW51L2V2ZW50LWRldGVjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFHSCxPQUFPLEVBQUMsS0FBSyxFQUFFLEtBQUssRUFBQyxNQUFNLHVCQUF1QixDQUFDO0FBRW5ELHlGQUF5RjtBQUN6RixNQUFNLFVBQVUsMEJBQTBCLENBQ3hDLFVBQW1DLEVBQ25DLEtBQW9CO0lBRXBCLHlDQUF5QztJQUN6QyxJQUFJLENBQUMsS0FBSyxDQUFDLFNBQVMsRUFBRTtRQUNwQixPQUFPLEtBQUssQ0FBQztLQUNkO0lBRUQsTUFBTSxFQUFFLEdBQUcsVUFBVSxDQUFDLGFBQWEsQ0FBQztJQUNwQyxNQUFNLE9BQU8sR0FBRyxLQUFLLENBQUMsT0FBTyxDQUFDO0lBRTlCLHlEQUF5RDtJQUN6RCxJQUFJLEVBQUUsQ0FBQyxRQUFRLEtBQUssUUFBUSxJQUFJLENBQUUsRUFBd0IsQ0FBQyxRQUFRLEVBQUU7UU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