mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-06 07:06:11 +00:00
perf: optimize handling of font properties in G elements
This commit is contained in:
@@ -155,13 +155,9 @@ exports[`supports CSS in style element 1`] = `
|
|||||||
</svg>"
|
</svg>"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
>
|
>
|
||||||
<RNSVGGroup
|
<RNSVGGroup>
|
||||||
font={Object {}}
|
|
||||||
>
|
|
||||||
<RNSVGDefs />
|
<RNSVGDefs />
|
||||||
<RNSVGGroup
|
<RNSVGGroup>
|
||||||
font={Object {}}
|
|
||||||
>
|
|
||||||
<RNSVGRect
|
<RNSVGRect
|
||||||
fill={4294901760}
|
fill={4294901760}
|
||||||
height={200}
|
height={200}
|
||||||
@@ -179,9 +175,7 @@ exports[`supports CSS in style element 1`] = `
|
|||||||
y={0}
|
y={0}
|
||||||
/>
|
/>
|
||||||
</RNSVGGroup>
|
</RNSVGGroup>
|
||||||
<RNSVGGroup
|
<RNSVGGroup>
|
||||||
font={Object {}}
|
|
||||||
>
|
|
||||||
<RNSVGRect
|
<RNSVGRect
|
||||||
fill={4294901760}
|
fill={4294901760}
|
||||||
fillOpacity={0.3}
|
fillOpacity={0.3}
|
||||||
|
|||||||
@@ -24,16 +24,24 @@ export default class G<P> extends Shape<P> {
|
|||||||
render() {
|
render() {
|
||||||
const { props } = this;
|
const { props } = this;
|
||||||
const prop = propsAndStyles(props);
|
const prop = propsAndStyles(props);
|
||||||
|
const extractedProps = extractProps(prop, this);
|
||||||
|
const font = extractFont(prop);
|
||||||
|
if (hasProps(font)) {
|
||||||
|
extractedProps.font = font;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<RNSVGGroup
|
<RNSVGGroup ref={this.refMethod} {...extractedProps}>
|
||||||
ref={this.refMethod}
|
|
||||||
{...extractProps(prop, this)}
|
|
||||||
font={extractFont(prop)}
|
|
||||||
>
|
|
||||||
{props.children}
|
{props.children}
|
||||||
</RNSVGGroup>
|
</RNSVGGroup>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasProps = (obj: {}) => {
|
||||||
|
for (let _ in obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
export const RNSVGGroup = requireNativeComponent('RNSVGGroup');
|
export const RNSVGGroup = requireNativeComponent('RNSVGGroup');
|
||||||
|
|||||||
Reference in New Issue
Block a user