Skip to content

Commit

Permalink
using omit from loadsh to exclude className from props when passing d…
Browse files Browse the repository at this point in the history
…own to Svg component
  • Loading branch information
mzorz committed Aug 24, 2018
1 parent bf65beb commit 6d5b37d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/components/src/primitives/svg/index.native.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* External dependencies
*/
import { omit } from 'lodash';
import {
Path,
G,
Expand All @@ -12,18 +16,14 @@ export {
export const SVG = ( props ) => {
if ( props.width !== undefined && props.height !== undefined ) {
return (
<Svg width={ props.width } height={ props.height } >
{ props.children }
</Svg>
<Svg { ...omit( props, [ 'className' ]) } />
);
}

// take viewport system to match the viewBox definition
// i.e. viewBox="0 0 24 24"
// i.e. viewBox="0 0 24 24" as <Svg> needs width and height to be explicitely set
const viewBoxCoords = props.viewBox.split( ' ' );
return (
<Svg width={ viewBoxCoords[ 2 ] } height={ viewBoxCoords[ 3 ] } >
{ props.children }
</Svg>
<Svg { ...omit( {...props, width: viewBoxCoords[ 2 ], height: viewBoxCoords[ 3 ] }, [ 'className' ]) } />
);
};

0 comments on commit 6d5b37d

Please sign in to comment.