Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: support SVG tags (#302)
  • Loading branch information
evilebottnawi committed Aug 11, 2020
1 parent 420dccc commit 1acd204
Show file tree
Hide file tree
Showing 7 changed files with 385 additions and 63 deletions.
21 changes: 21 additions & 0 deletions src/plugins/source-plugin.js
Expand Up @@ -113,6 +113,27 @@ const defaultAttributes = [
attribute: 'src',
type: 'src',
},
// SVG
{
tag: 'image',
attribute: 'xlink:href',
type: 'src',
},
{
tag: 'image',
attribute: 'href',
type: 'src',
},
{
tag: 'use',
attribute: 'xlink:href',
type: 'src',
},
{
tag: 'use',
attribute: 'href',
type: 'src',
},
];

function parseSource(source) {
Expand Down
234 changes: 201 additions & 33 deletions test/__snapshots__/attributes-option.test.js.snap

Large diffs are not rendered by default.

66 changes: 57 additions & 9 deletions test/__snapshots__/esModule-option.test.js.snap

Large diffs are not rendered by default.

22 changes: 19 additions & 3 deletions test/__snapshots__/loader.test.js.snap

Large diffs are not rendered by default.

86 changes: 70 additions & 16 deletions test/__snapshots__/minimize-option.test.js.snap

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions test/fixtures/simple.html
Expand Up @@ -128,8 +128,6 @@ <h2>An Ordered HTML List</h2>

<div data-videomp4="video.mp4"></div>

<use xlink:href="vector.svg" />

<![CDATA[<img src="image.png">]]><img src="image.png">

<link rel="stylesheet" type="text/css" href="./style.file.css">
Expand Down Expand Up @@ -275,3 +273,19 @@ <h2>An Ordered HTML List</h2>
<img data-srcset="image.png 480w, image.png 800w" sizes="(max-width: 600px) 480px, 800px" data-src="image.png" alt="Elva dressed as a fairy">

<img src=~aliasImageWithSpace#hash />

<svg width="200" height="200">
<image xlink:href="./webpack.svg" height="200" width="200"/>
</svg>

<svg width="200" height="200">
<image href="./webpack.svg" height="200" width="200"/>
</svg>

<svg width="200" height="200">
<use href="./webpack.svg"></use>
</svg>

<svg width="200" height="200">
<use xlink:href="./webpack.svg"></use>
</svg>
1 change: 1 addition & 0 deletions test/fixtures/webpack.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1acd204

Please sign in to comment.