diff --git a/__tests__/__snapshots__/react.js.snap b/__tests__/__snapshots__/react.js.snap index f87108f..aa737db 100644 --- a/__tests__/__snapshots__/react.js.snap +++ b/__tests__/__snapshots__/react.js.snap @@ -3469,7 +3469,12 @@ const UseSvg = props => { viewBox=\\"0 0 20 20\\" className={\`views-block \${Svg_hq411mi}\`} > - + { r={5} className=\\"views-block\\" /> - + @@ -3514,7 +3523,12 @@ const UseSvg = props => { viewBox=\\"0 0 20 20\\" className={\`views-block \${Svg_hq411mi}\`} > - + { r={5} className=\\"views-block\\" /> - + @@ -5632,19 +5650,21 @@ import Svg, { Path as SvgPath, Text as SvgText, } from 'react-native-svg'; -import { StyleSheet } from 'react-native'; -const styles = StyleSheet.create({ h8aawx1: { height: 20, width: 20 } }); const UseSvg = props => { return ( - + - + diff --git a/__tests__/views/UseSvg.view b/__tests__/views/UseSvg.view index 5cee3b8..30bf080 100644 --- a/__tests__/views/UseSvg.view +++ b/__tests__/views/UseSvg.view @@ -4,11 +4,13 @@ height 20 width 20 SvgPath d 0 20 +fill red SvgCircle cx 10 cy 5 r 5 SvgGroup +transform translate(6.000000, 5.000000) SvgPath d 1 SvgPath diff --git a/morph/react/property-style.js b/morph/react/property-style.js index 47e3e0d..c2afeca 100644 --- a/morph/react/property-style.js +++ b/morph/react/property-style.js @@ -4,11 +4,18 @@ import { getStyleType, isCode, isStyle, + isSvg, } from '../utils.js' import safe from './safe.js' export function enter(node, parent, state) { - if (!(isStyle(node) && parent.isBasic && !parent.isSvg)) return + if ( + !isStyle(node) || + !parent.isBasic || + (isSvg(parent) && state.isReactNative) || + parent.name === 'SvgGroup' + ) + return let styleForProperty, isScopedVal, _isProp diff --git a/morph/utils.js b/morph/utils.js index 1f28888..1b81d59 100644 --- a/morph/utils.js +++ b/morph/utils.js @@ -124,3 +124,5 @@ export const isList = node => node && node.type === 'Block' && node.name === 'List' export const isEmpty = list => list.length === 0 + +export const isSvg = node => /^Svg/.test(node.name) && node.isBasic diff --git a/package.json b/package.json index 296b44d..e3f5430 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "views-morph", - "version": "0.11.5", + "version": "0.11.6", "description": "Views language morpher", "main": "lib.js", "bin": {