Skip to content

Commit

Permalink
[fix] set textShadow if only blur and color provided
Browse files Browse the repository at this point in the history
Mirrors a recent fix to React Native.

Close #1182
  • Loading branch information
skahack authored and necolas committed Mar 8, 2019
1 parent 49edcb2 commit cf7b020
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ describe('StyleSheet/createReactDOMStyle', () => {
});

test('textShadowColor and textShadowRadius only', () => {
expect(createReactDOMStyle({ textShadowColor: 'red', textShadowRadius: 5 })).toEqual({});
expect(createReactDOMStyle({ textShadowColor: 'red', textShadowRadius: 0 })).toEqual({});
expect(createReactDOMStyle({ textShadowColor: 'red', textShadowRadius: 5 })).toEqual({
textShadow: '0px 0px 5px rgba(255,0,0,1.00)'
});
});

test('textShadowColor, textShadowOffset, textShadowRadius', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ const resolveTextDecoration = (resolvedStyle, style) => {
const resolveTextShadow = (resolvedStyle, style) => {
const { textShadowColor, textShadowOffset, textShadowRadius } = style;
const { height, width } = textShadowOffset || defaultOffset;
const radius = textShadowRadius || 0;
const offsetX = normalizeValue(null, width);
const offsetY = normalizeValue(null, height);
const blurRadius = normalizeValue(null, textShadowRadius || 0);
const blurRadius = normalizeValue(null, radius);
const color = normalizeColor(textShadowColor);

if (color && (height !== 0 || width !== 0)) {
if (color && (height !== 0 || width !== 0 || radius !== 0)) {
resolvedStyle.textShadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`;
}
};
Expand Down

0 comments on commit cf7b020

Please sign in to comment.