Skip to content

Commit 2defaf7

Browse files
authored
refactor(platform): change deprecated APIs for version 10 (#19347)
Changes the APIs that were deprecated for v10 in the `cdk/platform` module. BREAKING CHANGES: * The `_platformId` parameter in the `Platform` constructor is now required.
1 parent 25d2e05 commit 2defaf7

File tree

12 files changed

+212
-136
lines changed

12 files changed

+212
-136
lines changed

src/cdk/a11y/focus-trap/focus-trap.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Platform} from '@angular/cdk/platform';
2-
import {Component, PLATFORM_ID, ViewChild} from '@angular/core';
2+
import {Component, ViewChild} from '@angular/core';
33
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
44
import {A11yModule, FocusTrap, CdkTrapFocus} from '../index';
55

@@ -48,9 +48,9 @@ describe('FocusTrap', () => {
4848
// focus event handler directly.
4949
const result = focusTrapInstance.focusLastTabbableElement();
5050

51-
const platformId = TestBed.inject(PLATFORM_ID);
51+
const platform = TestBed.inject(Platform);
5252
// In iOS button elements are never tabbable, so the last element will be the input.
53-
const lastElement = new Platform(platformId).IOS ? 'input' : 'button';
53+
const lastElement = platform.IOS ? 'input' : 'button';
5454

5555
expect(document.activeElement!.nodeName.toLowerCase())
5656
.toBe(lastElement, `Expected ${lastElement} element to be focused`);

src/cdk/a11y/high-contrast-mode/high-contrast-mode-detector.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import {
55
HighContrastModeDetector, WHITE_ON_BLACK_CSS_CLASS,
66
} from './high-contrast-mode-detector';
77
import {Platform} from '@angular/cdk/platform';
8+
import {inject} from '@angular/core/testing';
89

910

1011
describe('HighContrastModeDetector', () => {
1112
let fakePlatform: Platform;
1213

13-
beforeEach(() => {
14-
fakePlatform = new Platform();
15-
});
14+
beforeEach(inject([Platform], (p: Platform) => {
15+
fakePlatform = p;
16+
}));
1617

1718
it('should detect NONE for non-browser platforms', () => {
1819
fakePlatform.isBrowser = false;

0 commit comments

Comments
 (0)