-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Introduce debugging APIs for structural inspection of an application #41525
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
2567fc5
to
07cae06
Compare
0244d26
to
6505ad1
Compare
b3ab0e4
to
1c197ff
Compare
The aio-test failure is due to this line: Line 82 in 8c939dc
This is because of this redirect in Firebase: Line 86 in 820d95b
I think we can fix the test by changing the ngsw-config line to have a hyphen:
|
You can preview a297877 at https://pr41525-a297877.ngbuilds.io/. |
packages/core/src/render3/index.ts
Outdated
@@ -176,12 +176,15 @@ export { ɵɵtemplateRefExtractor} from './view_engine_compatibility_prebound'; | |||
// clang-format on | |||
|
|||
export { | |||
ComponentDebugMetadata as ComponentMetadata, |
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 this (and the directive on below) is correct. We should not be aliasing these anymore.
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.
Which is why they are appearing incorrectly in the API reference documentation: https://pr41525-a297877.ngbuilds.io/api/core/global#structures and are not clickable in the https://pr41525-a297877.ngbuilds.io/api/core/global/ngGetDirectiveMetadata doc
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.
Yes, you're right. Code's refactoring introduced it. Removing them now.
packages/core/src/render3/index.ts
Outdated
@@ -176,12 +176,15 @@ export { ɵɵtemplateRefExtractor} from './view_engine_compatibility_prebound'; | |||
// clang-format on | |||
|
|||
export { | |||
ComponentDebugMetadata as ComponentMetadata, |
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.
Which is why they are appearing incorrectly in the API reference documentation: https://pr41525-a297877.ngbuilds.io/api/core/global#structures and are not clickable in the https://pr41525-a297877.ngbuilds.io/api/core/global/ngGetDirectiveMetadata doc
This commit introduces a global debugging method `ng.getDirectiveMetadata` which returns the metadata for a directive or component instance.
This commit introduces the following optimizations: 1. We return an empty array for text nodes in `getDirectives` because Angular does not support attaching logic to them. This optimization improves performance of `getDirectives` significantly because text nodes often result in expensive calls to `loadLContext` since we can't resolve it from a parent node. 1. `getDirectives` now calls `loadLContext` with second argument `false` so it doesn't throw an error. This brings another significant improvement because prevents the VM from deoptimizing calls. BREAKING CHANGE: Previously the `ng.getDirectives` function threw an error in case a given DOM node had no Angular context associated with it (for example if a function was called for a DOM element outside of an Angular app). This behavior was inconsistent with other debugging utilities under `ng` namespace, which handled this situation without raising an exception. Now calling the `ng.getDirectives` function for such DOM nodes would result in an empty array returned from that function.
You can preview 9b60ae4 at https://pr41525-9b60ae4.ngbuilds.io/. |
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.
Reviewed-for: public-api
This commit introduces the following optimizations: 1. We return an empty array for text nodes in `getDirectives` because Angular does not support attaching logic to them. This optimization improves performance of `getDirectives` significantly because text nodes often result in expensive calls to `loadLContext` since we can't resolve it from a parent node. 1. `getDirectives` now calls `loadLContext` with second argument `false` so it doesn't throw an error. This brings another significant improvement because prevents the VM from deoptimizing calls. BREAKING CHANGE: Previously the `ng.getDirectives` function threw an error in case a given DOM node had no Angular context associated with it (for example if a function was called for a DOM element outside of an Angular app). This behavior was inconsistent with other debugging utilities under `ng` namespace, which handled this situation without raising an exception. Now calling the `ng.getDirectives` function for such DOM nodes would result in an empty array returned from that function. PR Close #41525
This commit refactors the code to replace `loadLContext` with `getLContext` calls. The only difference between these two functions is that the `loadLContext` supports throwing an error in case `LContext` can not be found. The investigation performed in angular#41525 revealed that throwing while retrieving `LContext` might have undesirable performance implications, so we should avoid that to make sure there are no accidental perf regressions in other parts of code that used `loadLContext`. Moreover, in most of the places the `loadLContext` was already called in a mode that prevented an error from being thrown, so this refactoring should have no effect on the actual behavior.
This commit refactors the code to replace `loadLContext` with `getLContext` calls. The only difference between these two functions is that the `loadLContext` supports throwing an error in case `LContext` can not be found. The investigation performed in #41525 revealed that throwing while retrieving `LContext` might have undesirable performance implications, so we should avoid that to make sure there are no accidental perf regressions in other parts of code that used `loadLContext`. Moreover, in most of the places the `loadLContext` was already called in a mode that prevented an error from being thrown, so this refactoring should have no effect on the actual behavior. PR Close #41606
This commit refactors the code to replace `loadLContext` with `getLContext` calls. The only difference between these two functions is that the `loadLContext` supports throwing an error in case `LContext` can not be found. The investigation performed in #41525 revealed that throwing while retrieving `LContext` might have undesirable performance implications, so we should avoid that to make sure there are no accidental perf regressions in other parts of code that used `loadLContext`. Moreover, in most of the places the `loadLContext` was already called in a mode that prevented an error from being thrown, so this refactoring should have no effect on the actual behavior. PR Close #41606
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. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the new behavior?
Introduces new debugging utilities for structural inspection of an application. The PR expands the
ng
namespace and adds a newgetDirectiveMetadata
method that returns the metadata for a specified directive or component instance.Additionally, the PR optimizes the
getDirectives
function by:loadLContext
with second argumentfalse
so it doesn't throw an errorDoes this PR introduce a breaking change?
ng.getDirectives
is called) in case there are no directives on the element