Skip to content
Permalink
Browse files

fix(ivy): reset style property using ngStyle fix (#33920)

PR Close #33920
  • Loading branch information
raizemm authored and alxhub committed Nov 20, 2019
1 parent b31afc2 commit b8ba6b036cae1c987df8b21757042bdda47bae7c
Showing with 27 additions and 1 deletion.
  1. +1 −1 packages/core/src/render3/styling/bindings.ts
  2. +26 −0 packages/core/test/acceptance/styling_spec.ts
@@ -1102,7 +1102,7 @@ function removeStylingValues(
const value = getMapValue(arr, i);
if (value) {
const prop = getMapProp(arr, i);
applyFn(renderer, element, prop, false);
applyFn(renderer, element, prop, null);
}
}
}
@@ -1936,6 +1936,32 @@ describe('styling', () => {
expect(div.classList.contains('bar')).toBeTruthy();
});

it('should allow to reset style property value defined using ngStyle', () => {
@Component({
template: `
<div [ngStyle]="s"></div>
`
})
class Cmp {
s: any = {opacity: '1'};

clearStyle(): void { this.s = null; }
}

TestBed.configureTestingModule({declarations: [Cmp]});
const fixture = TestBed.createComponent(Cmp);
const comp = fixture.componentInstance;
fixture.detectChanges();

const div = fixture.nativeElement.querySelector('div');
expect(div.style.opacity).toEqual('1');

comp.clearStyle();
fixture.detectChanges();

expect(div.style.opacity).toEqual('');
});

it('should allow detectChanges to be run in a property change that causes additional styling to be rendered',
() => {
@Component({

0 comments on commit b8ba6b0

Please sign in to comment.
You can’t perform that action at this time.