Comparing version 1.0.0 to 1.1.0
@@ -21,12 +21,20 @@ function $parcel$defineInteropFlag(a) { | ||
async init() { | ||
const { file: file, revision: revision } = this.options; | ||
if (this.isLocalStorage && localStorage.getItem("inlineSVGrev") === revision) { | ||
const data = localStorage.getItem("inlineSVGdata"); | ||
if (data) { | ||
this.insert(data); | ||
return; | ||
const { file: file } = this.options; | ||
if (document.querySelector("#iconset")) return; | ||
if (this.isLocalStorage) { | ||
const storedSize = localStorage.getItem("inlineSVGsize"); | ||
try { | ||
const response = await fetch(file); | ||
if (!response.ok) throw new Error("Network response was not ok"); | ||
const data = await response.text(); | ||
if (storedSize && storedSize === data.length.toString()) this.insert(localStorage.getItem("inlineSVGdata")); | ||
else { | ||
this.insert(data); | ||
localStorage.setItem("inlineSVGdata", data); | ||
localStorage.setItem("inlineSVGsize", data.length.toString()); | ||
} | ||
} catch (error) { | ||
console.error("There was a problem with the network fetch operation:", error); | ||
} | ||
} | ||
if (document.querySelector("#iconset")) return; | ||
try { | ||
} else try { | ||
const response = await fetch(file); | ||
@@ -36,6 +44,2 @@ if (!response.ok) throw new Error("Network response was not ok"); | ||
this.insert(data); | ||
if (this.isLocalStorage) { | ||
localStorage.setItem("inlineSVGdata", data); | ||
localStorage.setItem("inlineSVGrev", revision); | ||
} | ||
} catch (error) { | ||
@@ -42,0 +46,0 @@ console.error("There was a problem with the network fetch operation:", error); |
@@ -11,12 +11,20 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 { | ||
async init() { | ||
const { file: file, revision: revision } = this.options; | ||
if (this.isLocalStorage && localStorage.getItem("inlineSVGrev") === revision) { | ||
const data = localStorage.getItem("inlineSVGdata"); | ||
if (data) { | ||
this.insert(data); | ||
return; | ||
const { file: file } = this.options; | ||
if (document.querySelector("#iconset")) return; | ||
if (this.isLocalStorage) { | ||
const storedSize = localStorage.getItem("inlineSVGsize"); | ||
try { | ||
const response = await fetch(file); | ||
if (!response.ok) throw new Error("Network response was not ok"); | ||
const data = await response.text(); | ||
if (storedSize && storedSize === data.length.toString()) this.insert(localStorage.getItem("inlineSVGdata")); | ||
else { | ||
this.insert(data); | ||
localStorage.setItem("inlineSVGdata", data); | ||
localStorage.setItem("inlineSVGsize", data.length.toString()); | ||
} | ||
} catch (error) { | ||
console.error("There was a problem with the network fetch operation:", error); | ||
} | ||
} | ||
if (document.querySelector("#iconset")) return; | ||
try { | ||
} else try { | ||
const response = await fetch(file); | ||
@@ -26,6 +34,2 @@ if (!response.ok) throw new Error("Network response was not ok"); | ||
this.insert(data); | ||
if (this.isLocalStorage) { | ||
localStorage.setItem("inlineSVGdata", data); | ||
localStorage.setItem("inlineSVGrev", revision); | ||
} | ||
} catch (error) { | ||
@@ -32,0 +36,0 @@ console.error("There was a problem with the network fetch operation:", error); |
{ | ||
"name": "iconly", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "SVG Sprite", | ||
@@ -5,0 +5,0 @@ "author": "ux-ui.pro", |
@@ -11,33 +11,39 @@ export default class Iconly { | ||
async init() { | ||
const { file, revision } = this.options | ||
const { file } = this.options | ||
if (this.isLocalStorage && localStorage.getItem('inlineSVGrev') === revision) { | ||
const data = localStorage.getItem('inlineSVGdata') | ||
if (document.querySelector('#iconset')) return | ||
if (data) { | ||
this.insert(data) | ||
if (this.isLocalStorage) { | ||
const storedSize = localStorage.getItem('inlineSVGsize') | ||
return | ||
} | ||
} | ||
try { | ||
const response = await fetch(file) | ||
if (document.querySelector('#iconset')) return | ||
if (!response.ok) throw new Error('Network response was not ok') | ||
try { | ||
const response = await fetch(file) | ||
const data = await response.text() | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok') | ||
if (storedSize && storedSize === data.length.toString()) { | ||
this.insert(localStorage.getItem('inlineSVGdata')) | ||
} else { | ||
this.insert(data) | ||
localStorage.setItem('inlineSVGdata', data) | ||
localStorage.setItem('inlineSVGsize', data.length.toString()) | ||
} | ||
} catch (error) { | ||
console.error('There was a problem with the network fetch operation:', error) | ||
} | ||
} else { | ||
try { | ||
const response = await fetch(file) | ||
const data = await response.text() | ||
if (!response.ok) throw new Error('Network response was not ok') | ||
this.insert(data) | ||
const data = await response.text() | ||
if (this.isLocalStorage) { | ||
localStorage.setItem('inlineSVGdata', data) | ||
localStorage.setItem('inlineSVGrev', revision) | ||
this.insert(data) | ||
} catch (error) { | ||
console.error('There was a problem with the network fetch operation:', error) | ||
} | ||
} catch (error) { | ||
console.error('There was a problem with the network fetch operation:', error) | ||
} | ||
@@ -44,0 +50,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
20442
143
6