ionic-team / stencil

A toolchain for building scalable, enterprise-ready component systems on top of TypeScript and Web Component standards. Stencil components can be distributed natively to React, Angular, Vue, and traditional web developers from a single, framework-agnostic codebase.
https://stenciljs.com
Other
12.5k stars 783 forks source link

Stencil components duplicate inside angular component when ngIf is used #527

Closed sebastien-yoobic closed 6 years ago

sebastien-yoobic commented 6 years ago

Stencil version:

 @stencil/core@0.4.3

I'm submitting a:

Current behavior: When a stencil component is inside an Angular component using *ngIf on the angular component leads to the duplication of the stencil component.

Expected behavior: Stencil components do not duplicate.

Steps to reproduce:

This repo replicate the issue: https://github.com/sebastien-yoobic/duplicate You can follow the instruction of the Readme, it contains an Angular and the Stencil app starter project. It compile the Stencil project and then use it inside an Angular application.

Related code:

Angular component html

<div *ngIf="visible">
    I am an Angular component, I contain a Stencil component
    <ng-content></ng-content>
</div>

ts

import { Input, Component } from '@angular/core';

@Component({
  selector: 'angular-component',
  templateUrl: './angular-component.html',
  styleUrls: ['./angular-component.scss']
})
export class AngularComponent {
  @Input() visible: boolean;

  constructor() {}
}

Use of stencil component form Stencil starter.

<div>
  <h2>Stencil Angular Duplicate</h2>
  <button (click)="onClick()">Show/hide Angular component</button>
  <angular-component [visible]="visible">
    <my-app></my-app>
  </angular-component>
</div>

Other information:

The repo is cleaner that the one before and I hope you will be able to reproduce the issue, If you have any trouble reproducing it, let me know.

Thanks,

ghaiat commented 6 years ago

@danbucholtz hey, we created another repo. it s a valid issue. ping me on slack if it s still not clear

danbucholtz commented 6 years ago

I have confirmed this is a real issue.

Thanks, Dan

adamdbradley commented 6 years ago

Awesome issue, thanks for filing this!