@leeoniya/react-inlinesvg
Advanced tools
Comparing version
import * as React from 'react'; | ||
import { Props, State, StorageItem } from './types'; | ||
export declare const cacheStore: { | ||
[key: string]: StorageItem; | ||
}; | ||
export default class InlineSVG extends React.PureComponent<Props, State> { | ||
static cacheStore: { | ||
[key: string]: StorageItem; | ||
}; | ||
constructor(props: Props); | ||
@@ -8,0 +8,0 @@ private isActive; |
@@ -48,2 +48,3 @@ var __extends = (this && this.__extends) || (function () { | ||
import { STATUS, canUseDOM, isSupportedEnvironment, randomString, removeProperties, } from './helpers'; | ||
export var cacheStore = Object.create(null); | ||
var InlineSVG = /** @class */ (function (_super) { | ||
@@ -88,3 +89,3 @@ __extends(InlineSVG, _super); | ||
if (cacheRequests) { | ||
InlineSVG.cacheStore[src] = { content: '', status: STATUS.LOADING, queue: [] }; | ||
cacheStore[src] = { content: '', status: STATUS.LOADING, queue: [] }; | ||
} | ||
@@ -107,3 +108,3 @@ return fetch(src) | ||
if (cacheRequests) { | ||
var cache = InlineSVG.cacheStore[src]; | ||
var cache = cacheStore[src]; | ||
/* istanbul ignore else */ | ||
@@ -124,3 +125,3 @@ if (cache) { | ||
if (cacheRequests) { | ||
var cache = InlineSVG.cacheStore[src]; | ||
var cache = cacheStore[src]; | ||
/* istanbul ignore else */ | ||
@@ -131,3 +132,3 @@ if (cache) { | ||
}); | ||
delete InlineSVG.cacheStore[src]; | ||
delete cacheStore[src]; | ||
} | ||
@@ -144,3 +145,3 @@ } | ||
element: null, | ||
hasCache: !!props.cacheRequests && !!InlineSVG.cacheStore[props.src], | ||
hasCache: !!props.cacheRequests && !!cacheStore[props.src], | ||
status: STATUS.PENDING, | ||
@@ -301,3 +302,3 @@ }; | ||
var _a = _this.props, cacheRequests = _a.cacheRequests, src = _a.src; | ||
var cache = cacheRequests && InlineSVG.cacheStore[src]; | ||
var cache = cacheRequests && cacheStore[src]; | ||
if (cache) { | ||
@@ -344,3 +345,2 @@ /* istanbul ignore else */ | ||
}; | ||
InlineSVG.cacheStore = Object.create(null); | ||
InlineSVG.defaultProps = { | ||
@@ -347,0 +347,0 @@ cacheRequests: true, |
import * as React from 'react'; | ||
import { Props, State, StorageItem } from './types'; | ||
export declare const cacheStore: { | ||
[key: string]: StorageItem; | ||
}; | ||
export default class InlineSVG extends React.PureComponent<Props, State> { | ||
static cacheStore: { | ||
[key: string]: StorageItem; | ||
}; | ||
constructor(props: Props); | ||
@@ -8,0 +8,0 @@ private isActive; |
@@ -57,5 +57,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cacheStore = void 0; | ||
var React = require("react"); | ||
var react_from_dom_1 = require("react-from-dom"); | ||
var helpers_1 = require("./helpers"); | ||
exports.cacheStore = Object.create(null); | ||
var InlineSVG = /** @class */ (function (_super) { | ||
@@ -100,3 +102,3 @@ __extends(InlineSVG, _super); | ||
if (cacheRequests) { | ||
InlineSVG.cacheStore[src] = { content: '', status: helpers_1.STATUS.LOADING, queue: [] }; | ||
exports.cacheStore[src] = { content: '', status: helpers_1.STATUS.LOADING, queue: [] }; | ||
} | ||
@@ -119,3 +121,3 @@ return fetch(src) | ||
if (cacheRequests) { | ||
var cache = InlineSVG.cacheStore[src]; | ||
var cache = exports.cacheStore[src]; | ||
/* istanbul ignore else */ | ||
@@ -136,3 +138,3 @@ if (cache) { | ||
if (cacheRequests) { | ||
var cache = InlineSVG.cacheStore[src]; | ||
var cache = exports.cacheStore[src]; | ||
/* istanbul ignore else */ | ||
@@ -143,3 +145,3 @@ if (cache) { | ||
}); | ||
delete InlineSVG.cacheStore[src]; | ||
delete exports.cacheStore[src]; | ||
} | ||
@@ -156,3 +158,3 @@ } | ||
element: null, | ||
hasCache: !!props.cacheRequests && !!InlineSVG.cacheStore[props.src], | ||
hasCache: !!props.cacheRequests && !!exports.cacheStore[props.src], | ||
status: helpers_1.STATUS.PENDING, | ||
@@ -313,3 +315,3 @@ }; | ||
var _a = _this.props, cacheRequests = _a.cacheRequests, src = _a.src; | ||
var cache = cacheRequests && InlineSVG.cacheStore[src]; | ||
var cache = cacheRequests && exports.cacheStore[src]; | ||
if (cache) { | ||
@@ -356,3 +358,2 @@ /* istanbul ignore else */ | ||
}; | ||
InlineSVG.cacheStore = Object.create(null); | ||
InlineSVG.defaultProps = { | ||
@@ -359,0 +360,0 @@ cacheRequests: true, |
{ | ||
"name": "@leeoniya/react-inlinesvg", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"description": "An SVG loader for React", | ||
@@ -5,0 +5,0 @@ "author": "Gil Barbara <gilbarbara@gmail.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1405
0.07%83020
-0.25%