Skip to content
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

feat: support SVG tags #302

Merged
merged 1 commit into from Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.