source: trip-planner-front/node_modules/@angular/cdk/esm2015/a11y/interactivity-checker/interactivity-checker.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 28.3 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Platform } from '@angular/cdk/platform';
9import { Injectable } from '@angular/core';
10import * as i0 from "@angular/core";
11import * as i1 from "@angular/cdk/platform";
12/**
13 * Configuration for the isFocusable method.
14 */
15export class IsFocusableConfig {
16 constructor() {
17 /**
18 * Whether to count an element as focusable even if it is not currently visible.
19 */
20 this.ignoreVisibility = false;
21 }
22}
23// The InteractivityChecker leans heavily on the ally.js accessibility utilities.
24// Methods like `isTabbable` are only covering specific edge-cases for the browsers which are
25// supported.
26/**
27 * Utility for checking the interactivity of an element, such as whether is is focusable or
28 * tabbable.
29 */
30export class InteractivityChecker {
31 constructor(_platform) {
32 this._platform = _platform;
33 }
34 /**
35 * Gets whether an element is disabled.
36 *
37 * @param element Element to be checked.
38 * @returns Whether the element is disabled.
39 */
40 isDisabled(element) {
41 // This does not capture some cases, such as a non-form control with a disabled attribute or
42 // a form control inside of a disabled form, but should capture the most common cases.
43 return element.hasAttribute('disabled');
44 }
45 /**
46 * Gets whether an element is visible for the purposes of interactivity.
47 *
48 * This will capture states like `display: none` and `visibility: hidden`, but not things like
49 * being clipped by an `overflow: hidden` parent or being outside the viewport.
50 *
51 * @returns Whether the element is visible.
52 */
53 isVisible(element) {
54 return hasGeometry(element) && getComputedStyle(element).visibility === 'visible';
55 }
56 /**
57 * Gets whether an element can be reached via Tab key.
58 * Assumes that the element has already been checked with isFocusable.
59 *
60 * @param element Element to be checked.
61 * @returns Whether the element is tabbable.
62 */
63 isTabbable(element) {
64 // Nothing is tabbable on the server 😎
65 if (!this._platform.isBrowser) {
66 return false;
67 }
68 const frameElement = getFrameElement(getWindow(element));
69 if (frameElement) {
70 // Frame elements inherit their tabindex onto all child elements.
71 if (getTabIndexValue(frameElement) === -1) {
72 return false;
73 }
74 // Browsers disable tabbing to an element inside of an invisible frame.
75 if (!this.isVisible(frameElement)) {
76 return false;
77 }
78 }
79 let nodeName = element.nodeName.toLowerCase();
80 let tabIndexValue = getTabIndexValue(element);
81 if (element.hasAttribute('contenteditable')) {
82 return tabIndexValue !== -1;
83 }
84 if (nodeName === 'iframe' || nodeName === 'object') {
85 // The frame or object's content may be tabbable depending on the content, but it's
86 // not possibly to reliably detect the content of the frames. We always consider such
87 // elements as non-tabbable.
88 return false;
89 }
90 // In iOS, the browser only considers some specific elements as tabbable.
91 if (this._platform.WEBKIT && this._platform.IOS && !isPotentiallyTabbableIOS(element)) {
92 return false;
93 }
94 if (nodeName === 'audio') {
95 // Audio elements without controls enabled are never tabbable, regardless
96 // of the tabindex attribute explicitly being set.
97 if (!element.hasAttribute('controls')) {
98 return false;
99 }
100 // Audio elements with controls are by default tabbable unless the
101 // tabindex attribute is set to `-1` explicitly.
102 return tabIndexValue !== -1;
103 }
104 if (nodeName === 'video') {
105 // For all video elements, if the tabindex attribute is set to `-1`, the video
106 // is not tabbable. Note: We cannot rely on the default `HTMLElement.tabIndex`
107 // property as that one is set to `-1` in Chrome, Edge and Safari v13.1. The
108 // tabindex attribute is the source of truth here.
109 if (tabIndexValue === -1) {
110 return false;
111 }
112 // If the tabindex is explicitly set, and not `-1` (as per check before), the
113 // video element is always tabbable (regardless of whether it has controls or not).
114 if (tabIndexValue !== null) {
115 return true;
116 }
117 // Otherwise (when no explicit tabindex is set), a video is only tabbable if it
118 // has controls enabled. Firefox is special as videos are always tabbable regardless
119 // of whether there are controls or not.
120 return this._platform.FIREFOX || element.hasAttribute('controls');
121 }
122 return element.tabIndex >= 0;
123 }
124 /**
125 * Gets whether an element can be focused by the user.
126 *
127 * @param element Element to be checked.
128 * @param config The config object with options to customize this method's behavior
129 * @returns Whether the element is focusable.
130 */
131 isFocusable(element, config) {
132 // Perform checks in order of left to most expensive.
133 // Again, naive approach that does not capture many edge cases and browser quirks.
134 return isPotentiallyFocusable(element) && !this.isDisabled(element) &&
135 ((config === null || config === void 0 ? void 0 : config.ignoreVisibility) || this.isVisible(element));
136 }
137}
138InteractivityChecker.ɵprov = i0.ɵɵdefineInjectable({ factory: function InteractivityChecker_Factory() { return new InteractivityChecker(i0.ɵɵinject(i1.Platform)); }, token: InteractivityChecker, providedIn: "root" });
139InteractivityChecker.decorators = [
140 { type: Injectable, args: [{ providedIn: 'root' },] }
141];
142InteractivityChecker.ctorParameters = () => [
143 { type: Platform }
144];
145/**
146 * Returns the frame element from a window object. Since browsers like MS Edge throw errors if
147 * the frameElement property is being accessed from a different host address, this property
148 * should be accessed carefully.
149 */
150function getFrameElement(window) {
151 try {
152 return window.frameElement;
153 }
154 catch (_a) {
155 return null;
156 }
157}
158/** Checks whether the specified element has any geometry / rectangles. */
159function hasGeometry(element) {
160 // Use logic from jQuery to check for an invisible element.
161 // See https://github.com/jquery/jquery/blob/master/src/css/hiddenVisibleSelectors.js#L12
162 return !!(element.offsetWidth || element.offsetHeight ||
163 (typeof element.getClientRects === 'function' && element.getClientRects().length));
164}
165/** Gets whether an element's */
166function isNativeFormElement(element) {
167 let nodeName = element.nodeName.toLowerCase();
168 return nodeName === 'input' ||
169 nodeName === 'select' ||
170 nodeName === 'button' ||
171 nodeName === 'textarea';
172}
173/** Gets whether an element is an `<input type="hidden">`. */
174function isHiddenInput(element) {
175 return isInputElement(element) && element.type == 'hidden';
176}
177/** Gets whether an element is an anchor that has an href attribute. */
178function isAnchorWithHref(element) {
179 return isAnchorElement(element) && element.hasAttribute('href');
180}
181/** Gets whether an element is an input element. */
182function isInputElement(element) {
183 return element.nodeName.toLowerCase() == 'input';
184}
185/** Gets whether an element is an anchor element. */
186function isAnchorElement(element) {
187 return element.nodeName.toLowerCase() == 'a';
188}
189/** Gets whether an element has a valid tabindex. */
190function hasValidTabIndex(element) {
191 if (!element.hasAttribute('tabindex') || element.tabIndex === undefined) {
192 return false;
193 }
194 let tabIndex = element.getAttribute('tabindex');
195 // IE11 parses tabindex="" as the value "-32768"
196 if (tabIndex == '-32768') {
197 return false;
198 }
199 return !!(tabIndex && !isNaN(parseInt(tabIndex, 10)));
200}
201/**
202 * Returns the parsed tabindex from the element attributes instead of returning the
203 * evaluated tabindex from the browsers defaults.
204 */
205function getTabIndexValue(element) {
206 if (!hasValidTabIndex(element)) {
207 return null;
208 }
209 // See browser issue in Gecko https://bugzilla.mozilla.org/show_bug.cgi?id=1128054
210 const tabIndex = parseInt(element.getAttribute('tabindex') || '', 10);
211 return isNaN(tabIndex) ? -1 : tabIndex;
212}
213/** Checks whether the specified element is potentially tabbable on iOS */
214function isPotentiallyTabbableIOS(element) {
215 let nodeName = element.nodeName.toLowerCase();
216 let inputType = nodeName === 'input' && element.type;
217 return inputType === 'text'
218 || inputType === 'password'
219 || nodeName === 'select'
220 || nodeName === 'textarea';
221}
222/**
223 * Gets whether an element is potentially focusable without taking current visible/disabled state
224 * into account.
225 */
226function isPotentiallyFocusable(element) {
227 // Inputs are potentially focusable *unless* they're type="hidden".
228 if (isHiddenInput(element)) {
229 return false;
230 }
231 return isNativeFormElement(element) ||
232 isAnchorWithHref(element) ||
233 element.hasAttribute('contenteditable') ||
234 hasValidTabIndex(element);
235}
236/** Gets the parent window of a DOM node with regards of being inside of an iframe. */
237function getWindow(node) {
238 // ownerDocument is null if `node` itself *is* a document.
239 return node.ownerDocument && node.ownerDocument.defaultView || window;
240}
241//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJhY3Rpdml0eS1jaGVja2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2Nkay9hMTF5L2ludGVyYWN0aXZpdHktY2hlY2tlci9pbnRlcmFjdGl2aXR5LWNoZWNrZXIudHMiXSwibmFt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