Relative URLs in srcset are not transformed
It looks like @vue/compiler-sfc
has a bug, introduced in v3.0.0-beta.9
when adding support for absolute URLs in srcset
. This bug bypasses the transformation that would've resolved the asset URLs in srcset
.
Version
3.2.20
Reproduction link
https://github.com/tony19-sandbox/vue-srcset-relative-urls-bug
Steps to reproduce
- In a template, add an
<img>
with asrcset
that contains relative URLs with path aliases:
<img srcset="@/assets/300.png 2x, @/assets/150.png 1x">
Start the dev server with
yarn dev
.Observe no image is shown in the browser, and that the
<img>.srcset
URLs are unresolved.
What is expected?
- The
srcset
URLs are resolved:
<img srcset="/src/assets/300.png 2x, /src/assets/150.png 1x">
- The image appears in the browser.
What is actually happening?
- The
srcset
URLs are unresolved:
<img srcset="/src/@/assets/300.png 2x, /src/@/assets/150.png 1x">
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
- The image is not shown.