New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cdk): switch injectables to new scope API #10301
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @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 {InjectionToken} from '@angular/core'; | ||
|
||
// The token for the live announcer element is defined in a separate file from LiveAnnouncer | ||
// as a workaround for https://github.com/angular/angular/issues/22559 | ||
|
||
export const LIVE_ANNOUNCER_ELEMENT_TOKEN = | ||
new InjectionToken<HTMLElement | null>('liveAnnouncerElement', { | ||
providedIn: 'root', | ||
factory: () => null, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @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 {DOCUMENT} from '@angular/common'; | ||
import {inject, InjectionToken} from '@angular/core'; | ||
|
||
|
||
/** | ||
* Injection token used to inject the document into Directionality. | ||
* This is used so that the value can be faked in tests. | ||
* | ||
* We can't use the real document in tests because changing the real `dir` causes geometry-based | ||
* tests in Safari to fail. | ||
* | ||
* We also can't re-provide the DOCUMENT token from platform-brower because the unit tests | ||
* themselves use things like `querySelector` in test code. | ||
* | ||
* This token is defined in a separate file from Directionality as a workaround for | ||
* https://github.com/angular/angular/issues/22559 | ||
* | ||
* @docs-private | ||
*/ | ||
export const DIR_DOCUMENT = new InjectionToken<Document>('cdk-dir-doc', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As an aside, do we really need a separate token for the document here? We can easily stub out the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I was originally doing this I found that re-providing common's |
||
providedIn: 'root', | ||
factory: () => inject(DOCUMENT), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super familiar with how the app-wide providers work yet, but should the
AriaDescriber
still be set in theproviders
in this case? I believe that it's the only reason why, for example, the tooltip imports theA11yModule
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it, module imports just for this kind of injectable shouldn't be necessary any more. I'll address those in my next PR that applies this to material.