FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(animations): getAnimationStyle causes exceptions in older browsers by Serginho · Pull Request #29709 · angular/angular · GitHub

Repository navigation

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

Filter by extension

Filter by extension .ts  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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('');
});
});
}

Back | FazBrowse Home | New Git URL