Skip to content
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

assertion error This TNode does not belong to this TView #39779

Closed
rakia opened this issue Nov 20, 2020 · 6 comments
Closed

assertion error This TNode does not belong to this TView #39779

rakia opened this issue Nov 20, 2020 · 6 comments
Assignees
Labels
area: core Issues related to the framework runtime core: DOM rendering needs reproduction This issue needs a reproduction in order for the team to investigate further P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Milestone

Comments

@rakia
Copy link

rakia commented Nov 20, 2020

Hi guys,

I have a dynamic material table implemented following the concept explained in the angular material documentation: https://material.angular.io/components/table/examples

<table mat-table [dataSource]="data" class="mat-elevation-z8">
  <ng-container [matColumnDef]="column" *ngFor="let column of displayedColumns">
    <th mat-header-cell *matHeaderCellDef> {{column}} </th>
    <td mat-cell *matCellDef="let element"> {{element[column]}} </td>
  </ng-container>

  <tr mat-header-row *matHeaderRowDef="columnsToDisplay"></tr>
  <tr mat-row *matRowDef="let row; columns: columnsToDisplay;"></tr>
</table>

It was working well with Angular 10, but after migrating to Angular 11, Angular Material 11, and Typescript 4, I got the following error on the browser console whenever I open a view that should render this table:

🔥 Error

ERROR Error: ASSERTION ERROR: This TNode does not belong to this TView. [Expected=> [object Object] == [object Object] <=Actual]
    at throwError (core.js:720)
    at assertEqual (core.js:671)
    at assertTNodeForTView (core.js:1996)
    at assertTNodeForLView (core.js:1991)
    at getNativeByTNode (core.js:2594)
    at getInsertInFrontOfRNodeWithNoI18n (core.js:6688)
    at getInsertInFrontOfRNode (core.js:6673)
    at appendChild (core.js:6720)
    at createContainerRef (core.js:10669)
    at createSpecialToken (core.js:26038)

🌍 My Environment

I have Angular 11, Angular Material 11, Typescript 4

Could you please tell me what should I change to get it working correctly again?

Thanks for your help!

@petebacondarwin
Copy link
Member

Would you be able to create a StackBlitz that demonstrates this failure that we can debug?

@petebacondarwin petebacondarwin added area: core Issues related to the framework runtime core: DOM rendering P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Nov 20, 2020
@ngbot ngbot bot modified the milestone: Backlog Nov 20, 2020
@mhevery
Copy link
Contributor

mhevery commented Nov 20, 2020

Yes, please I need a repro to be able to get to the bottom of this.

@mhevery mhevery added the needs reproduction This issue needs a reproduction in order for the team to investigate further label Nov 20, 2020
@rakia
Copy link
Author

rakia commented Nov 22, 2020

here is the github repository where you can see the error: https://github.com/rakia/ng-dynamic-table.git

https://github.com/rakia/ng-dynamic-table

@rakia
Copy link
Author

rakia commented Nov 22, 2020

Good news,
removing #matrow from dynamic-table.component.html and replacing
<tr #matrow mat-row *matRowDef="let row; columns: displayedColumns;" (click)="selectRow(row)"></tr>
by
<tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="selectRow(row)"></tr>
has resolved my problem.

I have changed a lot of DOM before finding out the right source of the exception. Instead of just "TNode ... TView [Expected=> [object Object] == [object Object] <=Actual]", it would be really helpful if the error message thrown by Angular will be more clear.

Thank you guys for offering us a better developement experience!

@mhevery
Copy link
Contributor

mhevery commented Nov 23, 2020

Thanks for the repro. If you upgrade to 11.0.2 the error will disappear. Closing as already fixed

@mhevery mhevery closed this as completed Nov 23, 2020
@angular-automatic-lock-bot
Copy link

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 Dec 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime core: DOM rendering needs reproduction This issue needs a reproduction in order for the team to investigate further P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

3 participants