fix(animations): repair flicker issues with WA polyfill (#16937)

Fixes #16919
Fixes #16918
This commit is contained in:
Matias Niemelä
2017-05-22 16:57:16 -07:00
committed by Chuck Jazdzewski
parent 08dfe91b95
commit e7d9fd8056
7 changed files with 85 additions and 13 deletions

View File

@ -123,16 +123,18 @@ export function copyStyles(
export function setStyles(element: any, styles: ɵStyleData) {
if (element['style']) {
Object.keys(styles).forEach(prop => element.style[prop] = styles[prop]);
Object.keys(styles).forEach(prop => {
const camelProp = dashCaseToCamelCase(prop);
element.style[camelProp] = styles[prop];
});
}
}
export function eraseStyles(element: any, styles: ɵStyleData) {
if (element['style']) {
Object.keys(styles).forEach(prop => {
// IE requires '' instead of null
// see https://github.com/angular/angular/issues/7916
element.style[prop] = '';
const camelProp = dashCaseToCamelCase(prop);
element.style[camelProp] = '';
});
}
}
@ -206,3 +208,8 @@ export function mergeAnimationOptions(
}
return destination;
}
const DASH_CASE_REGEXP = /-+([a-z0-9])/g;
export function dashCaseToCamelCase(input: string): string {
return input.replace(DASH_CASE_REGEXP, (...m: any[]) => m[1].toUpperCase());
}