From 564590268b1de2e24b729ef98c1dc62a48e5d348 Mon Sep 17 00:00:00 2001 From: Dongyu Zhao Date: Tue, 12 Feb 2019 13:22:11 +0800 Subject: [PATCH] Fix SVG issues caused by Chrome 72 --- dist/Components/Basic/Svg.js | 8 ++++++-- examples/AdaptiveCards/Components/Basic/Svg.js | 8 ++++++-- package.json | 4 ++-- src/Components/Basic/Svg.tsx | 8 ++++++-- src/Views/CardElements/Image.tsx | 2 +- tool/src/assets/AdaptiveCards/Components/Basic/Svg.js | 8 ++++++-- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/dist/Components/Basic/Svg.js b/dist/Components/Basic/Svg.js index 2aaf7ad..aa3ef42 100644 --- a/dist/Components/Basic/Svg.js +++ b/dist/Components/Basic/Svg.js @@ -1,5 +1,5 @@ import * as React from 'react'; -import { WebView } from 'react-native'; +import { Platform, WebView } from 'react-native'; export class Svg extends React.Component { constructor(props) { super(props); @@ -30,7 +30,11 @@ export class Svg extends React.Component { } get src() { if (this.props.url) { - return this.props.url.replace('"', '\''); + let url = this.props.url.replace('"', '\''); + if (Platform.OS === 'android') { + return encodeURI(url); + } + return url; } return ''; } diff --git a/examples/AdaptiveCards/Components/Basic/Svg.js b/examples/AdaptiveCards/Components/Basic/Svg.js index 2aaf7ad..aa3ef42 100644 --- a/examples/AdaptiveCards/Components/Basic/Svg.js +++ b/examples/AdaptiveCards/Components/Basic/Svg.js @@ -1,5 +1,5 @@ import * as React from 'react'; -import { WebView } from 'react-native'; +import { Platform, WebView } from 'react-native'; export class Svg extends React.Component { constructor(props) { super(props); @@ -30,7 +30,11 @@ export class Svg extends React.Component { } get src() { if (this.props.url) { - return this.props.url.replace('"', '\''); + let url = this.props.url.replace('"', '\''); + if (Platform.OS === 'android') { + return encodeURI(url); + } + return url; } return ''; } diff --git a/package.json b/package.json index a03e60c..84370ae 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "devDependencies": { "@types/lodash": "latest", "@types/react": "latest", - "@types/react-native": "^0.57.15", + "@types/react-native": "^0.57.35", "@types/react-native-vector-icons": "^4.6.4", "del": "latest", "gulp": "latest", @@ -51,6 +51,6 @@ }, "dependencies": { "lodash": "latest", - "react-native-vector-icons": "^6.1.0" + "react-native-vector-icons": "^6.2.0" } } diff --git a/src/Components/Basic/Svg.tsx b/src/Components/Basic/Svg.tsx index 3132464..1f3ecca 100644 --- a/src/Components/Basic/Svg.tsx +++ b/src/Components/Basic/Svg.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { StyleProp, ViewStyle, WebView } from 'react-native'; +import { Platform, StyleProp, ViewStyle, WebView } from 'react-native'; interface IProps { url: string; @@ -52,7 +52,11 @@ export class Svg extends React.Component { private get src() { if (this.props.url) { - return this.props.url.replace('"', '\''); + let url = this.props.url.replace('"', '\''); + if (Platform.OS === 'android') { + return encodeURI(url); + } + return url; } return ''; } diff --git a/src/Views/CardElements/Image.tsx b/src/Views/CardElements/Image.tsx index 2091e80..61deb76 100644 --- a/src/Views/CardElements/Image.tsx +++ b/src/Views/CardElements/Image.tsx @@ -49,7 +49,7 @@ export class ImageView extends React.Component { // tslint:disable-next-line:max-line-length public setState(state: ((prevState: Readonly, props: Readonly) => (Pick | IState | null)) | (Pick | IState | null), callback?: () => void) { if (this.mounted) { - super.setState(state, callback); + super.setState(state as any, callback); } } diff --git a/tool/src/assets/AdaptiveCards/Components/Basic/Svg.js b/tool/src/assets/AdaptiveCards/Components/Basic/Svg.js index 2aaf7ad..aa3ef42 100644 --- a/tool/src/assets/AdaptiveCards/Components/Basic/Svg.js +++ b/tool/src/assets/AdaptiveCards/Components/Basic/Svg.js @@ -1,5 +1,5 @@ import * as React from 'react'; -import { WebView } from 'react-native'; +import { Platform, WebView } from 'react-native'; export class Svg extends React.Component { constructor(props) { super(props); @@ -30,7 +30,11 @@ export class Svg extends React.Component { } get src() { if (this.props.url) { - return this.props.url.replace('"', '\''); + let url = this.props.url.replace('"', '\''); + if (Platform.OS === 'android') { + return encodeURI(url); + } + return url; } return ''; }