Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ function setAnimationStyle(element: any, name: string, value: string, index?: nu
element.style[prop] = value;
}

function getAnimationStyle(element: any, name: string) {
return element.style[ANIMATION_PROP + name];
export function getAnimationStyle(element: any, name: string) {
return element.style[ANIMATION_PROP + name] || '';
Comment thread
AndrewKushnir marked this conversation as resolved.
}

function countChars(value: string, char: string): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {ElementAnimationStyleHandler} from '../../../src/render/css_keyframes/element_animation_style_handler';
import {ElementAnimationStyleHandler, getAnimationStyle} from '../../../src/render/css_keyframes/element_animation_style_handler';
import {computeStyle} from '../../../src/util';

import {assertStyle, createElement, makeAnimationEvent, supportsAnimationEventCreation} from './shared';

const EMPTY_FN = () => {};
Expand Down Expand Up @@ -227,5 +226,23 @@ const EMPTY_FN = () => {};
element.dispatchEvent(event);
expect(done).toBeTruthy();
});

// Issue: https://github.com/angular/angular/issues/24094
it('should not break getAnimationStyle in old browsers', () => {
// Old browsers like Chrome Android 34 returns null if element.style
// is not found, modern browsers returns empty string.
const fakeElement = {
style: {
'animationstyle1': 'value',
'animationstyle2': null,
'animationstyle3': '',
'animation': null
}
};
expect(getAnimationStyle(fakeElement, 'style1')).toBe('value');
expect(getAnimationStyle(fakeElement, 'style2')).toBe('');
expect(getAnimationStyle(fakeElement, 'style3')).toBe('');
expect(getAnimationStyle(fakeElement, '')).toBe('');
});
});
}