@angular/cdk 9.2.1 → 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.
Files changed (171) hide show
  1. package/a11y/focus-monitor/focus-monitor.d.ts +10 -3
  2. package/a11y/high-contrast-mode/high-contrast-mode-detector.d.ts +2 -2
  3. package/a11y/index.metadata.json +1 -1
  4. package/bundles/cdk-a11y.umd.js +62 -27
  5. package/bundles/cdk-a11y.umd.js.map +1 -1
  6. package/bundles/cdk-a11y.umd.min.js +12 -5
  7. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  8. package/bundles/cdk-drag-drop.umd.js +193 -109
  9. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  10. package/bundles/cdk-drag-drop.umd.min.js +17 -10
  11. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  12. package/bundles/cdk-overlay.umd.js.map +1 -1
  13. package/bundles/cdk-platform.umd.js +3 -1
  14. package/bundles/cdk-platform.umd.js.map +1 -1
  15. package/bundles/cdk-platform.umd.min.js +4 -4
  16. package/bundles/cdk-platform.umd.min.js.map +1 -1
  17. package/bundles/cdk-scrolling.umd.js +18 -3
  18. package/bundles/cdk-scrolling.umd.js.map +1 -1
  19. package/bundles/cdk-scrolling.umd.min.js +2 -2
  20. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  21. package/bundles/cdk-testing-testbed.umd.js +62 -10
  22. package/bundles/cdk-testing-testbed.umd.js.map +1 -1
  23. package/bundles/cdk-testing-testbed.umd.min.js +5 -5
  24. package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
  25. package/bundles/cdk-tree.umd.js +1 -0
  26. package/bundles/cdk-tree.umd.js.map +1 -1
  27. package/bundles/cdk-tree.umd.min.js +1 -1
  28. package/bundles/cdk-tree.umd.min.js.map +1 -1
  29. package/bundles/cdk.umd.js +1 -1
  30. package/bundles/cdk.umd.js.map +1 -1
  31. package/bundles/cdk.umd.min.js +1 -1
  32. package/bundles/cdk.umd.min.js.map +1 -1
  33. package/drag-drop/drag-ref.d.ts +4 -2
  34. package/drag-drop/drop-list-ref.d.ts +9 -8
  35. package/drag-drop/index.metadata.json +1 -1
  36. package/drag-drop/parent-position-tracker.d.ts +31 -0
  37. package/drag-drop/public-api.d.ts +1 -1
  38. package/esm2015/a11y/aria-describer/aria-reference.js +6 -6
  39. package/esm2015/a11y/focus-monitor/focus-monitor.js +84 -26
  40. package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +3 -3
  41. package/esm2015/drag-drop/drag-drop-module.js +3 -1
  42. package/esm2015/drag-drop/drag-ref.js +55 -35
  43. package/esm2015/drag-drop/drop-list-ref.js +115 -124
  44. package/esm2015/drag-drop/parent-position-tracker.js +141 -0
  45. package/esm2015/drag-drop/public-api.js +1 -1
  46. package/esm2015/overlay/position/flexible-connected-position-strategy.js +1 -1
  47. package/esm2015/platform/features/shadow-dom.js +4 -2
  48. package/esm2015/scrolling/public-api.js +2 -2
  49. package/esm2015/scrolling/scrolling-module.js +15 -4
  50. package/esm2015/testing/testbed/fake-events/dispatch-events.js +11 -4
  51. package/esm2015/testing/testbed/fake-events/event-objects.js +37 -3
  52. package/esm2015/testing/testbed/unit-test-element.js +13 -2
  53. package/esm2015/tree/tree.js +2 -1
  54. package/esm2015/version.js +1 -1
  55. package/esm5/a11y/aria-describer/aria-reference.js +6 -6
  56. package/esm5/a11y/focus-monitor/focus-monitor.js +57 -22
  57. package/esm5/a11y/high-contrast-mode/high-contrast-mode-detector.js +3 -3
  58. package/esm5/drag-drop/drag-drop-module.js +3 -1
  59. package/esm5/drag-drop/drag-ref.js +39 -26
  60. package/esm5/drag-drop/drop-list-ref.js +85 -86
  61. package/esm5/drag-drop/parent-position-tracker.js +74 -0
  62. package/esm5/drag-drop/public-api.js +1 -1
  63. package/esm5/overlay/position/flexible-connected-position-strategy.js +1 -1
  64. package/esm5/platform/features/shadow-dom.js +4 -2
  65. package/esm5/scrolling/scrolling-module.js +19 -4
  66. package/esm5/testing/testbed/fake-events/dispatch-events.js +15 -7
  67. package/esm5/testing/testbed/fake-events/event-objects.js +43 -5
  68. package/esm5/testing/testbed/unit-test-element.js +10 -3
  69. package/esm5/tree/tree.js +2 -1
  70. package/esm5/version.js +1 -1
  71. package/fesm2015/a11y.js +90 -32
  72. package/fesm2015/a11y.js.map +1 -1
  73. package/fesm2015/cdk.js +1 -1
  74. package/fesm2015/cdk.js.map +1 -1
  75. package/fesm2015/drag-drop.js +302 -158
  76. package/fesm2015/drag-drop.js.map +1 -1
  77. package/fesm2015/overlay.js.map +1 -1
  78. package/fesm2015/platform.js +3 -1
  79. package/fesm2015/platform.js.map +1 -1
  80. package/fesm2015/scrolling.js +15 -4
  81. package/fesm2015/scrolling.js.map +1 -1
  82. package/fesm2015/testing/testbed.js +56 -4
  83. package/fesm2015/testing/testbed.js.map +1 -1
  84. package/fesm2015/tree.js +1 -0
  85. package/fesm2015/tree.js.map +1 -1
  86. package/fesm5/a11y.js +63 -28
  87. package/fesm5/a11y.js.map +1 -1
  88. package/fesm5/cdk.js +1 -1
  89. package/fesm5/cdk.js.map +1 -1
  90. package/fesm5/drag-drop.js +195 -111
  91. package/fesm5/drag-drop.js.map +1 -1
  92. package/fesm5/overlay.js.map +1 -1
  93. package/fesm5/platform.js +3 -1
  94. package/fesm5/platform.js.map +1 -1
  95. package/fesm5/scrolling.js +18 -4
  96. package/fesm5/scrolling.js.map +1 -1
  97. package/fesm5/testing/testbed.js +63 -11
  98. package/fesm5/testing/testbed.js.map +1 -1
  99. package/fesm5/tree.js +1 -0
  100. package/fesm5/tree.js.map +1 -1
  101. package/overlay/position/flexible-connected-position-strategy.d.ts +1 -1
  102. package/package.json +1 -1
  103. package/schematics/ng-add/index.js +1 -1
  104. package/schematics/ng-update/devkit-file-system.d.ts +29 -0
  105. package/schematics/ng-update/devkit-file-system.js +67 -0
  106. package/schematics/ng-update/devkit-migration-rule.d.ts +25 -0
  107. package/schematics/ng-update/devkit-migration-rule.js +152 -0
  108. package/schematics/ng-update/devkit-migration.d.ts +37 -0
  109. package/schematics/ng-update/devkit-migration.js +29 -0
  110. package/schematics/ng-update/index.js +7 -7
  111. package/schematics/ng-update/{upgrade-rules/attribute-selectors-rule.d.ts → migrations/attribute-selectors.d.ts} +6 -6
  112. package/schematics/ng-update/migrations/attribute-selectors.js +76 -0
  113. package/schematics/ng-update/{upgrade-rules/class-inheritance-rule.d.ts → migrations/class-inheritance.d.ts} +6 -6
  114. package/schematics/ng-update/migrations/class-inheritance.js +67 -0
  115. package/schematics/ng-update/{upgrade-rules/class-names-rule.d.ts → migrations/class-names.d.ts} +6 -6
  116. package/schematics/ng-update/migrations/class-names.js +98 -0
  117. package/schematics/ng-update/{upgrade-rules/constructor-signature-rule.d.ts → migrations/constructor-signature.d.ts} +6 -6
  118. package/schematics/ng-update/migrations/constructor-signature.js +144 -0
  119. package/schematics/ng-update/{upgrade-rules/css-selectors-rule.d.ts → migrations/css-selectors.d.ts} +6 -6
  120. package/schematics/ng-update/migrations/css-selectors.js +83 -0
  121. package/schematics/ng-update/{upgrade-rules/element-selectors-rule.d.ts → migrations/element-selectors.d.ts} +6 -6
  122. package/schematics/ng-update/migrations/element-selectors.js +74 -0
  123. package/schematics/ng-update/{upgrade-rules/input-names-rule.d.ts → migrations/input-names.d.ts} +6 -6
  124. package/schematics/ng-update/migrations/input-names.js +69 -0
  125. package/schematics/ng-update/{upgrade-rules/method-call-arguments-rule.d.ts → migrations/method-call-arguments.d.ts} +6 -6
  126. package/schematics/ng-update/migrations/method-call-arguments.js +70 -0
  127. package/schematics/ng-update/{upgrade-rules/misc-template-rule.d.ts → migrations/misc-template.d.ts} +6 -6
  128. package/schematics/ng-update/migrations/misc-template.js +47 -0
  129. package/schematics/ng-update/{upgrade-rules/output-names-rule.d.ts → migrations/output-names.d.ts} +6 -6
  130. package/schematics/ng-update/migrations/output-names.js +56 -0
  131. package/schematics/ng-update/{upgrade-rules/property-names-rule.d.ts → migrations/property-names.d.ts} +6 -6
  132. package/schematics/ng-update/migrations/property-names.js +56 -0
  133. package/schematics/ng-update/public-api.d.ts +3 -2
  134. package/schematics/ng-update/public-api.js +5 -4
  135. package/schematics/ng-update/upgrade-data.d.ts +7 -8
  136. package/schematics/ng-update/upgrade-data.js +6 -7
  137. package/schematics/update-tool/component-resource-collector.d.ts +3 -1
  138. package/schematics/update-tool/component-resource-collector.js +8 -8
  139. package/schematics/update-tool/file-system.d.ts +38 -0
  140. package/schematics/update-tool/file-system.js +20 -0
  141. package/schematics/update-tool/index.d.ts +41 -11
  142. package/schematics/update-tool/index.js +135 -106
  143. package/schematics/update-tool/logger.d.ts +16 -0
  144. package/schematics/update-tool/logger.js +27 -0
  145. package/schematics/update-tool/{migration-rule.d.ts → migration.d.ts} +23 -45
  146. package/schematics/update-tool/migration.js +76 -0
  147. package/schematics/update-tool/public-api.d.ts +5 -4
  148. package/schematics/update-tool/public-api.js +6 -6
  149. package/schematics/update-tool/update-recorder.d.ts +14 -0
  150. package/schematics/update-tool/update-recorder.js +20 -0
  151. package/schematics/update-tool/utils/parse-tsconfig.js +1 -1
  152. package/schematics/update-tool/version-changes.js +3 -4
  153. package/scrolling/index.metadata.json +1 -1
  154. package/scrolling/scrolling-module.d.ts +2 -0
  155. package/testing/testbed/fake-events/dispatch-events.d.ts +8 -3
  156. package/testing/testbed/fake-events/event-objects.d.ts +12 -1
  157. package/tree/index.metadata.json +1 -1
  158. package/schematics/ng-update/upgrade-rules/attribute-selectors-rule.js +0 -76
  159. package/schematics/ng-update/upgrade-rules/class-inheritance-rule.js +0 -67
  160. package/schematics/ng-update/upgrade-rules/class-names-rule.js +0 -98
  161. package/schematics/ng-update/upgrade-rules/constructor-signature-rule.js +0 -144
  162. package/schematics/ng-update/upgrade-rules/css-selectors-rule.js +0 -83
  163. package/schematics/ng-update/upgrade-rules/element-selectors-rule.js +0 -74
  164. package/schematics/ng-update/upgrade-rules/index.d.ts +0 -22
  165. package/schematics/ng-update/upgrade-rules/index.js +0 -116
  166. package/schematics/ng-update/upgrade-rules/input-names-rule.js +0 -69
  167. package/schematics/ng-update/upgrade-rules/method-call-arguments-rule.js +0 -70
  168. package/schematics/ng-update/upgrade-rules/misc-template-rule.js +0 -47
  169. package/schematics/ng-update/upgrade-rules/output-names-rule.js +0 -56
  170. package/schematics/ng-update/upgrade-rules/property-names-rule.js +0 -56
  171. 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 deliminated by an empty space, as per the spec.
