question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
karacommented, May 15, 2020

@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 in host would not be, which could be confusing. In Ivy, we made it consistent so @HostBinding and host 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.

0reactions
angular-automatic-lock-bot[bot]commented, Jun 25, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found