Skip to content

Commit

Permalink
Refactor, hoist closure creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
msand committed Jan 6, 2019
1 parent 7415097 commit 732e575
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
4 changes: 2 additions & 2 deletions RNSVG.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
11 changes: 10 additions & 1 deletion lib/extract/extractResponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand All @@ -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:
Expand Down
21 changes: 14 additions & 7 deletions lib/extract/extractText.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit 732e575

Please sign in to comment.