23
+ * IDs are delimited by an empty space, as per the spec.
24
24
  * @type {?}
25
25
  */
26
- const ID_DELIMINATOR = ' ';
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(ID_DELIMINATOR));
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(ID_DELIMINATOR));
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 deliminated) in the attribute value
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
 
@@ -2768,6 +2768,13 @@ class FocusMonitor {
2768
2768
  * The number of elements currently being monitored.
2769
2769
  */
2770
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();
2771
2778
  /**
2772
2779
  * Event listener for `keydown` events on the document.
2773
2780
  * Needs to be an arrow function in order to preserve the context when it gets bound.
@@ -2814,10 +2821,7 @@ class FocusMonitor {
2814
2821
  if (this._touchTimeoutId != null) {
2815
2822
  clearTimeout(this._touchTimeoutId);
2816
2823
  }
2817
- // Since this listener is bound on the `document` level, any events coming from the shadow DOM
2818
- // will have their `target` set to the shadow root. If available, use `composedPath` to
2819
- // figure out the event target.
2820
- this._lastTouchTarget = event.composedPath ? event.composedPath()[0] : event.target;
2824
+ this._lastTouchTarget = getTarget(event);
2821
2825
  this._touchTimeoutId = setTimeout((/**
2822
2826
  * @return {?}
2823
2827
  */
@@ -2843,18 +2847,18 @@ class FocusMonitor {
2843
2847
  * Event listener for `focus` and 'blur' events on the document.
2844
2848
  * Needs to be an arrow function in order to preserve the context when it gets bound.
2845
2849
  */
2846
- this._documentFocusAndBlurListener = (/**
2850
+ this._rootNodeFocusAndBlurListener = (/**
2847
2851
  * @param {?} event
2848
2852
  * @return {?}
2849
2853
  */
2850
2854
  (event) => {
2851
2855
  /** @type {?} */
2852
- const target = (/** @type {?} */ (event.target));
2856
+ const target = getTarget(event);
2853
2857
  /** @type {?} */
2854
2858
  const handler = event.type === 'focus' ? this._onFocus : this._onBlur;
2855
2859
  // We need to walk up the ancestor chain in order to support `checkChildren`.
2856
- for (let el = target; el; el = el.parentElement) {
2857
- handler.call(this, event, el);
2860
+ for (let element = target; element; element = element.parentElement) {
2861
+ handler.call(this, (/** @type {?} */ (event)), element);
2858
2862
  }
2859
2863
  });
2860
2864
  this._document = document;
@@ -2872,21 +2876,27 @@ class FocusMonitor {
2872
2876
  }
2873
2877
  /** @type {?} */
2874
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();
2875
2884
  // Check if we're already monitoring this element.
2876
2885
  if (this._elementInfo.has(nativeElement)) {
2877
2886
  /** @type {?} */
2878
- const cachedInfo = this._elementInfo.get(nativeElement);
2879
- (/** @type {?} */ (cachedInfo)).checkChildren = checkChildren;
2880
- return (/** @type {?} */ (cachedInfo)).subject.asObservable();
2887
+ const cachedInfo = (/** @type {?} */ (this._elementInfo.get(nativeElement)));
2888
+ cachedInfo.checkChildren = checkChildren;
2889
+ return cachedInfo.subject.asObservable();
2881
2890
  }
2882
2891
  // Create monitored element info.
2883
2892
  /** @type {?} */
2884
2893
  const info = {
2885
2894
  checkChildren: checkChildren,
2886
- subject: new Subject()
2895
+ subject: new Subject(),
2896
+ rootNode
2887
2897
  };
2888
2898
  this._elementInfo.set(nativeElement, info);
2889
- this._incrementMonitoredElementCount();
2899
+ this._registerGlobalListeners(info);
2890
2900
  return info.subject.asObservable();
2891
2901
  }
2892
2902
  /**
@@ -2902,7 +2912,7 @@ class FocusMonitor {
2902
2912
  elementInfo.subject.complete();
2903
2913
  this._setClasses(nativeElement);
2904
2914
  this._elementInfo.delete(nativeElement);
2905
- this._decrementMonitoredElementCount();
2915
+ this._removeGlobalListeners(elementInfo);
2906
2916
  }
2907
2917
  }
2908
2918
  /**
@@ -3053,7 +3063,7 @@ class FocusMonitor {
3053
3063
  // focus event. When that blur event fires we know that whatever follows is not a result of the
3054
3064
  // touchstart.
3055
3065
  /** @type {?} */
3056
- let focusTarget = event.target;
3066
+ const focusTarget = getTarget(event);
3057
3067
  return this._lastTouchTarget instanceof Node && focusTarget instanceof Node &&
3058
3068
  (focusTarget === this._lastTouchTarget || focusTarget.contains(this._lastTouchTarget));
3059
3069
  }
@@ -3077,7 +3087,7 @@ class FocusMonitor {
3077
3087
  // monitored element itself.
3078
3088
  /** @type {?} */
3079
3089
  const elementInfo = this._elementInfo.get(element);
3080
- if (!elementInfo || (!elementInfo.checkChildren && element !== event.target)) {
3090
+ if (!elementInfo || (!elementInfo.checkChildren && element !== getTarget(event))) {
3081
3091
  return;
3082
3092
  }
3083
3093
  /** @type {?} */
@@ -3118,11 +3128,29 @@ class FocusMonitor {
3118
3128
  }
3119
3129
  /**
3120
3130
  * @private
3131
+ * @param {?} elementInfo
3121
3132
  * @return {?}
3122
3133
  */
3123
- _incrementMonitoredElementCount() {
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);
3124
3152
  // Register global listeners when first element is monitored.
3125
- if (++this._monitoredElementCount == 1 && this._platform.isBrowser) {
3153
+ if (++this._monitoredElementCount === 1) {
3126
3154
  // Note: we listen to events in the capture phase so we
3127
3155
  // can detect them even if the user stops propagation.
3128
3156
  this._ngZone.runOutsideAngular((/**
@@ -3133,8 +3161,6 @@ class FocusMonitor {
3133
3161
  const document = this._getDocument();
3134
3162
  /** @type {?} */
3135
3163
  const window = this._getWindow();
3136
- document.addEventListener('focus', this._documentFocusAndBlurListener, captureEventListenerOptions);
3137
- document.addEventListener('blur', this._documentFocusAndBlurListener, captureEventListenerOptions);
3138
3164
  document.addEventListener('keydown', this._documentKeydownListener, captureEventListenerOptions);
3139
3165
  document.addEventListener('mousedown', this._documentMousedownListener, captureEventListenerOptions);
3140
3166
  document.addEventListener('touchstart', this._documentTouchstartListener, captureEventListenerOptions);
@@ -3144,17 +3170,30 @@ class FocusMonitor {
3144
3170
  }
3145
3171
  /**
3146
3172
  * @private
3173
+ * @param {?} elementInfo
3147
3174
  * @return {?}
3148
3175
  */
3149
- _decrementMonitoredElementCount() {
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
+ }
3150
3191
  // Unregister global listeners when last element is unmonitored.
3151
3192
  if (!--this._monitoredElementCount) {
3152
3193
  /** @type {?} */
3153
3194
  const document = this._getDocument();
3154
3195
  /** @type {?} */
3155
3196
  const window = this._getWindow();
3156
- document.removeEventListener('focus', this._documentFocusAndBlurListener, captureEventListenerOptions);
3157
- document.removeEventListener('blur', this._documentFocusAndBlurListener, captureEventListenerOptions);
3158
3197
  document.removeEventListener('keydown', this._documentKeydownListener, captureEventListenerOptions);
3159
3198
  document.removeEventListener('mousedown', this._documentMousedownListener, captureEventListenerOptions);
3160
3199
  document.removeEventListener('touchstart', this._documentTouchstartListener, captureEventListenerOptions);
@@ -3232,6 +3271,15 @@ if (false) {
3232
3271
  * @private
3233
3272
  */
3234
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;
3235
3283
  /**
3236
3284
  * The specified detection mode, used for attributing the origin of a focus
3237
3285
  * event.
@@ -3279,7 +3327,7 @@ if (false) {
3279
3327
  * @type {?}
3280
3328
  * @private
3281
3329
  */
3282
- FocusMonitor.prototype._documentFocusAndBlurListener;
3330
+ FocusMonitor.prototype._rootNodeFocusAndBlurListener;
3283
3331
  /**
3284
3332
  * @type {?}
3285
3333
  * @private
@@ -3291,6 +3339,16 @@ if (false) {
3291
3339
  */
3292
3340
  FocusMonitor.prototype._platform;
3293
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
+ }
3294
3352
  /**
3295
3353
  * Directive that determines how a particular element was focused (via keyboard, mouse, touch, or
3296
3354
  * programmatically) and adds corresponding classes to the element.
@@ -3384,7 +3442,7 @@ const WHITE_ON_BLACK_CSS_CLASS = 'cdk-high-contrast-white-on-black';
3384
3442
  */
3385
3443
  const HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS = 'cdk-high-contrast-active';
3386
3444
  /**
3387
- * Service to determine whether the browser is currently in a high-constrast-mode environment.
3445
+ * Service to determine whether the browser is currently in a high-contrast-mode environment.
3388
3446
  *
3389
3447
  * Microsoft Windows supports an accessibility feature called "High Contrast Mode". This mode
3390
3448
  * changes the appearance of all applications, including web applications, to dramatically increase
@@ -3404,7 +3462,7 @@ class HighContrastModeDetector {
3404
3462
  this._document = document;
3405
3463
  }
3406
3464
  /**
3407
- * Gets the current high-constrast-mode for the page.
3465
+ * Gets the current high-contrast-mode for the page.
3408
3466
  * @return {?}
3409
3467
  */
3410
3468
  getHighContrastMode() {