mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
The main logic of the `InheritDefinitionFeature` is to go through the prototype chain of a given Component and merge all Angular-specific information onto that Component def. The problem happens in case there is a Component in a hierarchy that also contains the `InheritDefinitionFeature` (i.e. it extends some other Component), so it inherits all Angular-specific information from its super class. As a result, the root Component may end up having duplicate information inherited from different Components in hierarchy. Let's consider the following structure: `GrandChild` extends `Child` that extends `Base` and the `Base` class has a `HostListener`. In this scenario `GrandChild` and `Child` will have `InheritDefinitionFeature` included into the `features` list. The processing will happend in the following order: - `Child` inherits `HostListener` from the `Base` class - `GrandChild` inherits `HostListener` from the `Child` class - since `Child` has a parent, `GrandChild` also inherits from the `Base` class The result is that the `GrandChild` def has duplicated host listener, which is not correct. This commit introduces additional logic that checks whether we came across a def that has `InheritDefinitionFeature` feature (which means that this def already inherited information from its super classes). If that's the case, we skip further fields-related inheritance logic, but keep going though the prototype chain to look for super classes that contain other features (like NgOnChanges), that we need to invoke for a given Component def. PR Close #34244 |
||
|---|---|---|
| .. | ||
| change_detection | ||
| compiler | ||
| debug | ||
| di | ||
| i18n | ||
| interface | ||
| linker | ||
| metadata | ||
| reflection | ||
| render | ||
| render3 | ||
| sanitization | ||
| testability | ||
| util | ||
| view | ||
| zone | ||
| application_init.ts | ||
| application_module.ts | ||
| application_ref.ts | ||
| application_tokens.ts | ||
| change_detection.ts | ||
| codegen_private_exports.ts | ||
| console.ts | ||
| core.externs.js | ||
| core.ts | ||
| core_private_export.ts | ||
| core_render3_private_export.ts | ||
| di.ts | ||
| error_handler.ts | ||
| errors.ts | ||
| event_emitter.ts | ||
| ivy_switch.ts | ||
| linker.ts | ||
| metadata.ts | ||
| platform_core_providers.ts | ||
| r3_symbols.ts | ||
| render.ts | ||
| version.ts | ||
| zone.ts | ||