Refactor, hoist closure creation.

This commit is contained in:
Mikael Sand
2019-01-06 02:19:41 +02:00
parent 741509763c
commit 732e5752de
3 changed files with 26 additions and 10 deletions

View File

@@ -7,9 +7,9 @@ Pod::Spec.new do |s|
s.version = package['version']
s.summary = package['description']
s.license = package['license']
s.homepage = 'https://github.com/magicismight/react-native-svg'
s.homepage = 'https://github.com/react-native-community/react-native-svg'
s.authors = 'Horcrux Chen'
s.source = { :git => 'https://github.com/magicismight/react-native-svg.git', :tag => s.version }
s.source = { :git => 'https://github.com/react-native-community/react-native-svg.git', :tag => s.version }
s.source_files = 'ios/**/*.{h,m}'
s.requires_arc = true
s.platforms = { :ios => "8.0", :tvos => "9.2" }

View File

@@ -16,6 +16,15 @@ const touchableProps = [
"delayLongPress",
];
function hasTouchableProperty(props) {
for (let prop of touchableProps) {
if (props.hasOwnProperty(prop)) {
return true;
}
}
return false;
}
export default function(props, ref) {
const extractedProps = {};
@@ -30,7 +39,7 @@ export default function(props, ref) {
}
}
if (touchableProps.some(key => props[key])) {
if (hasTouchableProperty(props)) {
extractedProps.responsible = true;
Object.assign(extractedProps, {
onStartShouldSetResponder:

View File

@@ -93,6 +93,19 @@ export function extractFont(prop) {
return { ...font, ...ownedFont };
}
function getChildren(children, TSpan) {
const reactChildren = Children.toArray(children);
const result = [];
for (let child of reactChildren) {
if (typeof child === "string" || typeof child === "number") {
result.push(<TSpan>{child.toString()}</TSpan>);
} else {
result.push(child);
}
}
return result;
}
export default function(props, container = false, TSpan) {
const {
x,
@@ -116,13 +129,7 @@ export default function(props, container = false, TSpan) {
children = null;
}
} else if (Children.count(children) > 1 || Array.isArray(children)) {
children = Children.map(children, child => {
if (typeof child === "string" || typeof child === "number") {
return <TSpan>{child.toString()}</TSpan>;
} else {
return child;
}
});
children = getChildren(children, TSpan);
}
return {