fix(BrowserAdapter): correctly removes styles on IE

fixes #7916
This commit is contained in:
Victor Berchet 2016-09-27 17:57:26 -07:00 committed by Chuck Jazdzewski
parent ca3f9926f9
commit 3898dc488e
2 changed files with 6 additions and 2 deletions

View File

@ -67,7 +67,7 @@ export class NgStyle implements DoCheck {
private _setStyle(nameAndUnit: string, value: string): void {
const [name, unit] = nameAndUnit.split('.');
value = value !== null && value !== void(0) && unit ? `${value}${unit}` : value;
value = value && unit ? `${value}${unit}` : value;
this._renderer.setElementStyle(this._ngEl.nativeElement, name, value);
}

View File

@ -213,7 +213,11 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
setStyle(element: any, styleName: string, styleValue: string) {
element.style[styleName] = styleValue;
}
removeStyle(element: any, stylename: string) { element.style[stylename] = null; }
removeStyle(element: any, stylename: string) {
// IE requires '' instead of null
// see https://github.com/angular/angular/issues/7916
element.style[stylename] = '';
}
getStyle(element: any, stylename: string): string { return element.style[stylename]; }
hasStyle(element: any, styleName: string, styleValue: string = null): boolean {
const value = this.getStyle(element, styleName) || '';