Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

marclaval
Copy link
Contributor

This PR fixes FW-854.

My first approach was to add a special case for INJECTOR in NodeInjector.get(), but this solution feels better.

@marclaval marclaval requested review from a team as code owners January 9, 2019 10:53
@mary-poppins
Copy link

You can preview 72bdb4f at https://pr28009-72bdb4f.ngbuilds.io/.

@marclaval marclaval force-pushed the injectorFromNodeInjector branch from 72bdb4f to 2bdbf6a Compare January 9, 2019 11:17
@marclaval marclaval requested a review from a team as a code owner January 9, 2019 11:17
@mary-poppins
Copy link

You can preview 2bdbf6a at https://pr28009-2bdbf6a.ngbuilds.io/.

@marclaval marclaval added action: review The PR is still awaiting reviews from at least one requested reviewer target: major This PR is targeted for the next major release comp: ivy labels Jan 9, 2019
@ngbot ngbot bot added this to the needsTriage milestone Jan 9, 2019
@@ -56,15 +56,21 @@ export class InjectionToken<T> {

readonly ngInjectableDef: never|undefined;

/** @internal */
readonly __NG_ELEMENT_ID__: (() => any)|undefined;
Copy link
Contributor

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.

@@ -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', {
Copy link
Contributor

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"
},
{
Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@marclaval marclaval force-pushed the injectorFromNodeInjector branch from 2bdbf6a to 57f6eb8 Compare January 10, 2019 10:51
@mary-poppins
Copy link

You can preview 57f6eb8 at https://pr28009-57f6eb8.ngbuilds.io/.

@marclaval marclaval force-pushed the injectorFromNodeInjector branch from 57f6eb8 to a0bb68f Compare January 10, 2019 13:59
@mary-poppins
Copy link

You can preview a0bb68f at https://pr28009-a0bb68f.ngbuilds.io/.

@marclaval marclaval force-pushed the injectorFromNodeInjector branch from a0bb68f to 7fd4118 Compare January 10, 2019 14:15
@mary-poppins
Copy link

You can preview 7fd4118 at https://pr28009-7fd4118.ngbuilds.io/.

@marclaval marclaval force-pushed the injectorFromNodeInjector branch from 7fd4118 to 04199c3 Compare January 10, 2019 14:50
@mary-poppins
Copy link

You can preview 04199c3 at https://pr28009-04199c3.ngbuilds.io/.

@marclaval marclaval force-pushed the injectorFromNodeInjector branch from 04199c3 to fe7100a Compare January 10, 2019 15:27
@mary-poppins
Copy link

You can preview fe7100a at https://pr28009-fe7100a.ngbuilds.io/.

@marclaval marclaval force-pushed the injectorFromNodeInjector branch from fe7100a to 9bc30a4 Compare January 10, 2019 15:33
@mary-poppins
Copy link

You can preview 9bc30a4 at https://pr28009-9bc30a4.ngbuilds.io/.

@marclaval marclaval force-pushed the injectorFromNodeInjector branch from 9bc30a4 to 51d9122 Compare January 10, 2019 15:49
@mary-poppins
Copy link

You can preview 51d9122 at https://pr28009-51d9122.ngbuilds.io/.

@marclaval marclaval force-pushed the injectorFromNodeInjector branch from 51d9122 to f268a2b Compare January 10, 2019 15:55
@mary-poppins
Copy link

You can preview f268a2b at https://pr28009-f268a2b.ngbuilds.io/.

@marclaval marclaval force-pushed the injectorFromNodeInjector branch from f268a2b to 64d2d0e Compare January 11, 2019 10:22
@mary-poppins
Copy link

You can preview 64d2d0e at https://pr28009-64d2d0e.ngbuilds.io/.

@@ -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;
Copy link
Contributor

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.

@marclaval marclaval force-pushed the injectorFromNodeInjector branch from 64d2d0e to 6cabb22 Compare January 14, 2019 09:17
@mary-poppins
Copy link

You can preview 6cabb22 at https://pr28009-6cabb22.ngbuilds.io/.

@marclaval marclaval changed the title fix(ivy): NodeInjector should know how to get itself (INJECTOR) test(ivy): NodeInjector should know how to get itself (INJECTOR) Jan 14, 2019
@marclaval
Copy link
Contributor Author

The issue was fixed by #28066 but the test still needs to be enabled

Copy link
Contributor

@kara kara left a 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).

@kara kara removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Jan 14, 2019
@kara kara added the action: merge The PR is ready for merge by the caretaker label Jan 14, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants