react-inlinesvg
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -1,2 +0,1 @@ | ||
import once from 'once'; | ||
export declare const canUseDOM: () => boolean; | ||
@@ -10,3 +9,3 @@ export declare const supportsInlineSVG: () => boolean | null; | ||
} | ||
export declare const isSupportedEnvironment: (() => boolean | null) & once.FnProps<boolean | null>; | ||
export declare const randomString: (length?: number) => string; | ||
export declare const isSupportedEnvironment: any; | ||
export declare const randomString: (length: number) => string; |
@@ -15,7 +15,5 @@ "use strict"; | ||
})(); | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var once_1 = __importDefault(require("once")); | ||
// @ts-ignore | ||
var once_1 = require("once"); | ||
var exenv_1 = require("exenv"); | ||
@@ -47,3 +45,2 @@ exports.canUseDOM = function () { return exenv_1.canUseDOM; }; | ||
exports.randomString = function (length) { | ||
if (length === void 0) { length = 8; } | ||
var letters = 'abcdefghijklmnopqrstuvwxyz'; | ||
@@ -50,0 +47,0 @@ var numbers = '1234567890'; |
@@ -10,3 +10,3 @@ import * as React from 'react'; | ||
onError?: (error: InlineSVGError | IFetchError) => void; | ||
onLoad?: (src: URL | string, isCached: boolean) => void; | ||
onLoad?: (src: string, isCached: boolean) => void; | ||
preProcessor?: (code: string) => string; | ||
@@ -13,0 +13,0 @@ src: string; |
@@ -46,15 +46,5 @@ "use strict"; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var React = __importStar(require("react")); | ||
var react_from_dom_1 = __importDefault(require("react-from-dom")); | ||
var React = require("react"); | ||
var react_from_dom_1 = require("react-from-dom"); | ||
var helpers_1 = require("./helpers"); | ||
@@ -155,3 +145,3 @@ exports.STATUS = { | ||
}; | ||
_this.hash = props.uniqueHash || helpers_1.randomString(); | ||
_this.hash = props.uniqueHash || helpers_1.randomString(8); | ||
return _this; | ||
@@ -251,8 +241,8 @@ } | ||
var node = react_from_dom_1.default(svgText, { nodeOnly: true }); | ||
if (!node) { | ||
if (!node || !(node instanceof SVGSVGElement)) { | ||
throw new helpers_1.InlineSVGError('Could not convert the src to a DOM Node'); | ||
} | ||
node = this.updateSVGAttributes(node); | ||
var svg = this.updateSVGAttributes(node); | ||
if (description) { | ||
var originalDesc = node.querySelector('desc'); | ||
var originalDesc = svg.querySelector('desc'); | ||
if (originalDesc && originalDesc.parentNode) { | ||
@@ -263,6 +253,6 @@ originalDesc.parentNode.removeChild(originalDesc); | ||
descElement.innerHTML = description; | ||
node.prepend(descElement); | ||
svg.prepend(descElement); | ||
} | ||
if (title) { | ||
var originalTitle = node.querySelector('title'); | ||
var originalTitle = svg.querySelector('title'); | ||
if (originalTitle && originalTitle.parentNode) { | ||
@@ -273,5 +263,5 @@ originalTitle.parentNode.removeChild(originalTitle); | ||
titleElement.innerHTML = title; | ||
node.prepend(titleElement); | ||
svg.prepend(titleElement); | ||
} | ||
return node; | ||
return svg; | ||
} | ||
@@ -287,3 +277,3 @@ catch (error) { | ||
var element = react_from_dom_1.default(node); | ||
if (!element) { | ||
if (!element || !React.isValidElement(element)) { | ||
throw new helpers_1.InlineSVGError('Could not convert the src to a React element'); | ||
@@ -290,0 +280,0 @@ } |
{ | ||
"name": "react-inlinesvg", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "An SVG loader for React", | ||
@@ -35,3 +35,3 @@ "author": "Gil Barbara <gilbarbara@gmail.com>", | ||
"dependencies": { | ||
"react-from-dom": "^0.2.2", | ||
"react-from-dom": "^0.2.3", | ||
"exenv": "^1.2.2", | ||
@@ -41,30 +41,11 @@ "once": "^1.4.0" | ||
"devDependencies": { | ||
"@babel/cli": "^7.5.5", | ||
"@babel/core": "^7.5.5", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/plugin-proposal-decorators": "^7.4.4", | ||
"@babel/plugin-proposal-do-expressions": "^7.5.0", | ||
"@babel/plugin-proposal-export-default-from": "^7.5.2", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.5.2", | ||
"@babel/plugin-proposal-function-sent": "^7.5.0", | ||
"@babel/plugin-proposal-json-strings": "^7.2.0", | ||
"@babel/plugin-proposal-logical-assignment-operators": "^7.2.0", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4", | ||
"@babel/plugin-proposal-numeric-separator": "^7.2.0", | ||
"@babel/plugin-proposal-optional-chaining": "^7.2.0", | ||
"@babel/plugin-proposal-pipeline-operator": "^7.5.0", | ||
"@babel/plugin-proposal-throw-expressions": "^7.2.0", | ||
"@babel/plugin-syntax-dynamic-import": "^7.2.0", | ||
"@babel/plugin-syntax-import-meta": "^7.2.0", | ||
"@babel/plugin-transform-object-assign": "^7.2.0", | ||
"@babel/preset-env": "^7.5.5", | ||
"@babel/preset-react": "^7.0.0", | ||
"@babel/preset-typescript": "^7.3.3", | ||
"@types/enzyme": "^3.10.3", | ||
"@types/exenv": "^1.2.0", | ||
"@types/fetch-mock": "^7.3.1", | ||
"@types/jest": "^24.0.15", | ||
"@types/node": "^12.6.8", | ||
"@types/node-fetch": "^2.5.0", | ||
"@types/once": "^1.4.0", | ||
"@types/react": "^16.8.23", | ||
"@types/react-dom": "^16.8.4", | ||
"babel-eslint": "^10.0.2", | ||
"babel-jest": "^24.8.0", | ||
"@types/react-dom": "^16.8.5", | ||
"bundlesize": "^0.18.0", | ||
@@ -75,9 +56,2 @@ "chalk": "^2.4.2", | ||
"enzyme-adapter-react-16": "^1.14.0", | ||
"eslint": "^5.16.0", | ||
"eslint-config-airbnb": "^17.1.1", | ||
"eslint-config-prettier": "^5.1.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"eslint-plugin-react": "^7.14.2", | ||
"fetch-mock": "^7.3.9", | ||
@@ -100,2 +74,3 @@ "http-server": "^0.11.1", | ||
"ts-jest": "^24.0.2", | ||
"ts-node": "^8.3.0", | ||
"tslint": "^5.18.0", | ||
@@ -116,5 +91,3 @@ "tslint-config-prettier": "^1.18.0", | ||
"test:watch": "jest --watch --verbose", | ||
"lint": "npm run lint:ts && npm run lint:js", | ||
"lint:js": "eslint --ext .js --ext .jsx test tools", | ||
"lint:ts": "tslint -p tsconfig.json", | ||
"lint": "tslint 'src/**/*.ts?(x)' 'test/**/*.ts?(x)' 'tools/**/*.ts?(x)'", | ||
"format": "prettier \"**/*.{js,jsx,json,yml,yaml,css,less,scss,ts,tsx,md,graphql,mdx}\" --write", | ||
@@ -144,6 +117,6 @@ "validate": "npm run lint && npm run test && npm run build && npm run bundlesize", | ||
"hooks": { | ||
"post-merge": "node tools update", | ||
"pre-commit": "node tools has-commits && npm run validate" | ||
"post-merge": "ts-node tools update", | ||
"pre-commit": "ts-node tools has-commits && npm run validate" | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37
27360
470
Updatedreact-from-dom@^0.2.3