react-inlinesvg 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # react-inlinesvg
2
2
 
3
- [![NPM version](https://badge.fury.io/js/react-inlinesvg.svg)](https://www.npmjs.com/package/react-inlinesvg) [![Build Status](https://travis-ci.com/gilbarbara/react-inlinesvg.svg?branch=master)](https://travis-ci.com/gilbarbara/react-inlinesvg) [![Maintainability](https://api.codeclimate.com/v1/badges/c7e42fe511b80cc25760/maintainability)](https://codeclimate.com/github/gilbarbara/react-inlinesvg/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/c7e42fe511b80cc25760/test_coverage)](https://codeclimate.com/github/gilbarbara/react-inlinesvg/test_coverage)
3
+ [![NPM version](https://badge.fury.io/js/react-inlinesvg.svg)](https://www.npmjs.com/package/react-inlinesvg) [![CI](https://github.com/gilbarbara/react-inlinesvg/actions/workflows/main.yml/badge.svg)](https://github.com/gilbarbara/react-inlinesvg/actions/workflows/main.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/c7e42fe511b80cc25760/maintainability)](https://codeclimate.com/github/gilbarbara/react-inlinesvg/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/c7e42fe511b80cc25760/test_coverage)](https://codeclimate.com/github/gilbarbara/react-inlinesvg/test_coverage)
4
4
 
5
5
  Load inline, local or remote SVGs in your React components.
6
6
 
7
+ View the [demo](https://codesandbox.io/s/github/gilbarbara/react-inlinesvg/tree/main/demo)
8
+
7
9
  ## Highlights
8
10
 
9
11
  - 🏖 **Easy to use:** Just set the `src`
@@ -21,20 +23,18 @@ npm i react-inlinesvg
21
23
  And import it into your code:
22
24
 
23
25
  ```tsx
24
- import React, { useRef } from 'react';
25
- import SVG, { Props as SVGProps } from 'react-inlinesvg';
26
-
27
- const Logo = React.forwardRef<SVGElement, SVGProps>((props, ref) => (
28
- <SVG innerRef={ref} title="MyLogo" {...props} />
29
- ));
30
-
31
- export function App() {
32
- const logo = useRef<SVGElement>(null);
26
+ import React from 'react';
27
+ import SVG from 'react-inlinesvg';
33
28
 
29
+ export default function App() {
34
30
  return (
35
31
  <main>
36
- <SVG src={`${process.env.PUBLIC_URL}/menu.svg`} width={24} height="auto" title="Menu" />
37
- <Logo ref={logo} src={`${process.env.PUBLIC_URL}/logo.svg`} />
32
+ <SVG
33
+ src="https://cdn.svgporn.com/logos/react.svg"
34
+ width={128}
35
+ height="auto"
36
+ title="React"
37
+ />
38
38
  </main>
39
39
  );
40
40
  }
package/esm/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export declare const cacheStore: {
4
4
  [key: string]: StorageItem;
5
5
  };
6
6
  export default class InlineSVG extends React.PureComponent<Props, State> {
7
+ private isInitialized;
7
8
  private isActive;
8
9
  private readonly hash;
9
10
  static defaultProps: {
package/esm/index.js CHANGED
@@ -57,83 +57,117 @@ var InlineSVG = /** @class */ (function (_super) {
57
57
  __extends(InlineSVG, _super);
58
58
  function InlineSVG(props) {
59
59
  var _this = _super.call(this, props) || this;
60
- _this.isActive = false;
61
- _this.handleLoad = function (content) {
62
- /* istanbul ignore else */
63
- if (_this.isActive) {
64
- _this.setState({
65
- content: content,
66
- status: STATUS.LOADED,
67
- }, _this.getElement);
68
- }
69
- };
70
- _this.handleError = function (error) {
71
- var onError = _this.props.onError;
72
- var status = error.message === 'Browser does not support SVG' ? STATUS.UNSUPPORTED : STATUS.FAILED;
73
- /* istanbul ignore else */
74
- if (_this.isActive) {
75
- _this.setState({ status: status }, function () {
76
- /* istanbul ignore else */
77
- if (typeof onError === 'function') {
78
- onError(error);
79
- }
80
- });
60
+ Object.defineProperty(_this, "isInitialized", {
61
+ enumerable: true,
62
+ configurable: true,
63
+ writable: true,
64
+ value: false
65
+ });
66
+ Object.defineProperty(_this, "isActive", {
67
+ enumerable: true,
68
+ configurable: true,
69
+ writable: true,
70
+ value: false
71
+ });
72
+ Object.defineProperty(_this, "hash", {
73
+ enumerable: true,
74
+ configurable: true,
75
+ writable: true,
76
+ value: void 0
77
+ });
78
+ Object.defineProperty(_this, "handleLoad", {
79
+ enumerable: true,
80
+ configurable: true,
81
+ writable: true,
82
+ value: function (content, hasCache) {
83
+ if (hasCache === void 0) { hasCache = false; }
84
+ /* istanbul ignore else */
85
+ if (_this.isActive) {
86
+ _this.setState({
87
+ content: content,
88
+ hasCache: hasCache,
89
+ status: STATUS.LOADED,
90
+ }, _this.getElement);
91
+ }
81
92
  }
82
- };
83
- _this.request = function () {
84
- var _a = _this.props, cacheRequests = _a.cacheRequests, fetchOptions = _a.fetchOptions, src = _a.src;
85
- try {
86
- if (cacheRequests) {
87
- cacheStore[src] = { content: '', status: STATUS.LOADING };
93
+ });
94
+ Object.defineProperty(_this, "handleError", {
95
+ enumerable: true,
96
+ configurable: true,
97
+ writable: true,
98
+ value: function (error) {
99
+ var onError = _this.props.onError;
100
+ var status = error.message === 'Browser does not support SVG' ? STATUS.UNSUPPORTED : STATUS.FAILED;
101
+ /* istanbul ignore else */
102
+ if (_this.isActive) {
103
+ _this.setState({ status: status }, function () {
104
+ /* istanbul ignore else */
105
+ if (typeof onError === 'function') {
106
+ onError(error);
107
+ }
108
+ });
88
109
  }
89
- return fetch(src, fetchOptions)
90
- .then(function (response) {
91
- var contentType = response.headers.get('content-type');
92
- var _a = __read((contentType || '').split(/ ?; ?/), 1), fileType = _a[0];
93
- if (response.status > 299) {
94
- throw new Error('Not found');
95
- }
96
- if (!['image/svg+xml', 'text/plain'].some(function (d) { return fileType.includes(d); })) {
97
- throw new Error("Content type isn't valid: ".concat(fileType));
110
+ }
111
+ });
112
+ Object.defineProperty(_this, "request", {
113
+ enumerable: true,
114
+ configurable: true,
115
+ writable: true,
116
+ value: function () {
117
+ var _a = _this.props, cacheRequests = _a.cacheRequests, fetchOptions = _a.fetchOptions, src = _a.src;
118
+ try {
119
+ if (cacheRequests) {
120
+ cacheStore[src] = { content: '', status: STATUS.LOADING };
98
121
  }
99
- return response.text();
100
- })
101
- .then(function (content) {
102
- var currentSrc = _this.props.src;
103
- // the current src don't match the previous one, skipping...
104
- if (src !== currentSrc) {
105
- if (cacheStore[src].status === STATUS.LOADING) {
106
- delete cacheStore[src];
122
+ return fetch(src, fetchOptions)
123
+ .then(function (response) {
124
+ var contentType = response.headers.get('content-type');
125
+ var _a = __read((contentType || '').split(/ ?; ?/), 1), fileType = _a[0];
126
+ if (response.status > 299) {
127
+ throw new Error('Not found');
107
128
  }
108
- return;
109
- }
110
- _this.handleLoad(content);
111
- /* istanbul ignore else */
112
- if (cacheRequests) {
113
- var cache = cacheStore[src];
129
+ if (!['image/svg+xml', 'text/plain'].some(function (d) { return fileType.includes(d); })) {
130
+ throw new Error("Content type isn't valid: ".concat(fileType));
131
+ }
132
+ return response.text();
133
+ })
134
+ .then(function (content) {
135
+ var currentSrc = _this.props.src;
136
+ // the current src don't match the previous one, skipping...
137
+ if (src !== currentSrc) {
138
+ if (cacheStore[src].status === STATUS.LOADING) {
139
+ delete cacheStore[src];
140
+ }
141
+ return;
142
+ }
143
+ _this.handleLoad(content);
114
144
  /* istanbul ignore else */
115
- if (cache) {
116
- cache.content = content;
117
- cache.status = STATUS.LOADED;
145
+ if (cacheRequests) {
146
+ var cache = cacheStore[src];
147
+ /* istanbul ignore else */
148
+ if (cache) {
149
+ cache.content = content;
150
+ cache.status = STATUS.LOADED;
151
+ }
118
152
  }
119
- }
120
- })
121
- .catch(function (error) {
122
- _this.handleError(error);
123
- /* istanbul ignore else */
124
- if (cacheRequests) {
125
- var cache = cacheStore[src];
153
+ })
154
+ .catch(function (error) {
155
+ _this.handleError(error);
126
156
  /* istanbul ignore else */
127
- if (cache) {
128
- delete cacheStore[src];
157
+ if (cacheRequests) {
158
+ var cache = cacheStore[src];
159
+ /* istanbul ignore else */
160
+ if (cache) {
161
+ delete cacheStore[src];
162
+ }
129
163
  }
130
- }
131
- });
132
- }
133
- catch (error) {
134
- return _this.handleError(new Error(error.message));
164
+ });
165
+ }
166
+ catch (error) {
167
+ return _this.handleError(new Error(error.message));
168
+ }
135
169
  }
136
- };
170
+ });
137
171
  _this.state = {
138
172
  content: '',
139
173
  element: null,
@@ -143,196 +177,250 @@ var InlineSVG = /** @class */ (function (_super) {
143
177
  _this.hash = props.uniqueHash || randomString(8);
144
178
  return _this;
145
179
  }
146
- InlineSVG.prototype.componentDidMount = function () {
147
- this.isActive = true;
148
- if (!canUseDOM()) {
149
- return;
150
- }
151
- var status = this.state.status;
152
- var src = this.props.src;
153
- try {
154
- /* istanbul ignore else */
155
- if (status === STATUS.PENDING) {
180
+ Object.defineProperty(InlineSVG.prototype, "componentDidMount", {
181
+ enumerable: false,
182
+ configurable: true,
183
+ writable: true,
184
+ value: function () {
185
+ this.isActive = true;
186
+ if (!canUseDOM() || this.isInitialized) {
187
+ return;
188
+ }
189
+ var status = this.state.status;
190
+ var src = this.props.src;
191
+ try {
156
192
  /* istanbul ignore else */
157
- if (!isSupportedEnvironment()) {
158
- throw new Error('Browser does not support SVG');
193
+ if (status === STATUS.PENDING) {
194
+ /* istanbul ignore else */
195
+ if (!isSupportedEnvironment()) {
196
+ throw new Error('Browser does not support SVG');
197
+ }
198
+ /* istanbul ignore else */
199
+ if (!src) {
200
+ throw new Error('Missing src');
201
+ }
202
+ this.load();
159
203
  }
204
+ }
205
+ catch (error) {
206
+ this.handleError(error);
207
+ }
208
+ this.isInitialized = true;
209
+ }
210
+ });
211
+ Object.defineProperty(InlineSVG.prototype, "componentDidUpdate", {
212
+ enumerable: false,
213
+ configurable: true,
214
+ writable: true,
215
+ value: function (previousProps, previousState) {
216
+ if (!canUseDOM()) {
217
+ return;
218
+ }
219
+ var _a = this.state, hasCache = _a.hasCache, status = _a.status;
220
+ var _b = this.props, onLoad = _b.onLoad, src = _b.src;
221
+ if (previousState.status !== STATUS.READY && status === STATUS.READY) {
160
222
  /* istanbul ignore else */
223
+ if (onLoad) {
224
+ onLoad(src, hasCache);
225
+ }
226
+ }
227
+ if (previousProps.src !== src) {
161
228
  if (!src) {
162
- throw new Error('Missing src');
229
+ this.handleError(new Error('Missing src'));
230
+ return;
163
231
  }
164
232
  this.load();
165
233
  }
166
234
  }
167
- catch (error) {
168
- this.handleError(error);
235
+ });
236
+ Object.defineProperty(InlineSVG.prototype, "componentWillUnmount", {
237
+ enumerable: false,
238
+ configurable: true,
239
+ writable: true,
240
+ value: function () {
241
+ this.isActive = false;
169
242
  }
170
- };
171
- InlineSVG.prototype.componentDidUpdate = function (previousProps, previousState) {
172
- if (!canUseDOM()) {
173
- return;
174
- }
175
- var _a = this.state, hasCache = _a.hasCache, status = _a.status;
176
- var _b = this.props, onLoad = _b.onLoad, src = _b.src;
177
- if (previousState.status !== STATUS.READY && status === STATUS.READY) {
178
- /* istanbul ignore else */
179
- if (onLoad) {
180
- onLoad(src, hasCache);
243
+ });
244
+ Object.defineProperty(InlineSVG.prototype, "getNode", {
245
+ enumerable: false,
246
+ configurable: true,
247
+ writable: true,
248
+ value: function () {
249
+ var _a = this.props, description = _a.description, title = _a.title;
250
+ try {
251
+ var svgText = this.processSVG();
252
+ var node = convert(svgText, { nodeOnly: true });
253
+ if (!node || !(node instanceof SVGSVGElement)) {
254
+ throw new Error('Could not convert the src to a DOM Node');
255
+ }
256
+ var svg = this.updateSVGAttributes(node);
257
+ if (description) {
258
+ var originalDesc = svg.querySelector('desc');
259
+ if (originalDesc && originalDesc.parentNode) {
260
+ originalDesc.parentNode.removeChild(originalDesc);
261
+ }
262
+ var descElement = document.createElementNS('http://www.w3.org/2000/svg', 'desc');
263
+ descElement.innerHTML = description;
264
+ svg.prepend(descElement);
265
+ }
266
+ if (typeof title !== 'undefined') {
267
+ var originalTitle = svg.querySelector('title');
268
+ if (originalTitle && originalTitle.parentNode) {
269
+ originalTitle.parentNode.removeChild(originalTitle);
270
+ }
271
+ if (title) {
272
+ var titleElement = document.createElementNS('http://www.w3.org/2000/svg', 'title');
273
+ titleElement.innerHTML = title;
274
+ svg.prepend(titleElement);
275
+ }
276
+ }
277
+ return svg;
181
278
  }
182
- }
183
- if (previousProps.src !== src) {
184
- if (!src) {
185
- this.handleError(new Error('Missing src'));
186
- return;
279
+ catch (error) {
280
+ return this.handleError(error);
187
281
  }
188
- this.load();
189
282
  }
190
- };
191
- InlineSVG.prototype.componentWillUnmount = function () {
192
- this.isActive = false;
193
- };
194
- InlineSVG.prototype.getNode = function () {
195
- var _a = this.props, description = _a.description, title = _a.title;
196
- try {
197
- var svgText = this.processSVG();
198
- var node = convert(svgText, { nodeOnly: true });
199
- if (!node || !(node instanceof SVGSVGElement)) {
200
- throw new Error('Could not convert the src to a DOM Node');
201
- }
202
- var svg = this.updateSVGAttributes(node);
203
- if (description) {
204
- var originalDesc = svg.querySelector('desc');
205
- if (originalDesc && originalDesc.parentNode) {
206
- originalDesc.parentNode.removeChild(originalDesc);
283
+ });
284
+ Object.defineProperty(InlineSVG.prototype, "getElement", {
285
+ enumerable: false,
286
+ configurable: true,
287
+ writable: true,
288
+ value: function () {
289
+ try {
290
+ var node = this.getNode();
291
+ var element = convert(node);
292
+ if (!element || !React.isValidElement(element)) {
293
+ throw new Error('Could not convert the src to a React element');
207
294
  }
208
- var descElement = document.createElement('desc');
209
- descElement.innerHTML = description;
210
- svg.prepend(descElement);
295
+ this.setState({
296
+ element: element,
297
+ status: STATUS.READY,
298
+ });
211
299
  }
212
- if (title) {
213
- var originalTitle = svg.querySelector('title');
214
- if (originalTitle && originalTitle.parentNode) {
215
- originalTitle.parentNode.removeChild(originalTitle);
216
- }
217
- var titleElement = document.createElement('title');
218
- titleElement.innerHTML = title;
219
- svg.prepend(titleElement);
300
+ catch (error) {
301
+ this.handleError(new Error(error.message));
220
302
  }
221
- return svg;
222
- }
223
- catch (error) {
224
- return this.handleError(error);
225
303
  }
226
- };
227
- InlineSVG.prototype.getElement = function () {
228
- try {
229
- var node = this.getNode();
230
- var element = convert(node);
231
- if (!element || !React.isValidElement(element)) {
232
- throw new Error('Could not convert the src to a React element');
304
+ });
305
+ Object.defineProperty(InlineSVG.prototype, "load", {
306
+ enumerable: false,
307
+ configurable: true,
308
+ writable: true,
309
+ value: function () {
310
+ var _this = this;
311
+ /* istanbul ignore else */
312
+ if (this.isActive) {
313
+ this.setState({
314
+ content: '',
315
+ element: null,
316
+ hasCache: false,
317
+ status: STATUS.LOADING,
318
+ }, function () {
319
+ var _a = _this.props, cacheRequests = _a.cacheRequests, src = _a.src;
320
+ var cache = cacheRequests && cacheStore[src];
321
+ if (cache && cache.status === STATUS.LOADED) {
322
+ _this.handleLoad(cache.content, true);
323
+ return;
324
+ }
325
+ var dataURI = src.match(/data:image\/svg[^,]*?(;base64)?,(.*)/);
326
+ var inlineSrc;
327
+ if (dataURI) {
328
+ inlineSrc = dataURI[1] ? window.atob(dataURI[2]) : decodeURIComponent(dataURI[2]);
329
+ }
330
+ else if (src.includes('<svg')) {
331
+ inlineSrc = src;
332
+ }
333
+ if (inlineSrc) {
334
+ _this.handleLoad(inlineSrc);
335
+ return;
336
+ }
337
+ _this.request();
338
+ });
233
339
  }
234
- this.setState({
235
- element: element,
236
- status: STATUS.READY,
237
- });
238
- }
239
- catch (error) {
240
- this.handleError(new Error(error.message));
241
340
  }
242
- };
243
- InlineSVG.prototype.load = function () {
244
- var _this = this;
245
- /* istanbul ignore else */
246
- if (this.isActive) {
247
- this.setState({
248
- content: '',
249
- element: null,
250
- status: STATUS.LOADING,
251
- }, function () {
252
- var _a = _this.props, cacheRequests = _a.cacheRequests, src = _a.src;
253
- var cache = cacheRequests && cacheStore[src];
254
- if (cache && cache.status === STATUS.LOADED) {
255
- _this.handleLoad(cache.content);
256
- return;
257
- }
258
- var dataURI = src.match(/data:image\/svg[^,]*?(;base64)?,(.*)/);
259
- var inlineSrc;
260
- if (dataURI) {
261
- inlineSrc = dataURI[1] ? window.atob(dataURI[2]) : decodeURIComponent(dataURI[2]);
262
- }
263
- else if (src.includes('<svg')) {
264
- inlineSrc = src;
341
+ });
342
+ Object.defineProperty(InlineSVG.prototype, "updateSVGAttributes", {
343
+ enumerable: false,
344
+ configurable: true,
345
+ writable: true,
346
+ value: function (node) {
347
+ var _this = this;
348
+ var _a = this.props, _b = _a.baseURL, baseURL = _b === void 0 ? '' : _b, uniquifyIDs = _a.uniquifyIDs;
349
+ var replaceableAttributes = ['id', 'href', 'xlink:href', 'xlink:role', 'xlink:arcrole'];
350
+ var linkAttributes = ['href', 'xlink:href'];
351
+ var isDataValue = function (name, value) {
352
+ return linkAttributes.includes(name) && (value ? !value.includes('#') : false);
353
+ };
354
+ if (!uniquifyIDs) {
355
+ return node;
356
+ }
357
+ __spreadArray([], __read(node.children), false).map(function (d) {
358
+ if (d.attributes && d.attributes.length) {
359
+ var attributes_1 = Object.values(d.attributes).map(function (a) {
360
+ var attribute = a;
361
+ var match = a.value.match(/url\((.*?)\)/);
362
+ if (match && match[1]) {
363
+ attribute.value = a.value.replace(match[0], "url(".concat(baseURL).concat(match[1], "__").concat(_this.hash, ")"));
364
+ }
365
+ return attribute;
366
+ });
367
+ replaceableAttributes.forEach(function (r) {
368
+ var attribute = attributes_1.find(function (a) { return a.name === r; });
369
+ if (attribute && !isDataValue(r, attribute.value)) {
370
+ attribute.value = "".concat(attribute.value, "__").concat(_this.hash);
371
+ }
372
+ });
265
373
  }
266
- if (inlineSrc) {
267
- _this.handleLoad(inlineSrc);
268
- return;
374
+ if (d.children.length) {
375
+ return _this.updateSVGAttributes(d);
269
376
  }
270
- _this.request();
377
+ return d;
271
378
  });
272
- }
273
- };
274
- InlineSVG.prototype.updateSVGAttributes = function (node) {
275
- var _this = this;
276
- var _a = this.props, _b = _a.baseURL, baseURL = _b === void 0 ? '' : _b, uniquifyIDs = _a.uniquifyIDs;
277
- var replaceableAttributes = ['id', 'href', 'xlink:href', 'xlink:role', 'xlink:arcrole'];
278
- var linkAttributes = ['href', 'xlink:href'];
279
- var isDataValue = function (name, value) {
280
- return linkAttributes.includes(name) && (value ? !value.includes('#') : false);
281
- };
282
- if (!uniquifyIDs) {
283
379
  return node;
284
380
  }
285
- __spreadArray([], __read(node.children), false).map(function (d) {
286
- if (d.attributes && d.attributes.length) {
287
- var attributes_1 = Object.values(d.attributes).map(function (a) {
288
- var attribute = a;
289
- var match = a.value.match(/url\((.*?)\)/);
290
- if (match && match[1]) {
291
- attribute.value = a.value.replace(match[0], "url(".concat(baseURL).concat(match[1], "__").concat(_this.hash, ")"));
292
- }
293
- return attribute;
294
- });
295
- replaceableAttributes.forEach(function (r) {
296
- var attribute = attributes_1.find(function (a) { return a.name === r; });
297
- if (attribute && !isDataValue(r, attribute.value)) {
298
- attribute.value = "".concat(attribute.value, "__").concat(_this.hash);
299
- }
300
- });
381
+ });
382
+ Object.defineProperty(InlineSVG.prototype, "processSVG", {
383
+ enumerable: false,
384
+ configurable: true,
385
+ writable: true,
386
+ value: function () {
387
+ var content = this.state.content;
388
+ var preProcessor = this.props.preProcessor;
389
+ if (preProcessor) {
390
+ return preProcessor(content);
301
391
  }
302
- if (d.children.length) {
303
- return _this.updateSVGAttributes(d);
304
- }
305
- return d;
306
- });
307
- return node;
308
- };
309
- InlineSVG.prototype.processSVG = function () {
310
- var content = this.state.content;
311
- var preProcessor = this.props.preProcessor;
312
- if (preProcessor) {
313
- return preProcessor(content);
392
+ return content;
314
393
  }
315
- return content;
316
- };
317
- InlineSVG.prototype.render = function () {
318
- var _a = this.state, element = _a.element, status = _a.status;
319
- var _b = this.props, _c = _b.children, children = _c === void 0 ? null : _c, innerRef = _b.innerRef, _d = _b.loader, loader = _d === void 0 ? null : _d;
320
- var elementProps = omit(this.props, 'baseURL', 'cacheRequests', 'children', 'description', 'fetchOptions', 'innerRef', 'loader', 'onError', 'onLoad', 'preProcessor', 'src', 'title', 'uniqueHash', 'uniquifyIDs');
321
- if (!canUseDOM()) {
394
+ });
395
+ Object.defineProperty(InlineSVG.prototype, "render", {
396
+ enumerable: false,
397
+ configurable: true,
398
+ writable: true,
399
+ value: function () {
400
+ var _a = this.state, element = _a.element, status = _a.status;
401
+ var _b = this.props, _c = _b.children, children = _c === void 0 ? null : _c, innerRef = _b.innerRef, _d = _b.loader, loader = _d === void 0 ? null : _d;
402
+ var elementProps = omit(this.props, 'baseURL', 'cacheRequests', 'children', 'description', 'fetchOptions', 'innerRef', 'loader', 'onError', 'onLoad', 'preProcessor', 'src', 'title', 'uniqueHash', 'uniquifyIDs');
403
+ if (!canUseDOM()) {
404
+ return loader;
405
+ }
406
+ if (element) {
407
+ return React.cloneElement(element, __assign({ ref: innerRef }, elementProps));
408
+ }
409
+ if ([STATUS.UNSUPPORTED, STATUS.FAILED].includes(status)) {
410
+ return children;
411
+ }
322
412
  return loader;
323
413
  }
324
- if (element) {
325
- return React.cloneElement(element, __assign({ ref: innerRef }, elementProps));
414
+ });
415
+ Object.defineProperty(InlineSVG, "defaultProps", {
416
+ enumerable: true,
417
+ configurable: true,
418
+ writable: true,
419
+ value: {
420
+ cacheRequests: true,
421
+ uniquifyIDs: false,
326
422
  }
327
- if ([STATUS.UNSUPPORTED, STATUS.FAILED].includes(status)) {
328
- return children;
329
- }
330
- return loader;
331
- };
332
- InlineSVG.defaultProps = {
333
- cacheRequests: true,
334
- uniquifyIDs: false,
335
- };
423
+ });
336
424
  return InlineSVG;
337
425
  }(React.PureComponent));
338
426
  export default InlineSVG;