Doesn’t follow <script href>, <script xlink:href>, <a xlink:href> inside inline <svg>
See original GitHub issue🐛 bug report
Scripts should be embedded in <svg>
with <script href>
or <script xlink:href>
rather than <script src>
, but Parcel doesn’t find scripts with that syntax.
There are also other tags on which it fails to follow xlink:href
, like <a>
.
🎛 Configuration (.babelrc, package.json, cli command)
$ tail -n +1 *
==> index.html <==
<!DOCTYPE html>
<svg xmlns:xlink="http://www.w3.org/1999/xlink">
<script xlink:href="script.js"></script>
</svg>
==> script.js <==
alert(1);
$ parcel build index.html
✨ Built in 327ms.
dist/index.html 101 B 266ms
🤔 Expected Behavior
$ ls dist
index.html script.d1ea37cd.js script.d1ea37cd.js.map
😯 Current Behavior
$ ls dist
index.html
💁 Possible Solution
Maybe Parcel should follow all href
and xlink:href
attributes regardless of tag? But if you want a list of applicable tags, MDN has one for href
and xlink:href
.
🔦 Context
I wanted to embed TypeScript in a standalone SVG file, which didn’t work because Parcel doesn’t scan standalone SVGs for dependencies at all (#3571), but experimentation with inline SVG revealed this additional bug.
💻 Code Sample
See above.
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 1.12.3 |
Node | 12.10.0 |
npm/Yarn | 1.17.3 |
Operating System | Ubuntu 19.10 |
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
How to make an SVG embedded inline in HTML load its xlink ...
Here is a standalone SVG image with that script dependency. To activate the JavaScript, you can click on the image, and then there's...
Read more >xlink:href - SVG: Scalable Vector Graphics - MDN Web Docs
The xlink:href attribute defines a reference to a resource as a reference ... You can use this attribute with the following SVG elements:....
Read more >On xlink:href being deprecated in SVG - CSS-Tricks
The attribute we always use for them, xlink:href , is deprecated. Indeed, MDN says: That's pretty strong language, hence the reader's warning.
Read more >Google Doesn't Follow Links In SVGs
Although Google began crawling and indexing SVGs back in 2010, Google does not follow any links within the Scalable Vector Graphics.
Read more >Get "svg: use: @xlink:href required" when <use> element is ...
... recognize the "xlink:href" attribute I set on a number of SVG <use /> elements from JavaScript. For example the following code properly ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
SVG 2 is a candidate recommendation; SVG 1.1 is still much more common and only supports
xlink:href
. Do you really think Parcel should require its users to upgrade to candidate technologies? Is there any harm in leaving that decision to the user?@kirillrogovoy we aren’t really releasing any more updates for v1 so probably best to just fix this for v2