[Ivy] Subclass/component now inheriting `@Component({ host: {} })` properties from superclass.
See original GitHub issue🐞 bug report
Affected Package
The issue is caused by package @angular/core
Is this a regression?
Yes, the previous version in which this bug was not present was: 8 or 9 with Ivy disabled
Description
With Ivy enabled, subclasses extending a superclass now inherit properties from @Component({})
. More specifically, subclasses now inherit host
properties such as (click)
and (keydown)
. In previous versions and Angular 9 with Ivy disabled, this does not happen.
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular9-class-inheritance
Note: Open the console and click on either Foo or Bar. Then, change the ‘enableIvy’ value in the ‘tsconfig.json’ file or in the StackBlitz settings menu on the left, rerun, and you’ll see a difference in what’s outputted to the console.
🌍 Your Environment
Angular Version:
9.1.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How can we expose inherited properties from a super ...
The 'propName' property doesn't exist on the component. Here's a test case to try: A parent LWC module, and for sake of simplicity,...
Read more >How To Extend Classes with Angular Component Inheritance
Learn how to use the power of inheritance to extend your Angular components ... Then, run the following command to create a Base...
Read more >Inheritance and dependency injection - angular - Stack Overflow
I could solve this by injecting MyService within each and every component and use that argument for the super() call but that's definetly ......
Read more >Component features with Angular Ivy - DEV Community
Component features is the Angular way of doing mixins without inheritance and without class or property decorators.
Read more >Understand Composition and inheritance in Angular.
import { Component, OnInit } from '@angular/core'; import { FormBuilder, ... calling the superclass and passing the form builder dependency.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@nbeekman This is actually an intentional change (see the first entry under “less common changes” in the Ivy compatibility guide.
Background: In View Engine (e.g. v8),
@HostBinding
would be inherited by subclasses, but equivalent bindings inhost
would not be, which could be confusing. In Ivy, we made it consistent so@HostBinding
andhost
were actually equivalent.That said, having a way to override host bindings sounds like an interesting use case, so I’ll keep this issue open for discussion.
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.