-
Notifications
You must be signed in to change notification settings - Fork 26.3k
test(ivy): NodeInjector should know how to get itself (INJECTOR) #28009
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
Conversation
You can preview 72bdb4f at https://pr28009-72bdb4f.ngbuilds.io/. |
72bdb4f
to
2bdbf6a
Compare
You can preview 2bdbf6a at https://pr28009-2bdbf6a.ngbuilds.io/. |
@@ -56,15 +56,21 @@ export class InjectionToken<T> { | |||
|
|||
readonly ngInjectableDef: never|undefined; | |||
|
|||
/** @internal */ | |||
readonly __NG_ELEMENT_ID__: (() => any)|undefined; |
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 don't think exposing privet implementation details like this is a good idea.
packages/core/src/di/injector.ts
Outdated
@@ -31,7 +31,11 @@ export const THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND; | |||
* | |||
* @publicApi | |||
*/ | |||
export const INJECTOR = new InjectionToken<Injector>('INJECTOR'); | |||
export const INJECTOR: InjectionToken<Injector> = new InjectionToken<Injector>('INJECTOR', { |
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 think it would be better to create INJECTOR_PRE_R3
and INJECTOR_POST_R3
and switch on INJECTOR
level rather than complicating the InjectionToken
itself
@@ -2,15 +2,30 @@ | |||
{ | |||
"name": "APP_ROOT" | |||
}, | |||
{ |
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.
We are pulling in awful lot of stuff here. Is this expected?
@@ -417,6 +417,7 @@ export declare class InjectionToken<T> { | |||
constructor(_desc: string, options?: { | |||
providedIn?: Type<any> | 'root' | null; | |||
factory: () => T; | |||
ngElementId?: () => T; |
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.
Yeah, this exposes internal details to the world.
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.
+1
2bdbf6a
to
57f6eb8
Compare
You can preview 57f6eb8 at https://pr28009-57f6eb8.ngbuilds.io/. |
57f6eb8
to
a0bb68f
Compare
You can preview a0bb68f at https://pr28009-a0bb68f.ngbuilds.io/. |
a0bb68f
to
7fd4118
Compare
You can preview 7fd4118 at https://pr28009-7fd4118.ngbuilds.io/. |
7fd4118
to
04199c3
Compare
You can preview 04199c3 at https://pr28009-04199c3.ngbuilds.io/. |
04199c3
to
fe7100a
Compare
You can preview fe7100a at https://pr28009-fe7100a.ngbuilds.io/. |
fe7100a
to
9bc30a4
Compare
You can preview 9bc30a4 at https://pr28009-9bc30a4.ngbuilds.io/. |
9bc30a4
to
51d9122
Compare
You can preview 51d9122 at https://pr28009-51d9122.ngbuilds.io/. |
51d9122
to
f268a2b
Compare
You can preview f268a2b at https://pr28009-f268a2b.ngbuilds.io/. |
f268a2b
to
64d2d0e
Compare
You can preview 64d2d0e at https://pr28009-64d2d0e.ngbuilds.io/. |
packages/core/src/render3/di.ts
Outdated
@@ -296,6 +296,7 @@ export function getOrCreateInjectable<T>( | |||
tNode: TElementNode | TContainerNode | TElementContainerNode | null, lView: LView, | |||
token: Type<T>| InjectionToken<T>, flags: InjectFlags = InjectFlags.Default, | |||
notFoundValue?: any): T|null { | |||
if (token === INJECTOR_TOKEN) return new NodeInjector(tNode, lView) as unknown as T; |
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 am solving this exact issue here #28066 and I think that solution is better.
64d2d0e
to
6cabb22
Compare
You can preview 6cabb22 at https://pr28009-6cabb22.ngbuilds.io/. |
The issue was fixed by #28066 but the test still needs to be enabled |
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.
LGTM.
(the test was also re-enabled in a cleanup PR here, so you may have to rebase).
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This PR fixes FW-854.
My first approach was to add a special case for
INJECTOR
inNodeInjector.get()
, but this solution feels better.