Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcb1d77a

Browse files
SerginhoAndrewKushnir
authored andcommitted
fix(animations): getAnimationStyle causes exceptions in older browsers (#29709)
PR#29709 getAnimationStyle causes exceptions in older browsersPRClose#29709
1 parentdf231ad commitcb1d77a

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

‎packages/animations/browser/src/render/css_keyframes/element_animation_style_handler.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ function setAnimationStyle(element: any, name: string, value: string, index?: nu
140140
element.style[prop]=value;
141141
}
142142

143-
functiongetAnimationStyle(element:any,name:string){
144-
returnelement.style[ANIMATION_PROP+name];
143+
exportfunctiongetAnimationStyle(element:any,name:string){
144+
returnelement.style[ANIMATION_PROP+name]||'';
145145
}
146146

147147
functioncountChars(value:string,char:string):number{

‎packages/animations/browser/test/render/css_keyframes/element_animation_style_handler_spec.ts‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import{ElementAnimationStyleHandler}from'../../../src/render/css_keyframes/element_animation_style_handler';
8+
import{ElementAnimationStyleHandler,getAnimationStyle}from'../../../src/render/css_keyframes/element_animation_style_handler';
99
import{computeStyle}from'../../../src/util';
10-
1110
import{assertStyle,createElement,makeAnimationEvent,supportsAnimationEventCreation}from'./shared';
1211

1312
constEMPTY_FN=()=>{};
@@ -227,5 +226,23 @@ const EMPTY_FN = () => {};
227226
element.dispatchEvent(event);
228227
expect(done).toBeTruthy();
229228
});
229+
230+
// Issue: https://github.com/angular/angular/issues/24094
231+
it('should not break getAnimationStyle in old browsers',()=>{
232+
// Old browsers like Chrome Android 34 returns null if element.style
233+
// is not found, modern browsers returns empty string.
234+
constfakeElement={
235+
style:{
236+
'animationstyle1':'value',
237+
'animationstyle2':null,
238+
'animationstyle3':'',
239+
'animation':null
240+
}
241+
};
242+
expect(getAnimationStyle(fakeElement,'style1')).toBe('value');
243+
expect(getAnimationStyle(fakeElement,'style2')).toBe('');
244+
expect(getAnimationStyle(fakeElement,'style3')).toBe('');
245+
expect(getAnimationStyle(fakeElement,'')).toBe('');
246+
});
230247
});
231248
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp