-
Notifications
You must be signed in to change notification settings - Fork 3
"Argument is not valid" for items without v-svg-inline directive #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello, this error means, that plugin expects SVG file, but got something else (in your case PNG). vue-svg-inline-plugin/src/index.js Line 75 in 97be1e3
vue-svg-inline-plugin/src/index.js Lines 460 to 461 in 97be1e3
Are you 100% sure, its coming from this part of code?
Because this plugin registers its own Vue directive and should not run outside of it. If you are able to reproduce this issue, please try to add vue-svg-inline-plugin/src/index.js Lines 775 to 776 in 97be1e3
To see if there is actually processed image node without chosen directive. Thanks. |
@oliverfindl what I'm sure is that we set directive on svg files only (see screen below). That why my own confusion comes from :). |
I managed to explore the issue a bit more and get it replicated. Seems there is some conflict with vue-lazyload package in my case. The simplified block that reproduces the issue is this: <template>
<div>
<div v-if="showBlock=='default'">
<img v-lazy="getImageUrl(item.image_id)">
</div>
<div v-if="showBlock=='failed'">
<img v-svg-inline src="/customer/images/challenge-failed.svg" alt="">
</div>
</div>
</template> On If instead of As you proposed in console.log() into the beforeMount() method so the output if here: |
Hello, this looks really strange. Can you also expand Thanks. |
@oliverfindl the object is pretty large so does not fit to the screen, so cant copy it all here But something useful is here maybe. Yes - We use vue-lazyload 1.3.4 (the latest one for vue 2) |
FYI, the resulting element in DOM looks like this: <img data-src="/image/i.167/w.400:h.400:f.0/image.png"
src="https://aimera.local/customer/images/challenge-failed.svg" lazy="error" alt=""> |
Hello @tomastan, I created a dummy document and unfortunately I can't replicate your issue. I had to use version 1.3.3, because 1.3.4 was throwing error: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>img, svg { max-height: 200px; }</style>
</head>
<body>
<div id="app">
<img v-svg-inline :src="svg" />
<img v-lazy="png" />
</div>
<script src="https://unpkg.com/[email protected]/dist/vue-svg-inline-plugin.min.js"></script>
<script src="https://unpkg.com/[email protected]/vue-lazyload.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<script>
Vue.use(VueSvgInlinePlugin);
Vue.use(VueLazyload);
new Vue({
data: {
svg: "https://raw.githubusercontent.com/vuejs/art/master/logo.svg",
png: "https://raw.githubusercontent.com/vuejs/art/master/logo.png"
}
}).$mount("#app");
</script>
</body>
</html> Please provide minimal example, so I can replicate this issue. Thanks. |
Hello @Ilya-Chernyshev, this is different issue. There was already reported something similar, which was related to Vite due to using esbuild for dev server and Rollup for production build. Most probably your issue is related to your bundler. Please as first step, try to investigate your rendered webpage and try to find what is actually set into Thanks. |
@oliverfindl I made a jsfiddle (https://jsfiddle.net/kpjzhotf/1/) for you. The key factor for this to happen is switching between two parent elements containing lazyloaded png in one, and inline-svg in the another. I have no idea, how these elements are related, but they do somehow. Maybe some Vue optimizers in force? <div v-if="!showSvg">
<img v-lazy="png" />
</div>
<div v-if="showSvg">
<img v-svg-inline :src="svg" />
</div> |
Hello, thanks for clarification. I found out, that you don't need to use I presume, its due to how Vue is referencing elements. Our problem here is, that this plugin creates new I also tested your example with Vue 3 and its working there correctly. Unfortunately, I don't have any solution for Vue 2 based projects. If you have more questions, feel free to ask here. Thanks. |
I somehow cannot replicate the issue with However, I also think there is something is with Vue internals. But this bring me to a solution. If <div v-if="!showSvg" key="svg">
<img v-lazy="png" />
</div>
<div v-if="showSvg" key="png">
<img v-svg-inline :src="svg" />
</div> Working example: https://jsfiddle.net/x0trzuaj/1/ |
We noticed some random JS exceptions in Sentry logs which made us a bit confused.
For example:
TypeError: [vue-svg-inline-plugin] Argument is not valid! [path="/image/i.702/w.400:h.400:f.0/image.png"]
The confusion is because this element does not contain SVG and should not be affected at all:
<img v-lazy="getImageUrl(item.image_id)">
The same Vue component contains other elements using vue-svg-inline-plugin, for example:
Any ideas?
The text was updated successfully, but these errors were encountered: