Skip to content

Commit

Permalink
Merge 2367ed8 into 2eaf850
Browse files Browse the repository at this point in the history
  • Loading branch information
dkamburov committed Jul 31, 2018
2 parents 2eaf850 + 2367ed8 commit 218c711
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions dist/npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "5.0.3",
"description" : "A packaged version of Ignite UI wrappers for Angular",
"license": "MIT",
"types": "main.d.ts",
"main": "bundles/igniteui-angular-wrappers.umd.js",
"repository": {
"type": "git",
Expand Down
9 changes: 6 additions & 3 deletions src/igcontrolbase/igcontrolbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ export class IgControlBase<Model> implements DoCheck {
}

ngOnDestroy() {
jQuery(this._el)[this._widgetName]("destroy");
jQuery(this._el).remove();
jQuery(this._nativeElement).remove();
// igZoombar should be attached to body when being destroyed
if (this._widgetName !== "igZoombar" || document.body.contains(this._el)) {
jQuery(this._el)[this._widgetName]("destroy");
jQuery(this._el).remove();
jQuery(this._nativeElement).remove();
}
}
}
19 changes: 19 additions & 0 deletions tests/unit/igdatachart/chart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ export function main() {
done();
});
});

it('Zoombar should destroy correctly', (done) => {
var template = '<div><div *ngIf="isChartAreaVisible"><ig-data-chart widgetId="datachart1" [(options)]="opts"></ig-data-chart><ig-zoombar [(options)]="zoombarOpts" widgetId="zoombar"></ig-zoombar></div></div>';
TestBed.overrideComponent(TestComponent, {
set: {
template: template
}
});
TestBed.compileComponents().then(() => {
let fixture = TestBed.createComponent(TestComponent);
fixture.detectChanges();
fixture.componentInstance.isChartAreaVisible = false;
fixture.detectChanges();
expect($(fixture.debugElement.nativeElement).find("#datachart1").data("igDataChart")).toBeUndefined();
expect($(fixture.debugElement.nativeElement).find("#zoombar").data("igZoombar")).toBeUndefined();
done();
});
});
});
}

Expand All @@ -110,6 +128,7 @@ class TestComponent {
public opts2: any;
private zoombarOpts: any;
public data: Array<any>;
public isChartAreaVisible: boolean = true;
@ViewChild(Infragistics.IgDataChartComponent) public viewChild: Infragistics.IgDataChartComponent;
@ViewChild(Infragistics.IgZoombarComponent) public viewChild2: Infragistics.IgZoombarComponent;

Expand Down

0 comments on commit 218c711

Please sign in to comment.