mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-01-12 22:51:09 +08:00
[fix] set textShadow if only blur and color provided
Mirrors a recent fix to React Native. Close #1182
This commit is contained in:
committed by
Nicolas Gallagher
parent
7663adebe8
commit
d880457f22
@@ -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', () => {
|
||||
|
||||
@@ -117,12 +117,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}`;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user