fix(ivy): ensure interpolated style/classes do not cause tracking issues for bindings (#28190)

With the refactoring or how styles/classes are implmented in Ivy,
interpolation has caused the binding code to mess up since interpolation
itself takes up its own slot in Ivy's memory management code. This patch
makes sure that interpolation works as expected with class and style
bindings.

Jira issue: FW-944

PR Close #28190
This commit is contained in:
Matias Niemelä
2019-01-16 11:11:33 -08:00
committed by Alex Rickabaugh
parent 896cf35afb
commit 0d6913f037
8 changed files with 252 additions and 128 deletions

View File

@ -1916,6 +1916,30 @@ describe('render3 integration test', () => {
fixture.update();
expect(target.style.getPropertyValue('width')).toEqual('777px');
});
it('should properly handle and render interpolation for class attribute bindings', () => {
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
if (rf & RenderFlags.Create) {
elementStart(0, 'div');
elementStyling();
elementEnd();
}
if (rf & RenderFlags.Update) {
elementStylingMap(0, interpolation2('-', ctx.name, '-', ctx.age, '-'));
elementStylingApply(0);
}
}, 1, 2);
const fixture = new ComponentFixture(App);
const target = fixture.hostElement.querySelector('div') !;
expect(target.classList.contains('-fred-36-')).toBeFalsy();
fixture.component.name = 'fred';
fixture.component.age = '36';
fixture.update();
expect(target.classList.contains('-fred-36-')).toBeTruthy();
});
});
});