Skip to content

Commit 1acd204

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

7 files changed

+385
-63
lines changed
 

‎src/plugins/source-plugin.js

+21
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

+201-33
Large diffs are not rendered by default.

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

+57-9
Large diffs are not rendered by default.

‎test/__snapshots__/loader.test.js.snap

+19-3
Large diffs are not rendered by default.

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

+70-16
Large diffs are not rendered by default.

‎test/fixtures/simple.html

+16-2
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

+1
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.