Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-inline-svg

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-inline-svg - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

60

dist/vue-inline-svg.js

@@ -9,2 +9,3 @@ (function (global, factory) {

var cache = {};
/**

@@ -14,3 +15,2 @@ * Remove false attrs

*/
function filterAttrs(attrs) {

@@ -21,7 +21,5 @@ return Object.keys(attrs).reduce(function (result, key) {

}
return result;
}, {});
}
var InlineSvgComponent = {

@@ -34,3 +32,2 @@ name: 'InlineSvg',

}
return createElement('svg', {

@@ -84,11 +81,8 @@ on: this.$listeners,

var attrs = svgEl.attributes;
if (!attrs) {
return svgAttrs;
}
for (var i = attrs.length - 1; i >= 0; i--) {
svgAttrs[attrs[i].name] = attrs[i].value;
}
return svgAttrs;

@@ -99,18 +93,14 @@ },

svgEl = this.transformSource(svgEl);
if (this.title) {
setTitle(svgEl, this.title);
} // copy inner html
}
// copy inner html
return svgEl.innerHTML;
},
/**
* Get svgElSource
* @param {string} src
*/
getSource: function getSource(src) {
*/getSource: function getSource(src) {
var _this = this;
// fill cache by src with promise

@@ -120,14 +110,13 @@ if (!cache[src]) {

cache[src] = this.download(src);
} // notify svg is unloaded
}
// notify svg is unloaded
if (this.svgElSource && cache[src].isPending() && !this.keepDuringLoading) {
this.svgElSource = null;
this.$emit('unloaded');
} // inline svg when cached promise resolves
}
// inline svg when cached promise resolves
cache[src].then(function (svg) {
_this.svgElSource = svg; // wait to render
_this.svgElSource = svg;
// wait to render
_this.$nextTick(function () {

@@ -141,13 +130,9 @@ // notify

_this.svgElSource = null;
_this.$emit('unloaded');
} // remove cached rejected promise so next image can try load again
}
// remove cached rejected promise so next image can try load again
delete cache[src];
_this.$emit('error', err);
});
},
/**

@@ -157,8 +142,6 @@ * Get the contents of the SVG

* @returns {Promise<Element>}
*/
download: function download(url) {
*/download: function download(url) {
return makePromiseState(new Promise(function (resolve, reject) {
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.onload = function () {

@@ -171,3 +154,2 @@ if (request.status >= 200 && request.status < 400) {

var svgEl = result.getElementsByTagName('svg')[0];
if (svgEl) {

@@ -186,3 +168,2 @@ // svgEl = this.transformSource(svgEl);

};
request.onerror = reject;

@@ -194,2 +175,3 @@ request.send();

};
/**

@@ -200,6 +182,4 @@ * Create or edit the <title> element of a SVG

*/
function setTitle(svg, title) {
var titleTags = svg.getElementsByTagName('title');
if (titleTags.length) {

@@ -215,2 +195,3 @@ // overwrite existing title

}
/**

@@ -226,10 +207,10 @@ * @typedef {Promise} PromiseWithState

*/
function makePromiseState(promise) {
// Don't modify any promise that has been already modified.
if (promise.isPending) return promise; // Set initial state
if (promise.isPending) return promise;
var isPending = true; // Observe the promise, saving the fulfillment in a closure scope.
// Set initial state
var isPending = true;
// Observe the promise, saving the fulfillment in a closure scope.
var result = promise.then(function (v) {

@@ -242,10 +223,7 @@ isPending = false;

});
result.isPending = function getIsPending() {
return isPending;
};
return result;
}
var InlineSvgPlugin = {

@@ -252,0 +230,0 @@ install: function install(Vue) {

{
"name": "vue-inline-svg",
"version": "2.1.0",
"version": "2.1.1",
"description": "Replace SVG images with inline SVG element",

@@ -43,13 +43,13 @@ "main": "dist/vue-inline-svg.js",

"devDependencies": {
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.6",
"@rollup/plugin-babel": "^5.3.0",
"@babel/core": "^7.19.3",
"@babel/preset-env": "^7.19.4",
"@rollup/plugin-babel": "^5.3.1",
"check-dts": "^0.5.6",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-import": "^2.26.0",
"pre-commit": "^1.2.2",
"rollup": "^2.58.0",
"rollup": "^2.79.1",
"rollup-plugin-terser": "^7.0.2"
}
}

@@ -18,3 +18,3 @@ # Vue Inline SVG

- [CDN](#cdn)
- [Vue v3](#vue-v3)
- [Vue 3](#vue-v3)
- [Usage](#usage)

@@ -94,6 +94,7 @@ - [props](#props)

Version of `vue-inline-svg` with support of Vue v3 is available under `next` tag
from NPM
```bash
npm install vue-inline-svg@next
```
or from CDN
```html

@@ -100,0 +101,0 @@ <script src="https://unpkg.com/vue-inline-svg@next"></script>

@@ -8,3 +8,3 @@ /*

import { VueConstructor } from 'vue';
import { VueConstructor, PluginFunction } from 'vue';

@@ -18,2 +18,8 @@ interface InlineSvgProps {

interface InlineSvgPlugin {
install: PluginFunction<never>
}
export declare const InlineSvgPlugin: InlineSvgPlugin;
interface InlineSvgConstructor extends VueConstructor {

@@ -23,3 +29,4 @@ props: InlineSvgProps;

declare const InlineSvg: InlineSvgConstructor;
export = InlineSvg;
export declare const InlineSvgComponent: InlineSvgConstructor;
export default InlineSvgComponent;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc