@angular/cdk 9.1.3 → 9.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/focus-monitor/focus-monitor.d.ts +43 -4
- package/a11y/high-contrast-mode/high-contrast-mode-detector.d.ts +2 -2
- package/a11y/index.metadata.json +1 -1
- package/bundles/cdk-a11y.umd.js +140 -90
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +14 -7
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-coercion.umd.js +0 -1
- package/bundles/cdk-coercion.umd.js.map +1 -1
- package/bundles/cdk-coercion.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +292 -179
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +23 -9
- package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
- package/bundles/cdk-overlay.umd.js.map +1 -1
- package/bundles/cdk-platform.umd.js +3 -1
- package/bundles/cdk-platform.umd.js.map +1 -1
- package/bundles/cdk-platform.umd.min.js +4 -4
- package/bundles/cdk-platform.umd.min.js.map +1 -1
- package/bundles/cdk-scrolling.umd.js +18 -3
- package/bundles/cdk-scrolling.umd.js.map +1 -1
- package/bundles/cdk-scrolling.umd.min.js +2 -2
- package/bundles/cdk-scrolling.umd.min.js.map +1 -1
- package/bundles/cdk-table.umd.js +58 -27
- package/bundles/cdk-table.umd.js.map +1 -1
- package/bundles/cdk-table.umd.min.js +12 -5
- package/bundles/cdk-table.umd.min.js.map +1 -1
- package/bundles/cdk-testing-protractor.umd.js +15 -9
- package/bundles/cdk-testing-protractor.umd.js.map +1 -1
- package/bundles/cdk-testing-protractor.umd.min.js +2 -2
- package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
- package/bundles/cdk-testing-testbed.umd.js +77 -19
- package/bundles/cdk-testing-testbed.umd.js.map +1 -1
- package/bundles/cdk-testing-testbed.umd.min.js +8 -8
- package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
- package/bundles/cdk-tree.umd.js +9 -4
- package/bundles/cdk-tree.umd.js.map +1 -1
- package/bundles/cdk-tree.umd.min.js +1 -1
- package/bundles/cdk-tree.umd.min.js.map +1 -1
- package/bundles/cdk.umd.js +1 -1
- package/bundles/cdk.umd.js.map +1 -1
- package/bundles/cdk.umd.min.js +1 -1
- package/bundles/cdk.umd.min.js.map +1 -1
- package/coercion/array.d.ts +1 -0
- package/drag-drop/client-rect.d.ts +31 -0
- package/drag-drop/directives/config.d.ts +1 -0
- package/drag-drop/directives/drop-list.d.ts +4 -3
- package/drag-drop/drag-ref.d.ts +8 -2
- package/drag-drop/drop-list-ref.d.ts +9 -8
- package/drag-drop/index.metadata.json +1 -1
- package/drag-drop/parent-position-tracker.d.ts +31 -0
- package/drag-drop/public-api.d.ts +1 -1
- package/esm2015/a11y/aria-describer/aria-reference.js +6 -6
- package/esm2015/a11y/focus-monitor/focus-monitor.js +198 -92
- package/esm2015/a11y/focus-trap/configurable-focus-trap-factory.js +3 -3
- package/esm2015/a11y/focus-trap/focus-trap.js +1 -1
- package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +10 -6
- package/esm2015/a11y/live-announcer/live-announcer.js +1 -1
- package/esm2015/a11y/public-api.js +2 -2
- package/esm2015/coercion/array.js +1 -2
- package/esm2015/drag-drop/client-rect.js +75 -0
- package/esm2015/drag-drop/directives/config.js +3 -1
- package/esm2015/drag-drop/directives/drag.js +3 -2
- package/esm2015/drag-drop/directives/drop-list.js +24 -18
- package/esm2015/drag-drop/drag-drop-module.js +3 -1
- package/esm2015/drag-drop/drag-ref.js +97 -43
- package/esm2015/drag-drop/drop-list-ref.js +119 -187
- package/esm2015/drag-drop/parent-position-tracker.js +141 -0
- package/esm2015/drag-drop/public-api.js +1 -1
- package/esm2015/overlay/position/flexible-connected-position-strategy.js +1 -1
- package/esm2015/platform/features/shadow-dom.js +4 -2
- package/esm2015/scrolling/public-api.js +2 -2
- package/esm2015/scrolling/scrolling-module.js +15 -4
- package/esm2015/table/cell.js +18 -8
- package/esm2015/table/public-api.js +3 -2
- package/esm2015/table/row.js +24 -8
- package/esm2015/table/table.js +26 -12
- package/esm2015/table/text-column.js +3 -26
- package/esm2015/table/tokens.js +44 -0
- package/esm2015/testing/protractor/protractor-harness-environment.js +13 -8
- package/esm2015/testing/testbed/fake-events/dispatch-events.js +11 -4
- package/esm2015/testing/testbed/fake-events/event-objects.js +37 -3
- package/esm2015/testing/testbed/testbed-harness-environment.js +16 -10
- package/esm2015/testing/testbed/unit-test-element.js +13 -2
- package/esm2015/tree/padding.js +9 -10
- package/esm2015/tree/tree.js +2 -1
- package/esm2015/version.js +1 -1
- package/esm5/a11y/aria-describer/aria-reference.js +6 -6
- package/esm5/a11y/focus-monitor/focus-monitor.js +112 -65
- package/esm5/a11y/high-contrast-mode/high-contrast-mode-detector.js +9 -6
- package/esm5/coercion/array.js +1 -2
- package/esm5/drag-drop/client-rect.js +60 -0
- package/esm5/drag-drop/directives/config.js +1 -1
- package/esm5/drag-drop/directives/drag.js +3 -2
- package/esm5/drag-drop/directives/drop-list.js +13 -10
- package/esm5/drag-drop/drag-drop-module.js +3 -1
- package/esm5/drag-drop/drag-ref.js +62 -33
- package/esm5/drag-drop/drop-list-ref.js +89 -139
- package/esm5/drag-drop/parent-position-tracker.js +74 -0
- package/esm5/drag-drop/public-api.js +1 -1
- package/esm5/overlay/position/flexible-connected-position-strategy.js +1 -1
- package/esm5/platform/features/shadow-dom.js +4 -2
- package/esm5/scrolling/scrolling-module.js +19 -4
- package/esm5/table/cell.js +13 -8
- package/esm5/table/public-api.js +2 -1
- package/esm5/table/row.js +21 -11
- package/esm5/table/table.js +16 -11
- package/esm5/table/text-column.js +3 -4
- package/esm5/table/tokens.js +16 -0
- package/esm5/testing/protractor/protractor-harness-environment.js +17 -11
- package/esm5/testing/testbed/fake-events/dispatch-events.js +15 -7
- package/esm5/testing/testbed/fake-events/event-objects.js +43 -5
- package/esm5/testing/testbed/testbed-harness-environment.js +17 -11
- package/esm5/testing/testbed/unit-test-element.js +10 -3
- package/esm5/tree/padding.js +9 -5
- package/esm5/tree/tree.js +2 -1
- package/esm5/version.js +1 -1
- package/fesm2015/a11y.js +234 -126
- package/fesm2015/a11y.js.map +1 -1
- package/fesm2015/cdk.js +1 -1
- package/fesm2015/cdk.js.map +1 -1
- package/fesm2015/coercion.js +0 -1
- package/fesm2015/coercion.js.map +1 -1
- package/fesm2015/drag-drop.js +448 -247
- package/fesm2015/drag-drop.js.map +1 -1
- package/fesm2015/overlay.js.map +1 -1
- package/fesm2015/platform.js +3 -1
- package/fesm2015/platform.js.map +1 -1
- package/fesm2015/scrolling.js +15 -4
- package/fesm2015/scrolling.js.map +1 -1
- package/fesm2015/table.js +98 -49
- package/fesm2015/table.js.map +1 -1
- package/fesm2015/testing/protractor.js +13 -8
- package/fesm2015/testing/protractor.js.map +1 -1
- package/fesm2015/testing/testbed.js +71 -13
- package/fesm2015/testing/testbed.js.map +1 -1
- package/fesm2015/tree.js +9 -9
- package/fesm2015/tree.js.map +1 -1
- package/fesm5/a11y.js +141 -92
- package/fesm5/a11y.js.map +1 -1
- package/fesm5/cdk.js +1 -1
- package/fesm5/cdk.js.map +1 -1
- package/fesm5/coercion.js +0 -1
- package/fesm5/coercion.js.map +1 -1
- package/fesm5/drag-drop.js +294 -181
- package/fesm5/drag-drop.js.map +1 -1
- package/fesm5/overlay.js.map +1 -1
- package/fesm5/platform.js +3 -1
- package/fesm5/platform.js.map +1 -1
- package/fesm5/scrolling.js +18 -4
- package/fesm5/scrolling.js.map +1 -1
- package/fesm5/table.js +59 -29
- package/fesm5/table.js.map +1 -1
- package/fesm5/testing/protractor.js +17 -11
- package/fesm5/testing/protractor.js.map +1 -1
- package/fesm5/testing/testbed.js +78 -20
- package/fesm5/testing/testbed.js.map +1 -1
- package/fesm5/tree.js +9 -4
- package/fesm5/tree.js.map +1 -1
- package/overlay/position/flexible-connected-position-strategy.d.ts +1 -1
- package/package.json +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-update/devkit-file-system.d.ts +29 -0
- package/schematics/ng-update/devkit-file-system.js +67 -0
- package/schematics/ng-update/devkit-migration-rule.d.ts +25 -0
- package/schematics/ng-update/devkit-migration-rule.js +152 -0
- package/schematics/ng-update/devkit-migration.d.ts +37 -0
- package/schematics/ng-update/devkit-migration.js +29 -0
- package/schematics/ng-update/index.js +7 -7
- package/schematics/ng-update/{upgrade-rules/attribute-selectors-rule.d.ts → migrations/attribute-selectors.d.ts} +6 -6
- package/schematics/ng-update/migrations/attribute-selectors.js +76 -0
- package/schematics/ng-update/{upgrade-rules/class-inheritance-rule.d.ts → migrations/class-inheritance.d.ts} +6 -6
- package/schematics/ng-update/migrations/class-inheritance.js +67 -0
- package/schematics/ng-update/{upgrade-rules/class-names-rule.d.ts → migrations/class-names.d.ts} +6 -6
- package/schematics/ng-update/migrations/class-names.js +98 -0
- package/schematics/ng-update/{upgrade-rules/constructor-signature-rule.d.ts → migrations/constructor-signature.d.ts} +6 -6
- package/schematics/ng-update/migrations/constructor-signature.js +144 -0
- package/schematics/ng-update/{upgrade-rules/css-selectors-rule.d.ts → migrations/css-selectors.d.ts} +6 -6
- package/schematics/ng-update/migrations/css-selectors.js +83 -0
- package/schematics/ng-update/{upgrade-rules/element-selectors-rule.d.ts → migrations/element-selectors.d.ts} +6 -6
- package/schematics/ng-update/migrations/element-selectors.js +74 -0
- package/schematics/ng-update/{upgrade-rules/input-names-rule.d.ts → migrations/input-names.d.ts} +6 -6
- package/schematics/ng-update/migrations/input-names.js +69 -0
- package/schematics/ng-update/{upgrade-rules/method-call-arguments-rule.d.ts → migrations/method-call-arguments.d.ts} +6 -6
- package/schematics/ng-update/migrations/method-call-arguments.js +70 -0
- package/schematics/ng-update/{upgrade-rules/misc-template-rule.d.ts → migrations/misc-template.d.ts} +6 -6
- package/schematics/ng-update/migrations/misc-template.js +47 -0
- package/schematics/ng-update/{upgrade-rules/output-names-rule.d.ts → migrations/output-names.d.ts} +6 -6
- package/schematics/ng-update/migrations/output-names.js +56 -0
- package/schematics/ng-update/{upgrade-rules/property-names-rule.d.ts → migrations/property-names.d.ts} +6 -6
- package/schematics/ng-update/migrations/property-names.js +56 -0
- package/schematics/ng-update/public-api.d.ts +3 -2
- package/schematics/ng-update/public-api.js +5 -4
- package/schematics/ng-update/upgrade-data.d.ts +7 -8
- package/schematics/ng-update/upgrade-data.js +6 -7
- package/schematics/update-tool/component-resource-collector.d.ts +3 -1
- package/schematics/update-tool/component-resource-collector.js +8 -8
- package/schematics/update-tool/file-system.d.ts +38 -0
- package/schematics/update-tool/file-system.js +20 -0
- package/schematics/update-tool/index.d.ts +41 -11
- package/schematics/update-tool/index.js +135 -106
- package/schematics/update-tool/logger.d.ts +16 -0
- package/schematics/update-tool/logger.js +27 -0
- package/schematics/update-tool/{migration-rule.d.ts → migration.d.ts} +23 -45
- package/schematics/update-tool/migration.js +76 -0
- package/schematics/update-tool/public-api.d.ts +5 -4
- package/schematics/update-tool/public-api.js +6 -6
- package/schematics/update-tool/update-recorder.d.ts +14 -0
- package/schematics/update-tool/update-recorder.js +20 -0
- package/schematics/update-tool/utils/parse-tsconfig.js +1 -1
- package/schematics/update-tool/version-changes.js +3 -4
- package/schematics/utils/ast/ng-module-imports.js +3 -2
- package/scrolling/index.metadata.json +1 -1
- package/scrolling/scrolling-module.d.ts +2 -0
- package/table/cell.d.ts +2 -0
- package/table/index.metadata.json +1 -1
- package/table/public-api.d.ts +1 -0
- package/table/row.d.ts +6 -3
- package/table/table.d.ts +2 -0
- package/table/text-column.d.ts +2 -13
- package/table/tokens.d.ts +25 -0
- package/testing/protractor/protractor-harness-environment.d.ts +10 -3
- package/testing/testbed/fake-events/dispatch-events.d.ts +8 -3
- package/testing/testbed/fake-events/event-objects.d.ts +12 -1
- package/testing/testbed/testbed-harness-environment.d.ts +12 -4
- package/tree/index.metadata.json +1 -1
- package/tree/padding.d.ts +6 -2
- package/schematics/ng-update/upgrade-rules/attribute-selectors-rule.js +0 -76
- package/schematics/ng-update/upgrade-rules/class-inheritance-rule.js +0 -67
- package/schematics/ng-update/upgrade-rules/class-names-rule.js +0 -96
- package/schematics/ng-update/upgrade-rules/constructor-signature-rule.js +0 -144
- package/schematics/ng-update/upgrade-rules/css-selectors-rule.js +0 -83
- package/schematics/ng-update/upgrade-rules/element-selectors-rule.js +0 -74
- package/schematics/ng-update/upgrade-rules/index.d.ts +0 -22
- package/schematics/ng-update/upgrade-rules/index.js +0 -116
- package/schematics/ng-update/upgrade-rules/input-names-rule.js +0 -69
- package/schematics/ng-update/upgrade-rules/method-call-arguments-rule.js +0 -70
- package/schematics/ng-update/upgrade-rules/misc-template-rule.js +0 -47
- package/schematics/ng-update/upgrade-rules/output-names-rule.js +0 -56
- package/schematics/ng-update/upgrade-rules/property-names-rule.js +0 -56
- package/schematics/update-tool/migration-rule.js +0 -101
package/fesm2015/a11y.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Subject, Subscription, of } from 'rxjs';
|
|
|
4
4
|
import { hasModifierKey, A, Z, ZERO, NINE, LEFT_ARROW, RIGHT_ARROW, UP_ARROW, DOWN_ARROW, TAB } from '@angular/cdk/keycodes';
|
|
5
5
|
import { tap, debounceTime, filter, map, take } from 'rxjs/operators';
|
|
6
6
|
import { coerceBooleanProperty, coerceElement } from '@angular/cdk/coercion';
|
|
7
|
-
import { Platform, normalizePassiveListenerOptions, PlatformModule } from '@angular/cdk/platform';
|
|
7
|
+
import { Platform, normalizePassiveListenerOptions, _getShadowRoot, PlatformModule } from '@angular/cdk/platform';
|
|
8
8
|
import { ContentObserver, ObserversModule } from '@angular/cdk/observers';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -20,10 +20,10 @@ import { ContentObserver, ObserversModule } from '@angular/cdk/observers';
|
|
|
20
20
|
* found in the LICENSE file at https://angular.io/license
|
|
21
21
|
*/
|
|
22
22
|
/**
|
|
23
|
-
* IDs are
|
|
23
|
+
* IDs are delimited by an empty space, as per the spec.
|
|
24
24
|
* @type {?}
|
|
25
25
|
*/
|
|
26
|
-
const
|
|
26
|
+
const ID_DELIMITER = ' ';
|
|
27
27
|
/**
|
|
28
28
|
* Adds the given ID to the specified ARIA attribute on an element.
|
|
29
29
|
* Used for attributes such as aria-labelledby, aria-owns, etc.
|
|
@@ -43,7 +43,7 @@ function addAriaReferencedId(el, attr, id) {
|
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
ids.push(id.trim());
|
|
46
|
-
el.setAttribute(attr, ids.join(
|
|
46
|
+
el.setAttribute(attr, ids.join(ID_DELIMITER));
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Removes the given ID from the specified ARIA attribute on an element.
|
|
@@ -63,7 +63,7 @@ function removeAriaReferencedId(el, attr, id) {
|
|
|
63
63
|
*/
|
|
64
64
|
val => val != id.trim()));
|
|
65
65
|
if (filteredIds.length) {
|
|
66
|
-
el.setAttribute(attr, filteredIds.join(
|
|
66
|
+
el.setAttribute(attr, filteredIds.join(ID_DELIMITER));
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
69
|
el.removeAttribute(attr);
|
|
@@ -77,7 +77,7 @@ function removeAriaReferencedId(el, attr, id) {
|
|
|
77
77
|
* @return {?}
|
|
78
78
|
*/
|
|
79
79
|
function getAriaReferenceIds(el, attr) {
|
|
80
|
-
// Get string array of all individual ids (whitespace
|
|
80
|
+
// Get string array of all individual ids (whitespace delimited) in the attribute value
|
|
81
81
|
return (el.getAttribute(attr) || '').match(/\S+/g) || [];
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -2653,6 +2653,31 @@ if (false) {
|
|
|
2653
2653
|
CdkAriaLive.prototype._ngZone;
|
|
2654
2654
|
}
|
|
2655
2655
|
|
|
2656
|
+
/**
|
|
2657
|
+
* @fileoverview added by tsickle
|
|
2658
|
+
* Generated from: src/cdk/a11y/fake-mousedown.ts
|
|
2659
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2660
|
+
*/
|
|
2661
|
+
/**
|
|
2662
|
+
* @license
|
|
2663
|
+
* Copyright Google LLC All Rights Reserved.
|
|
2664
|
+
*
|
|
2665
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
2666
|
+
* found in the LICENSE file at https://angular.io/license
|
|
2667
|
+
*/
|
|
2668
|
+
/**
|
|
2669
|
+
* Screenreaders will often fire fake mousedown events when a focusable element
|
|
2670
|
+
* is activated using the keyboard. We can typically distinguish between these faked
|
|
2671
|
+
* mousedown events and real mousedown events using the "buttons" property. While
|
|
2672
|
+
* real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
|
|
2673
|
+
* the left mouse button), faked mousedowns will usually set the property value to 0.
|
|
2674
|
+
* @param {?} event
|
|
2675
|
+
* @return {?}
|
|
2676
|
+
*/
|
|
2677
|
+
function isFakeMousedownFromScreenReader(event) {
|
|
2678
|
+
return event.buttons === 0;
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2656
2681
|
/**
|
|
2657
2682
|
* @fileoverview added by tsickle
|
|
2658
2683
|
* Generated from: src/cdk/a11y/focus-monitor/focus-monitor.ts
|
|
@@ -2675,6 +2700,34 @@ if (false) {
|
|
|
2675
2700
|
*/
|
|
2676
2701
|
FocusOptions.prototype.preventScroll;
|
|
2677
2702
|
}
|
|
2703
|
+
/** @enum {number} */
|
|
2704
|
+
const FocusMonitorDetectionMode = {
|
|
2705
|
+
/**
|
|
2706
|
+
* Any mousedown, keydown, or touchstart event that happened in the previous
|
|
2707
|
+
* tick or the current tick will be used to assign a focus event's origin (to
|
|
2708
|
+
* either mouse, keyboard, or touch). This is the default option.
|
|
2709
|
+
*/
|
|
2710
|
+
IMMEDIATE: 0,
|
|
2711
|
+
/**
|
|
2712
|
+
* A focus event's origin is always attributed to the last corresponding
|
|
2713
|
+
* mousedown, keydown, or touchstart event, no matter how long ago it occured.
|
|
2714
|
+
*/
|
|
2715
|
+
EVENTUAL: 1,
|
|
2716
|
+
};
|
|
2717
|
+
/**
|
|
2718
|
+
* Injectable service-level options for FocusMonitor.
|
|
2719
|
+
* @record
|
|
2720
|
+
*/
|
|
2721
|
+
function FocusMonitorOptions() { }
|
|
2722
|
+
if (false) {
|
|
2723
|
+
/** @type {?|undefined} */
|
|
2724
|
+
FocusMonitorOptions.prototype.detectionMode;
|
|
2725
|
+
}
|
|
2726
|
+
/**
|
|
2727
|
+
* InjectionToken for FocusMonitorOptions.
|
|
2728
|
+
* @type {?}
|
|
2729
|
+
*/
|
|
2730
|
+
const FOCUS_MONITOR_DEFAULT_OPTIONS = new InjectionToken('cdk-focus-monitor-default-options');
|
|
2678
2731
|
/**
|
|
2679
2732
|
* Event listener options that enable capturing and also
|
|
2680
2733
|
* mark the listener as passive if the browser supports it.
|
|
@@ -2691,11 +2744,12 @@ class FocusMonitor {
|
|
|
2691
2744
|
/**
|
|
2692
2745
|
* @param {?} _ngZone
|
|
2693
2746
|
* @param {?} _platform
|
|
2694
|
-
* @param {
|
|
2747
|
+
* @param {?} document
|
|
2748
|
+
* @param {?} options
|
|
2695
2749
|
*/
|
|
2696
2750
|
constructor(_ngZone, _platform,
|
|
2697
2751
|
/** @breaking-change 11.0.0 make document required */
|
|
2698
|
-
document) {
|
|
2752
|
+
document, options) {
|
|
2699
2753
|
this._ngZone = _ngZone;
|
|
2700
2754
|
this._platform = _platform;
|
|
2701
2755
|
/**
|
|
@@ -2714,6 +2768,13 @@ class FocusMonitor {
|
|
|
2714
2768
|
* The number of elements currently being monitored.
|
|
2715
2769
|
*/
|
|
2716
2770
|
this._monitoredElementCount = 0;
|
|
2771
|
+
/**
|
|
2772
|
+
* Keeps track of the root nodes to which we've currently bound a focus/blur handler,
|
|
2773
|
+
* as well as the number of monitored elements that they contain. We have to treat focus/blur
|
|
2774
|
+
* handlers differently from the rest of the events, because the browser won't emit events
|
|
2775
|
+
* to the document when focus moves inside of a shadow root.
|
|
2776
|
+
*/
|
|
2777
|
+
this._rootNodeFocusListenerCount = new Map();
|
|
2717
2778
|
/**
|
|
2718
2779
|
* Event listener for `keydown` events on the document.
|
|
2719
2780
|
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
@@ -2731,13 +2792,18 @@ class FocusMonitor {
|
|
|
2731
2792
|
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
2732
2793
|
*/
|
|
2733
2794
|
this._documentMousedownListener = (/**
|
|
2795
|
+
* @param {?} event
|
|
2734
2796
|
* @return {?}
|
|
2735
2797
|
*/
|
|
2736
|
-
() => {
|
|
2798
|
+
(event) => {
|
|
2737
2799
|
// On mousedown record the origin only if there is not touch
|
|
2738
2800
|
// target, since a mousedown can happen as a result of a touch event.
|
|
2739
2801
|
if (!this._lastTouchTarget) {
|
|
2740
|
-
|
|
2802
|
+
// In some cases screen readers fire fake `mousedown` events instead of `keydown`.
|
|
2803
|
+
// Resolve the focus source to `keyboard` if we detect one of them.
|
|
2804
|
+
/** @type {?} */
|
|
2805
|
+
const source = isFakeMousedownFromScreenReader(event) ? 'keyboard' : 'mouse';
|
|
2806
|
+
this._setOriginForCurrentEventQueue(source);
|
|
2741
2807
|
}
|
|
2742
2808
|
});
|
|
2743
2809
|
/**
|
|
@@ -2755,10 +2821,7 @@ class FocusMonitor {
|
|
|
2755
2821
|
if (this._touchTimeoutId != null) {
|
|
2756
2822
|
clearTimeout(this._touchTimeoutId);
|
|
2757
2823
|
}
|
|
2758
|
-
|
|
2759
|
-
// will have their `target` set to the shadow root. If available, use `composedPath` to
|
|
2760
|
-
// figure out the event target.
|
|
2761
|
-
this._lastTouchTarget = event.composedPath ? event.composedPath()[0] : event.target;
|
|
2824
|
+
this._lastTouchTarget = getTarget(event);
|
|
2762
2825
|
this._touchTimeoutId = setTimeout((/**
|
|
2763
2826
|
* @return {?}
|
|
2764
2827
|
*/
|
|
@@ -2780,7 +2843,26 @@ class FocusMonitor {
|
|
|
2780
2843
|
*/
|
|
2781
2844
|
() => this._windowFocused = false));
|
|
2782
2845
|
});
|
|
2846
|
+
/**
|
|
2847
|
+
* Event listener for `focus` and 'blur' events on the document.
|
|
2848
|
+
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
2849
|
+
*/
|
|
2850
|
+
this._rootNodeFocusAndBlurListener = (/**
|
|
2851
|
+
* @param {?} event
|
|
2852
|
+
* @return {?}
|
|
2853
|
+
*/
|
|
2854
|
+
(event) => {
|
|
2855
|
+
/** @type {?} */
|
|
2856
|
+
const target = getTarget(event);
|
|
2857
|
+
/** @type {?} */
|
|
2858
|
+
const handler = event.type === 'focus' ? this._onFocus : this._onBlur;
|
|
2859
|
+
// We need to walk up the ancestor chain in order to support `checkChildren`.
|
|
2860
|
+
for (let element = target; element; element = element.parentElement) {
|
|
2861
|
+
handler.call(this, (/** @type {?} */ (event)), element);
|
|
2862
|
+
}
|
|
2863
|
+
});
|
|
2783
2864
|
this._document = document;
|
|
2865
|
+
this._detectionMode = (options === null || options === void 0 ? void 0 : options.detectionMode) || 0 /* IMMEDIATE */;
|
|
2784
2866
|
}
|
|
2785
2867
|
/**
|
|
2786
2868
|
* @param {?} element
|
|
@@ -2794,53 +2876,27 @@ class FocusMonitor {
|
|
|
2794
2876
|
}
|
|
2795
2877
|
/** @type {?} */
|
|
2796
2878
|
const nativeElement = coerceElement(element);
|
|
2879
|
+
// If the element is inside the shadow DOM, we need to bind our focus/blur listeners to
|
|
2880
|
+
// the shadow root, rather than the `document`, because the browser won't emit focus events
|
|
2881
|
+
// to the `document`, if focus is moving within the same shadow root.
|
|
2882
|
+
/** @type {?} */
|
|
2883
|
+
const rootNode = ((/** @type {?} */ (_getShadowRoot(nativeElement)))) || this._getDocument();
|
|
2797
2884
|
// Check if we're already monitoring this element.
|
|
2798
2885
|
if (this._elementInfo.has(nativeElement)) {
|
|
2799
2886
|
/** @type {?} */
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
return
|
|
2887
|
+
const cachedInfo = (/** @type {?} */ (this._elementInfo.get(nativeElement)));
|
|
2888
|
+
cachedInfo.checkChildren = checkChildren;
|
|
2889
|
+
return cachedInfo.subject.asObservable();
|
|
2803
2890
|
}
|
|
2804
2891
|
// Create monitored element info.
|
|
2805
2892
|
/** @type {?} */
|
|
2806
|
-
|
|
2807
|
-
unlisten: (/**
|
|
2808
|
-
* @return {?}
|
|
2809
|
-
*/
|
|
2810
|
-
() => { }),
|
|
2893
|
+
const info = {
|
|
2811
2894
|
checkChildren: checkChildren,
|
|
2812
|
-
subject: new Subject()
|
|
2895
|
+
subject: new Subject(),
|
|
2896
|
+
rootNode
|
|
2813
2897
|
};
|
|
2814
2898
|
this._elementInfo.set(nativeElement, info);
|
|
2815
|
-
this.
|
|
2816
|
-
// Start listening. We need to listen in capture phase since focus events don't bubble.
|
|
2817
|
-
/** @type {?} */
|
|
2818
|
-
let focusListener = (/**
|
|
2819
|
-
* @param {?} event
|
|
2820
|
-
* @return {?}
|
|
2821
|
-
*/
|
|
2822
|
-
(event) => this._onFocus(event, nativeElement));
|
|
2823
|
-
/** @type {?} */
|
|
2824
|
-
let blurListener = (/**
|
|
2825
|
-
* @param {?} event
|
|
2826
|
-
* @return {?}
|
|
2827
|
-
*/
|
|
2828
|
-
(event) => this._onBlur(event, nativeElement));
|
|
2829
|
-
this._ngZone.runOutsideAngular((/**
|
|
2830
|
-
* @return {?}
|
|
2831
|
-
*/
|
|
2832
|
-
() => {
|
|
2833
|
-
nativeElement.addEventListener('focus', focusListener, true);
|
|
2834
|
-
nativeElement.addEventListener('blur', blurListener, true);
|
|
2835
|
-
}));
|
|
2836
|
-
// Create an unlisten function for later.
|
|
2837
|
-
info.unlisten = (/**
|
|
2838
|
-
* @return {?}
|
|
2839
|
-
*/
|
|
2840
|
-
() => {
|
|
2841
|
-
nativeElement.removeEventListener('focus', focusListener, true);
|
|
2842
|
-
nativeElement.removeEventListener('blur', blurListener, true);
|
|
2843
|
-
});
|
|
2899
|
+
this._registerGlobalListeners(info);
|
|
2844
2900
|
return info.subject.asObservable();
|
|
2845
2901
|
}
|
|
2846
2902
|
/**
|
|
@@ -2853,11 +2909,10 @@ class FocusMonitor {
|
|
|
2853
2909
|
/** @type {?} */
|
|
2854
2910
|
const elementInfo = this._elementInfo.get(nativeElement);
|
|
2855
2911
|
if (elementInfo) {
|
|
2856
|
-
elementInfo.unlisten();
|
|
2857
2912
|
elementInfo.subject.complete();
|
|
2858
2913
|
this._setClasses(nativeElement);
|
|
2859
2914
|
this._elementInfo.delete(nativeElement);
|
|
2860
|
-
this.
|
|
2915
|
+
this._removeGlobalListeners(elementInfo);
|
|
2861
2916
|
}
|
|
2862
2917
|
}
|
|
2863
2918
|
/**
|
|
@@ -2920,6 +2975,31 @@ class FocusMonitor {
|
|
|
2920
2975
|
element.classList.remove(className);
|
|
2921
2976
|
}
|
|
2922
2977
|
}
|
|
2978
|
+
/**
|
|
2979
|
+
* @private
|
|
2980
|
+
* @param {?} event
|
|
2981
|
+
* @return {?}
|
|
2982
|
+
*/
|
|
2983
|
+
_getFocusOrigin(event) {
|
|
2984
|
+
// If we couldn't detect a cause for the focus event, it's due to one of three reasons:
|
|
2985
|
+
// 1) The window has just regained focus, in which case we want to restore the focused state of
|
|
2986
|
+
// the element from before the window blurred.
|
|
2987
|
+
// 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
|
|
2988
|
+
// 3) The element was programmatically focused, in which case we should mark the origin as
|
|
2989
|
+
// 'program'.
|
|
2990
|
+
if (this._origin) {
|
|
2991
|
+
return this._origin;
|
|
2992
|
+
}
|
|
2993
|
+
if (this._windowFocused && this._lastFocusOrigin) {
|
|
2994
|
+
return this._lastFocusOrigin;
|
|
2995
|
+
}
|
|
2996
|
+
else if (this._wasCausedByTouch(event)) {
|
|
2997
|
+
return 'touch';
|
|
2998
|
+
}
|
|
2999
|
+
else {
|
|
3000
|
+
return 'program';
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
2923
3003
|
/**
|
|
2924
3004
|
* Sets the focus classes on the element based on the given focus origin.
|
|
2925
3005
|
* @private
|
|
@@ -2928,18 +3008,15 @@ class FocusMonitor {
|
|
|
2928
3008
|
* @return {?}
|
|
2929
3009
|
*/
|
|
2930
3010
|
_setClasses(element, origin) {
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
this._toggleClass(element, 'cdk-keyboard-focused', origin === 'keyboard');
|
|
2937
|
-
this._toggleClass(element, 'cdk-mouse-focused', origin === 'mouse');
|
|
2938
|
-
this._toggleClass(element, 'cdk-program-focused', origin === 'program');
|
|
2939
|
-
}
|
|
3011
|
+
this._toggleClass(element, 'cdk-focused', !!origin);
|
|
3012
|
+
this._toggleClass(element, 'cdk-touch-focused', origin === 'touch');
|
|
3013
|
+
this._toggleClass(element, 'cdk-keyboard-focused', origin === 'keyboard');
|
|
3014
|
+
this._toggleClass(element, 'cdk-mouse-focused', origin === 'mouse');
|
|
3015
|
+
this._toggleClass(element, 'cdk-program-focused', origin === 'program');
|
|
2940
3016
|
}
|
|
2941
3017
|
/**
|
|
2942
3018
|
* Sets the origin and schedules an async function to clear it at the end of the event queue.
|
|
3019
|
+
* If the detection mode is 'eventual', the origin is never cleared.
|
|
2943
3020
|
* @private
|
|
2944
3021
|
* @param {?} origin The origin to set.
|
|
2945
3022
|
* @return {?}
|
|
@@ -2950,13 +3027,15 @@ class FocusMonitor {
|
|
|
2950
3027
|
*/
|
|
2951
3028
|
() => {
|
|
2952
3029
|
this._origin = origin;
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
3030
|
+
if (this._detectionMode === 0 /* IMMEDIATE */) {
|
|
3031
|
+
// Sometimes the focus origin won't be valid in Firefox because Firefox seems to focus *one*
|
|
3032
|
+
// tick after the interaction event fired. To ensure the focus origin is always correct,
|
|
3033
|
+
// the focus origin will be determined at the beginning of the next tick.
|
|
3034
|
+
this._originTimeoutId = setTimeout((/**
|
|
3035
|
+
* @return {?}
|
|
3036
|
+
*/
|
|
3037
|
+
() => this._origin = null), 1);
|
|
3038
|
+
}
|
|
2960
3039
|
}));
|
|
2961
3040
|
}
|
|
2962
3041
|
/**
|
|
@@ -2984,7 +3063,7 @@ class FocusMonitor {
|
|
|
2984
3063
|
// focus event. When that blur event fires we know that whatever follows is not a result of the
|
|
2985
3064
|
// touchstart.
|
|
2986
3065
|
/** @type {?} */
|
|
2987
|
-
|
|
3066
|
+
const focusTarget = getTarget(event);
|
|
2988
3067
|
return this._lastTouchTarget instanceof Node && focusTarget instanceof Node &&
|
|
2989
3068
|
(focusTarget === this._lastTouchTarget || focusTarget.contains(this._lastTouchTarget));
|
|
2990
3069
|
}
|
|
@@ -3008,28 +3087,11 @@ class FocusMonitor {
|
|
|
3008
3087
|
// monitored element itself.
|
|
3009
3088
|
/** @type {?} */
|
|
3010
3089
|
const elementInfo = this._elementInfo.get(element);
|
|
3011
|
-
if (!elementInfo || (!elementInfo.checkChildren && element !== event
|
|
3090
|
+
if (!elementInfo || (!elementInfo.checkChildren && element !== getTarget(event))) {
|
|
3012
3091
|
return;
|
|
3013
3092
|
}
|
|
3014
|
-
// If we couldn't detect a cause for the focus event, it's due to one of three reasons:
|
|
3015
|
-
// 1) The window has just regained focus, in which case we want to restore the focused state of
|
|
3016
|
-
// the element from before the window blurred.
|
|
3017
|
-
// 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
|
|
3018
|
-
// 3) The element was programmatically focused, in which case we should mark the origin as
|
|
3019
|
-
// 'program'.
|
|
3020
3093
|
/** @type {?} */
|
|
3021
|
-
|
|
3022
|
-
if (!origin) {
|
|
3023
|
-
if (this._windowFocused && this._lastFocusOrigin) {
|
|
3024
|
-
origin = this._lastFocusOrigin;
|
|
3025
|
-
}
|
|
3026
|
-
else if (this._wasCausedByTouch(event)) {
|
|
3027
|
-
origin = 'touch';
|
|
3028
|
-
}
|
|
3029
|
-
else {
|
|
3030
|
-
origin = 'program';
|
|
3031
|
-
}
|
|
3032
|
-
}
|
|
3094
|
+
const origin = this._getFocusOrigin(event);
|
|
3033
3095
|
this._setClasses(element, origin);
|
|
3034
3096
|
this._emitOrigin(elementInfo.subject, origin);
|
|
3035
3097
|
this._lastFocusOrigin = origin;
|
|
@@ -3066,11 +3128,29 @@ class FocusMonitor {
|
|
|
3066
3128
|
}
|
|
3067
3129
|
/**
|
|
3068
3130
|
* @private
|
|
3131
|
+
* @param {?} elementInfo
|
|
3069
3132
|
* @return {?}
|
|
3070
3133
|
*/
|
|
3071
|
-
|
|
3134
|
+
_registerGlobalListeners(elementInfo) {
|
|
3135
|
+
if (!this._platform.isBrowser) {
|
|
3136
|
+
return;
|
|
3137
|
+
}
|
|
3138
|
+
/** @type {?} */
|
|
3139
|
+
const rootNode = elementInfo.rootNode;
|
|
3140
|
+
/** @type {?} */
|
|
3141
|
+
const rootNodeFocusListeners = this._rootNodeFocusListenerCount.get(rootNode) || 0;
|
|
3142
|
+
if (!rootNodeFocusListeners) {
|
|
3143
|
+
this._ngZone.runOutsideAngular((/**
|
|
3144
|
+
* @return {?}
|
|
3145
|
+
*/
|
|
3146
|
+
() => {
|
|
3147
|
+
rootNode.addEventListener('focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
3148
|
+
rootNode.addEventListener('blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
3149
|
+
}));
|
|
3150
|
+
}
|
|
3151
|
+
this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners + 1);
|
|
3072
3152
|
// Register global listeners when first element is monitored.
|
|
3073
|
-
if (++this._monitoredElementCount
|
|
3153
|
+
if (++this._monitoredElementCount === 1) {
|
|
3074
3154
|
// Note: we listen to events in the capture phase so we
|
|
3075
3155
|
// can detect them even if the user stops propagation.
|
|
3076
3156
|
this._ngZone.runOutsideAngular((/**
|
|
@@ -3090,9 +3170,24 @@ class FocusMonitor {
|
|
|
3090
3170
|
}
|
|
3091
3171
|
/**
|
|
3092
3172
|
* @private
|
|
3173
|
+
* @param {?} elementInfo
|
|
3093
3174
|
* @return {?}
|
|
3094
3175
|
*/
|
|
3095
|
-
|
|
3176
|
+
_removeGlobalListeners(elementInfo) {
|
|
3177
|
+
/** @type {?} */
|
|
3178
|
+
const rootNode = elementInfo.rootNode;
|
|
3179
|
+
if (this._rootNodeFocusListenerCount.has(rootNode)) {
|
|
3180
|
+
/** @type {?} */
|
|
3181
|
+
const rootNodeFocusListeners = (/** @type {?} */ (this._rootNodeFocusListenerCount.get(rootNode)));
|
|
3182
|
+
if (rootNodeFocusListeners > 1) {
|
|
3183
|
+
this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners - 1);
|
|
3184
|
+
}
|
|
3185
|
+
else {
|
|
3186
|
+
rootNode.removeEventListener('focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
3187
|
+
rootNode.removeEventListener('blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
|
|
3188
|
+
this._rootNodeFocusListenerCount.delete(rootNode);
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3096
3191
|
// Unregister global listeners when last element is unmonitored.
|
|
3097
3192
|
if (!--this._monitoredElementCount) {
|
|
3098
3193
|
/** @type {?} */
|
|
@@ -3117,9 +3212,10 @@ FocusMonitor.decorators = [
|
|
|
3117
3212
|
FocusMonitor.ctorParameters = () => [
|
|
3118
3213
|
{ type: NgZone },
|
|
3119
3214
|
{ type: Platform },
|
|
3120
|
-
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] }
|
|
3215
|
+
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] },
|
|
3216
|
+
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FOCUS_MONITOR_DEFAULT_OPTIONS,] }] }
|
|
3121
3217
|
];
|
|
3122
|
-
/** @nocollapse */ FocusMonitor.ɵprov = ɵɵdefineInjectable({ factory: function FocusMonitor_Factory() { return new FocusMonitor(ɵɵinject(NgZone), ɵɵinject(Platform), ɵɵinject(DOCUMENT, 8)); }, token: FocusMonitor, providedIn: "root" });
|
|
3218
|
+
/** @nocollapse */ FocusMonitor.ɵprov = ɵɵdefineInjectable({ factory: function FocusMonitor_Factory() { return new FocusMonitor(ɵɵinject(NgZone), ɵɵinject(Platform), ɵɵinject(DOCUMENT, 8), ɵɵinject(FOCUS_MONITOR_DEFAULT_OPTIONS, 8)); }, token: FocusMonitor, providedIn: "root" });
|
|
3123
3219
|
if (false) {
|
|
3124
3220
|
/**
|
|
3125
3221
|
* The focus origin that the next focus event is a result of.
|
|
@@ -3175,6 +3271,22 @@ if (false) {
|
|
|
3175
3271
|
* @private
|
|
3176
3272
|
*/
|
|
3177
3273
|
FocusMonitor.prototype._monitoredElementCount;
|
|
3274
|
+
/**
|
|
3275
|
+
* Keeps track of the root nodes to which we've currently bound a focus/blur handler,
|
|
3276
|
+
* as well as the number of monitored elements that they contain. We have to treat focus/blur
|
|
3277
|
+
* handlers differently from the rest of the events, because the browser won't emit events
|
|
3278
|
+
* to the document when focus moves inside of a shadow root.
|
|
3279
|
+
* @type {?}
|
|
3280
|
+
* @private
|
|
3281
|
+
*/
|
|
3282
|
+
FocusMonitor.prototype._rootNodeFocusListenerCount;
|
|
3283
|
+
/**
|
|
3284
|
+
* The specified detection mode, used for attributing the origin of a focus
|
|
3285
|
+
* event.
|
|
3286
|
+
* @type {?}
|
|
3287
|
+
* @private
|
|
3288
|
+
*/
|
|
3289
|
+
FocusMonitor.prototype._detectionMode;
|
|
3178
3290
|
/**
|
|
3179
3291
|
* Event listener for `keydown` events on the document.
|
|
3180
3292
|
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
@@ -3209,6 +3321,13 @@ if (false) {
|
|
|
3209
3321
|
* @protected
|
|
3210
3322
|
*/
|
|
3211
3323
|
FocusMonitor.prototype._document;
|
|
3324
|
+
/**
|
|
3325
|
+
* Event listener for `focus` and 'blur' events on the document.
|
|
3326
|
+
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
3327
|
+
* @type {?}
|
|
3328
|
+
* @private
|
|
3329
|
+
*/
|
|
3330
|
+
FocusMonitor.prototype._rootNodeFocusAndBlurListener;
|
|
3212
3331
|
/**
|
|
3213
3332
|
* @type {?}
|
|
3214
3333
|
* @private
|
|
@@ -3220,6 +3339,16 @@ if (false) {
|
|
|
3220
3339
|
*/
|
|
3221
3340
|
FocusMonitor.prototype._platform;
|
|
3222
3341
|
}
|
|
3342
|
+
/**
|
|
3343
|
+
* Gets the target of an event, accounting for Shadow DOM.
|
|
3344
|
+
* @param {?} event
|
|
3345
|
+
* @return {?}
|
|
3346
|
+
*/
|
|
3347
|
+
function getTarget(event) {
|
|
3348
|
+
// If an event is bound outside the Shadow DOM, the `event.target` will
|
|
3349
|
+
// point to the shadow root so we have to use `composedPath` instead.
|
|
3350
|
+
return (/** @type {?} */ ((event.composedPath ? event.composedPath()[0] : event.target)));
|
|
3351
|
+
}
|
|
3223
3352
|
/**
|
|
3224
3353
|
* Directive that determines how a particular element was focused (via keyboard, mouse, touch, or
|
|
3225
3354
|
* programmatically) and adds corresponding classes to the element.
|
|
@@ -3286,31 +3415,6 @@ if (false) {
|
|
|
3286
3415
|
CdkMonitorFocus.prototype._focusMonitor;
|
|
3287
3416
|
}
|
|
3288
3417
|
|
|
3289
|
-
/**
|
|
3290
|
-
* @fileoverview added by tsickle
|
|
3291
|
-
* Generated from: src/cdk/a11y/fake-mousedown.ts
|
|
3292
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3293
|
-
*/
|
|
3294
|
-
/**
|
|
3295
|
-
* @license
|
|
3296
|
-
* Copyright Google LLC All Rights Reserved.
|
|
3297
|
-
*
|
|
3298
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
3299
|
-
* found in the LICENSE file at https://angular.io/license
|
|
3300
|
-
*/
|
|
3301
|
-
/**
|
|
3302
|
-
* Screenreaders will often fire fake mousedown events when a focusable element
|
|
3303
|
-
* is activated using the keyboard. We can typically distinguish between these faked
|
|
3304
|
-
* mousedown events and real mousedown events using the "buttons" property. While
|
|
3305
|
-
* real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
|
|
3306
|
-
* the left mouse button), faked mousedowns will usually set the property value to 0.
|
|
3307
|
-
* @param {?} event
|
|
3308
|
-
* @return {?}
|
|
3309
|
-
*/
|
|
3310
|
-
function isFakeMousedownFromScreenReader(event) {
|
|
3311
|
-
return event.buttons === 0;
|
|
3312
|
-
}
|
|
3313
|
-
|
|
3314
3418
|
/**
|
|
3315
3419
|
* @fileoverview added by tsickle
|
|
3316
3420
|
* Generated from: src/cdk/a11y/high-contrast-mode/high-contrast-mode-detector.ts
|
|
@@ -3338,7 +3442,7 @@ const WHITE_ON_BLACK_CSS_CLASS = 'cdk-high-contrast-white-on-black';
|
|
|
3338
3442
|
*/
|
|
3339
3443
|
const HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS = 'cdk-high-contrast-active';
|
|
3340
3444
|
/**
|
|
3341
|
-
* Service to determine whether the browser is currently in a high-
|
|
3445
|
+
* Service to determine whether the browser is currently in a high-contrast-mode environment.
|
|
3342
3446
|
*
|
|
3343
3447
|
* Microsoft Windows supports an accessibility feature called "High Contrast Mode". This mode
|
|
3344
3448
|
* changes the appearance of all applications, including web applications, to dramatically increase
|
|
@@ -3358,7 +3462,7 @@ class HighContrastModeDetector {
|
|
|
3358
3462
|
this._document = document;
|
|
3359
3463
|
}
|
|
3360
3464
|
/**
|
|
3361
|
-
* Gets the current high-
|
|
3465
|
+
* Gets the current high-contrast-mode for the page.
|
|
3362
3466
|
* @return {?}
|
|
3363
3467
|
*/
|
|
3364
3468
|
getHighContrastMode() {
|
|
@@ -3375,11 +3479,15 @@ class HighContrastModeDetector {
|
|
|
3375
3479
|
this._document.body.appendChild(testElement);
|
|
3376
3480
|
// Get the computed style for the background color, collapsing spaces to normalize between
|
|
3377
3481
|
// browsers. Once we get this color, we no longer need the test element. Access the `window`
|
|
3378
|
-
// via the document so we can fake it in tests.
|
|
3482
|
+
// via the document so we can fake it in tests. Note that we have extra null checks, because
|
|
3483
|
+
// this logic will likely run during app bootstrap and throwing can break the entire app.
|
|
3484
|
+
/** @type {?} */
|
|
3485
|
+
const documentWindow = this._document.defaultView || window;
|
|
3379
3486
|
/** @type {?} */
|
|
3380
|
-
const
|
|
3487
|
+
const computedStyle = (documentWindow && documentWindow.getComputedStyle) ?
|
|
3488
|
+
documentWindow.getComputedStyle(testElement) : null;
|
|
3381
3489
|
/** @type {?} */
|
|
3382
|
-
const computedColor = (
|
|
3490
|
+
const computedColor = (computedStyle && computedStyle.backgroundColor || '').replace(/ /g, '');
|
|
3383
3491
|
this._document.body.removeChild(testElement);
|
|
3384
3492
|
switch (computedColor) {
|
|
3385
3493
|
case 'rgb(0,0,0)': return 2 /* WHITE_ON_BLACK */;
|
|
@@ -3469,5 +3577,5 @@ A11yModule.ctorParameters = () => [
|
|
|
3469
3577
|
* Generated bundle index. Do not edit.
|
|
3470
3578
|
*/
|
|
3471
3579
|
|
|
3472
|
-
export { A11yModule, ActiveDescendantKeyManager, AriaDescriber, CDK_DESCRIBEDBY_HOST_ATTRIBUTE, CDK_DESCRIBEDBY_ID_PREFIX, CdkAriaLive, CdkMonitorFocus, CdkTrapFocus, ConfigurableFocusTrap, ConfigurableFocusTrapFactory, EventListenerFocusTrapInertStrategy, FOCUS_TRAP_INERT_STRATEGY, FocusKeyManager, FocusMonitor, FocusTrap, FocusTrapFactory, HighContrastModeDetector, InteractivityChecker, LIVE_ANNOUNCER_DEFAULT_OPTIONS, LIVE_ANNOUNCER_ELEMENT_TOKEN, LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY, ListKeyManager, LiveAnnouncer, MESSAGES_CONTAINER_ID, TOUCH_BUFFER_MS, isFakeMousedownFromScreenReader, FocusTrapManager as ɵangular_material_src_cdk_a11y_a11y_a, ConfigurableFocusTrapConfig as ɵangular_material_src_cdk_a11y_a11y_b };
|
|
3580
|
+
export { A11yModule, ActiveDescendantKeyManager, AriaDescriber, CDK_DESCRIBEDBY_HOST_ATTRIBUTE, CDK_DESCRIBEDBY_ID_PREFIX, CdkAriaLive, CdkMonitorFocus, CdkTrapFocus, ConfigurableFocusTrap, ConfigurableFocusTrapFactory, EventListenerFocusTrapInertStrategy, FOCUS_MONITOR_DEFAULT_OPTIONS, FOCUS_TRAP_INERT_STRATEGY, FocusKeyManager, FocusMonitor, FocusTrap, FocusTrapFactory, HighContrastModeDetector, InteractivityChecker, LIVE_ANNOUNCER_DEFAULT_OPTIONS, LIVE_ANNOUNCER_ELEMENT_TOKEN, LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY, ListKeyManager, LiveAnnouncer, MESSAGES_CONTAINER_ID, TOUCH_BUFFER_MS, isFakeMousedownFromScreenReader, FocusTrapManager as ɵangular_material_src_cdk_a11y_a11y_a, ConfigurableFocusTrapConfig as ɵangular_material_src_cdk_a11y_a11y_b };
|
|
3473
3581
|
//# sourceMappingURL=a11y.js.map
|