diff --git a/elements/Pattern.js b/elements/Pattern.js index 862f19ec..21a18f6c 100644 --- a/elements/Pattern.js +++ b/elements/Pattern.js @@ -5,7 +5,7 @@ import { numberProp } from "../lib/props"; import PATTERN_UNITS from "../lib/PATTERN_UNITS"; import { PatternAttributes } from "../lib/attributes"; import extractTransform from "../lib/extract/extractTransform"; -import extractViewBox from "react-native-svg/lib/extract/extractViewBox"; +import extractViewBox from "../lib/extract/extractViewBox"; export default class extends Component { static displayName = "Pattern"; diff --git a/lib/attributes.js b/lib/attributes.js index a21b6efb..06489029 100644 --- a/lib/attributes.js +++ b/lib/attributes.js @@ -99,8 +99,6 @@ const UseAttributes = { href: true, width: true, height: true, - usewidth: true, - useheight: true, }; const SymbolAttributes = { @@ -171,8 +169,6 @@ const PatternAttributes = { y: true, width: true, height: true, - patternwidth: true, - patternheight: true, patternUnits: true, patternContentUnits: true, patternTransform: { @@ -186,8 +182,6 @@ const MaskAttributes = { y: true, width: true, height: true, - maskwidth: true, - maskheight: true, maskUnits: true, maskContentUnits: true, maskTransform: { @@ -235,8 +229,6 @@ const ImageAttributes = { y: true, width: true, height: true, - imagewidth: true, - imageheight: true, src: true, align: true, meetOrSlice: true @@ -256,8 +248,6 @@ const RectAttributes = { y: true, width: true, height: true, - rectwidth: true, - rectheight: true, rx: true, ry: true }; diff --git a/lib/extract/extractBrush.js b/lib/extract/extractBrush.js index b1625756..551702a6 100644 --- a/lib/extract/extractBrush.js +++ b/lib/extract/extractBrush.js @@ -10,14 +10,14 @@ export default function(colorOrBrush) { return [2]; } try { - let matched = colorOrBrush.match(patternReg); + const matched = colorOrBrush.match(patternReg); // brush if (matched) { return [1, matched[1]]; //todo: } else { // solid color - let [r, g, b, a = 1] = Color(colorOrBrush) + const [r, g, b, a = 1] = Color(colorOrBrush) .rgb() .array(); return [0, r / 255, g / 255, b / 255, a]; diff --git a/lib/extract/extractClipPath.js b/lib/extract/extractClipPath.js index c59ae52e..a9539e3e 100644 --- a/lib/extract/extractClipPath.js +++ b/lib/extract/extractClipPath.js @@ -6,13 +6,13 @@ const clipRules = { }; export default function(props) { - let { clipPath, clipRule } = props; - let clipPathProps = {}; + const { clipPath, clipRule } = props; + const clipPathProps = {}; if (clipPath) { clipPathProps.clipRule = clipRules[clipRule] === 0 ? 0 : 1; - let matched = clipPath.match(clipReg); + const matched = clipPath.match(clipReg); if (matched) { clipPathProps.clipPath = matched[1]; diff --git a/lib/extract/extractGradient.js b/lib/extract/extractGradient.js index 87e10395..4534b573 100644 --- a/lib/extract/extractGradient.js +++ b/lib/extract/extractGradient.js @@ -16,7 +16,7 @@ export default function(props) { Children.forEach(props.children, child => { if (child.props.stopColor && child.props.offset) { // convert percent to float. - let offset = percentToFloat(child.props.offset); + const offset = percentToFloat(child.props.offset); // add stop //noinspection JSUnresolvedFunction @@ -36,7 +36,7 @@ export default function(props) { const gradient = []; sorted.forEach(({ stop }) => { - let [r, g, b, a = 1] = stop.rgb().array(); + const [r, g, b, a = 1] = stop.rgb().array(); gradient.push(r / 255); gradient.push(g / 255); gradient.push(b / 255); diff --git a/lib/extract/extractProps.js b/lib/extract/extractProps.js index a2e4d6ab..bdaf283b 100644 --- a/lib/extract/extractProps.js +++ b/lib/extract/extractProps.js @@ -26,7 +26,7 @@ export default function(prop, ref) { } if (mask) { - let matched = mask.match(urlRegex); + const matched = mask.match(urlRegex); if (matched) { extractedProps.mask = matched[1]; diff --git a/lib/extract/extractTransform.js b/lib/extract/extractTransform.js index 3143b9a4..9c777dce 100644 --- a/lib/extract/extractTransform.js +++ b/lib/extract/extractTransform.js @@ -1,7 +1,8 @@ import Matrix2D from "../Matrix2D"; -import _ from "lodash"; -let pooledMatrix = new Matrix2D(); import peg from "pegjs"; +import _ from "lodash"; + +const pooledMatrix = new Matrix2D(); function transformToMatrix(props, transform) { pooledMatrix.reset(); @@ -228,19 +229,19 @@ export function props2transform(props) { if (props && typeof props === "string") { return props; } - let [originX, originY] = universal2axis( + const [originX, originY] = universal2axis( props.origin, props.originX, props.originY, ); - let [scaleX, scaleY] = universal2axis( + const [scaleX, scaleY] = universal2axis( props.scale, props.scaleX, props.scaleY, 1, ); - let [skewX, skewY] = universal2axis(props.skew, props.skewX, props.skewY); - let [translateX, translateY] = universal2axis( + const [skewX, skewY] = universal2axis(props.skew, props.skewX, props.skewY); + const [translateX, translateY] = universal2axis( props.translate, _.isNil(props.translateX) ? props.x || 0 : props.translateX, _.isNil(props.translateY) ? props.y || 0 : props.translateY, diff --git a/lib/extract/extractViewBox.js b/lib/extract/extractViewBox.js index 8a366a23..0eb8b10f 100644 --- a/lib/extract/extractViewBox.js +++ b/lib/extract/extractViewBox.js @@ -29,19 +29,19 @@ export default function(props) { return null; } - let params = viewBox.trim().split(spacesRegExp); + const params = viewBox.trim().split(spacesRegExp); - if (params.length === 4 && params.every(param => !isNaN(+params))) { + if (params.length === 4 && params.every(param => !isNaN(+param))) { console.warn("Invalid `viewBox` prop:" + viewBox); return null; } - let modes = preserveAspectRatio + const modes = preserveAspectRatio ? preserveAspectRatio.trim().split(spacesRegExp) : []; - let meetOrSlice = meetOrSliceTypes[modes[1]] || 0; - let align = alignEnum[modes[0]] || "xMidYMid"; + const meetOrSlice = meetOrSliceTypes[modes[1]] || 0; + const align = alignEnum[modes[0]] || "xMidYMid"; return { minX: +params[0], diff --git a/lib/percentToFloat.js b/lib/percentToFloat.js index 3886fad6..32678dbd 100644 --- a/lib/percentToFloat.js +++ b/lib/percentToFloat.js @@ -1,6 +1,6 @@ -let percentReg = /^([+\-]?\d+(?:\.\d+)?(?:[eE][+\-]?\d+)?)(%?)$/; +const percentReg = /^([+\-]?\d+(?:\.\d+)?(?:[eE][+\-]?\d+)?)(%?)$/; export default function(percent) { - let matched = percent.match(percentReg); + const matched = percent.match(percentReg); if (!matched) { console.warn( `\`${percent}\` is not a valid number or percentage string.`