Skip to content

feat(ivy): expose node injector as part of debug context - #26210

Closed
pkozlowski-opensource wants to merge 1 commit into
angular:masterfrom
pkozlowski-opensource:context_discovery_node_injector
Closed

pkozlowski-opensource wants to merge 1 commit into
angular:masterfrom
pkozlowski-opensource:context_discovery_node_injector

Conversation

@pkozlowski-opensource

Copy link
Copy Markdown
Member

This PR exposes node injector as part as context discovery utils.

Additionally it fixes a bug where tokens with NG_ELEMENT_ID=0 wouldn't be injected correctly (as 0 is falsy and (token as any)[NG_ELEMENT_ID] || null would always return null for the very first token).

@matsko @kara I didn't do this in this PR but I would propose that we:

  • remove the existing getInjector() util function;
  • rename the getNodeInjector proposed here to getInjector()

I'm proposing this since I believe that the method proposed here is more useful as end users would probably get access to tokens regardless if those come from a node injector or module injector.

@pkozlowski-opensource pkozlowski-opensource added action: review The PR is still awaiting reviews from at least one requested reviewer comp: ivy target: major This PR is targeted for the next major release labels Oct 2, 2018
@mary-poppins

Copy link
Copy Markdown

You can preview 3532333 at https://pr26210-3532333.ngbuilds.io/.

@pkozlowski-opensource
pkozlowski-opensource force-pushed the context_discovery_node_injector branch from 3532333 to 4132df3 Compare October 2, 2018 13:33
@mary-poppins

Copy link
Copy Markdown

You can preview 4132df3 at https://pr26210-4132df3.ngbuilds.io/.

@pkozlowski-opensource
pkozlowski-opensource force-pushed the context_discovery_node_injector branch from 4132df3 to 4378cf7 Compare October 2, 2018 13:48
@mary-poppins

Copy link
Copy Markdown

You can preview 4378cf7 at https://pr26210-4378cf7.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 77a27ae at https://pr26210-77a27ae.ngbuilds.io/.

Comment thread packages/core/src/render3/di.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for catching this! Does one of the tests below ensure we won't break it again?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread packages/core/src/render3/util.ts Outdated

@kara kara Oct 2, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We already have a getTNode function in instructions.ts, so we probably shouldn't add another one. Seems like we should just add another arg to it for hostView? It should
also probably live here in util, though you'll probably have to move some of the related methods over from context_discovery.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Decided to drop this util altogether for now as: it is used in one place only and the one in instructions is quite different (LViewData vs. TView, indexes with no offset vs. offset etc.). So the benefit / hassle ratio is too low for me here.

I will probably come back to this if I see this util being beneficial in some other places in the future.

@mhevery

mhevery commented Oct 3, 2018

Copy link
Copy Markdown
Contributor

remove the existing getInjector() util function;
rename the getNodeInjector proposed here to getInjector()

@pkozlowski-opensource Yes please!

@mhevery mhevery left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please take care of the comments, LGTM otherwise. Ping when ready for full approval.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just replace getInject implementation above with this implementation.

@pkozlowski-opensource
pkozlowski-opensource force-pushed the context_discovery_node_injector branch from 77a27ae to 1db1433 Compare October 3, 2018 08:31
@mary-poppins

Copy link
Copy Markdown

You can preview 1db1433 at https://pr26210-1db1433.ngbuilds.io/.

@pkozlowski-opensource
pkozlowski-opensource force-pushed the context_discovery_node_injector branch from 1db1433 to 540c119 Compare October 3, 2018 08:47
@mary-poppins

Copy link
Copy Markdown

You can preview 540c119 at https://pr26210-540c119.ngbuilds.io/.

@pkozlowski-opensource
pkozlowski-opensource force-pushed the context_discovery_node_injector branch from 540c119 to 7aacfa6 Compare October 3, 2018 09:02
@mary-poppins

Copy link
Copy Markdown

You can preview 7aacfa6 at https://pr26210-7aacfa6.ngbuilds.io/.

@kara kara left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@kara

kara commented Oct 3, 2018

Copy link
Copy Markdown
Contributor

presubmit

@pkozlowski-opensource pkozlowski-opensource added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer action: merge The PR is ready for merge by the caretaker labels Oct 3, 2018
@mhevery
mhevery force-pushed the context_discovery_node_injector branch from 7aacfa6 to 52d2f13 Compare October 4, 2018 00:00
@mary-poppins

Copy link
Copy Markdown

You can preview 52d2f13 at https://pr26210-52d2f13.ngbuilds.io/.

@pkozlowski-opensource
pkozlowski-opensource force-pushed the context_discovery_node_injector branch from 52d2f13 to 81ba38e Compare October 4, 2018 08:53
@mary-poppins

Copy link
Copy Markdown

You can preview 81ba38e at https://pr26210-81ba38e.ngbuilds.io/.

@pkozlowski-opensource pkozlowski-opensource added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Oct 4, 2018
@pkozlowski-opensource

Copy link
Copy Markdown
Member Author

Marking as merge-assistance since the google3 presubmit is needed / pending (despite the fact that it was run by Kara: #26210 (comment)

@kara kara removed the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Oct 4, 2018
@jasonaden jasonaden closed this in fdaf573 Oct 4, 2018
@angular-automatic-lock-bot

Copy link
Copy Markdown

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.

5 participants