Skip to content

Commit 1acd204

Browse files
feat: support SVG tags (#302)
1 parent 420dccc commit 1acd204

File tree

7 files changed

+385
-63
lines changed

7 files changed

+385
-63
lines changed

src/plugins/source-plugin.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,27 @@ const defaultAttributes = [
113113
attribute: 'src',
114114
type: 'src',
115115
},
116+
// SVG
117+
{
118+
tag: 'image',
119+
attribute: 'xlink:href',
120+
type: 'src',
121+
},
122+
{
123+
tag: 'image',
124+
attribute: 'href',
125+
type: 'src',
126+
},
127+
{
128+
tag: 'use',
129+
attribute: 'xlink:href',
130+
type: 'src',
131+
},
132+
{
133+
tag: 'use',
134+
attribute: 'href',
135+
type: 'src',
136+
},
116137
];
117138

118139
function parseSource(source) {

test/__snapshots__/attributes-option.test.js.snap

Lines changed: 201 additions & 33 deletions
Large diffs are not rendered by default.

test/__snapshots__/esModule-option.test.js.snap

Lines changed: 57 additions & 9 deletions
Large diffs are not rendered by default.

test/__snapshots__/loader.test.js.snap

Lines changed: 19 additions & 3 deletions
Large diffs are not rendered by default.

test/__snapshots__/minimize-option.test.js.snap

Lines changed: 70 additions & 16 deletions
Large diffs are not rendered by default.

test/fixtures/simple.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ <h2>An Ordered HTML List</h2>
128128

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

131-
<use xlink:href="vector.svg" />
132-
133131
<![CDATA[<img src="image.png">]]><img src="image.png">
134132

135133
<link rel="stylesheet" type="text/css" href="./style.file.css">
@@ -275,3 +273,19 @@ <h2>An Ordered HTML List</h2>
275273
<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">
276274

277275
<img src=~aliasImageWithSpace#hash />
276+
277+
<svg width="200" height="200">
278+
<image xlink:href="./webpack.svg" height="200" width="200"/>
279+
</svg>
280+
281+
<svg width="200" height="200">
282+
<image href="./webpack.svg" height="200" width="200"/>
283+
</svg>
284+
285+
<svg width="200" height="200">
286+
<use href="./webpack.svg"></use>
287+
</svg>
288+
289+
<svg width="200" height="200">
290+
<use xlink:href="./webpack.svg"></use>
291+
</svg>

test/fixtures/webpack.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)