From 6b5d290829a17291e658d5a292659b87ed57960f Mon Sep 17 00:00:00 2001 From: Mochamad Gufron Date: Fri, 10 Nov 2017 08:41:25 +0700 Subject: [PATCH 1/3] add clippath --- index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.js b/index.js index c6419021..7790d4ed 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource' import Svg,{ Circle, Ellipse, + ClipPath, G , LinearGradient, RadialGradient, @@ -26,6 +27,7 @@ import * as utils from './utils'; const ACCEPTED_SVG_ELEMENTS = [ 'svg', 'g', + 'clipPath', 'circle', 'path', 'rect', @@ -44,6 +46,7 @@ const ACCEPTED_SVG_ELEMENTS = [ // Attributes from SVG elements that are mapped directly. const SVG_ATTS = ['viewBox', 'width', 'height']; const G_ATTS = ['id']; +const CLIP_PATH_ATTS = ['id']; const CIRCLE_ATTS = ['cx', 'cy', 'r']; const PATH_ATTS = ['d']; @@ -158,6 +161,9 @@ class SvgUri extends Component{ switch (node.nodeName) { case 'svg': componentAtts = this.obtainComponentAtts(node, SVG_ATTS); + if (!componentAtts.viewBox) { + componentAtts.viewBox = `0 0 ${componentAtts.width} ${componentAtts.height}`; + } if (this.props.width) { componentAtts.width = this.props.width; } @@ -169,6 +175,9 @@ class SvgUri extends Component{ case 'g': componentAtts = this.obtainComponentAtts(node, G_ATTS); return {childs}; + case 'clipPath': + componentAtts = this.obtainComponentAtts(node, CLIP_PATH_ATTS); + return {childs}; case 'path': componentAtts = this.obtainComponentAtts(node, PATH_ATTS); return {childs}; From 6f7b2c740b58455a4c6ce0d009d5f2696d8c27b2 Mon Sep 17 00:00:00 2001 From: Mochamad Gufron Date: Fri, 10 Nov 2017 08:43:26 +0700 Subject: [PATCH 2/3] fix closing tag --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7790d4ed..11269e7c 100644 --- a/index.js +++ b/index.js @@ -177,7 +177,7 @@ class SvgUri extends Component{ return {childs}; case 'clipPath': componentAtts = this.obtainComponentAtts(node, CLIP_PATH_ATTS); - return {childs}; + return {childs}; case 'path': componentAtts = this.obtainComponentAtts(node, PATH_ATTS); return {childs}; From a13713f3d639519cd73f1f600502b898a9b79c04 Mon Sep 17 00:00:00 2001 From: Mochamad Gufron Date: Thu, 21 Dec 2017 22:23:07 +0700 Subject: [PATCH 3/3] supress error of parsing xml --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 11269e7c..0c1d2e33 100644 --- a/index.js +++ b/index.js @@ -299,7 +299,7 @@ class SvgUri extends Component{ ); } catch(e){ - console.error("ERROR SVG", e); + console.log("ERROR SVG", e); return null; } }