From cf7b020c5dd50a61b744898a7abb033b2073b62b Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Mon, 19 Nov 2018 15:16:10 +0900 Subject: [PATCH] [fix] set textShadow if only blur and color provided Mirrors a recent fix to React Native. Close #1182 --- .../exports/StyleSheet/__tests__/createReactDOMStyle-test.js | 5 ++++- .../src/exports/StyleSheet/createReactDOMStyle.js | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/react-native-web/src/exports/StyleSheet/__tests__/createReactDOMStyle-test.js b/packages/react-native-web/src/exports/StyleSheet/__tests__/createReactDOMStyle-test.js index 104aaf85..77bf7147 100644 --- a/packages/react-native-web/src/exports/StyleSheet/__tests__/createReactDOMStyle-test.js +++ b/packages/react-native-web/src/exports/StyleSheet/__tests__/createReactDOMStyle-test.js @@ -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', () => { diff --git a/packages/react-native-web/src/exports/StyleSheet/createReactDOMStyle.js b/packages/react-native-web/src/exports/StyleSheet/createReactDOMStyle.js index 69d41fd7..fc4394fb 100644 --- a/packages/react-native-web/src/exports/StyleSheet/createReactDOMStyle.js +++ b/packages/react-native-web/src/exports/StyleSheet/createReactDOMStyle.js @@ -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}`; } };