diff --git a/README.md b/README.md
index 0be4f4e..a3205b4 100644
--- a/README.md
+++ b/README.md
@@ -81,6 +81,7 @@ interface TemplateCompileOptions {
// source: 'src',
// img: 'src',
// image: 'xlink:href'
+ // use: 'xlink:href'
// }
transformAssetUrls?: AssetURLOptions | boolean
diff --git a/lib/templateCompilerModules/assetUrl.ts b/lib/templateCompilerModules/assetUrl.ts
index b74b059..8838748 100644
--- a/lib/templateCompilerModules/assetUrl.ts
+++ b/lib/templateCompilerModules/assetUrl.ts
@@ -10,7 +10,8 @@ const defaultOptions: AssetURLOptions = {
video: ['src', 'poster'],
source: 'src',
img: 'src',
- image: ['xlink:href', 'href']
+ image: ['xlink:href', 'href'],
+ use: ['xlink:href', 'href']
}
export default (userOptions?: AssetURLOptions) => {
diff --git a/test/compileTemplate.spec.ts b/test/compileTemplate.spec.ts
index ccd52b4..bc1ef6d 100644
--- a/test/compileTemplate.spec.ts
+++ b/test/compileTemplate.spec.ts
@@ -152,6 +152,10 @@ test('transform srcset', () => {
+
+
@@ -183,16 +187,20 @@ test('transform srcset', () => {
expect(vnode.children[2].children[0].data.attrs['xlink:href']).toBe(
'test-url'
)
+ // use tag (SVG)
+ expect(vnode.children[4].children[0].data.attrs['xlink:href']).toBe(
+ 'test-url'
+ )
// image tag with srcset
- expect(vnode.children[4].data.attrs.srcset).toBe('test-url')
- expect(vnode.children[6].data.attrs.srcset).toBe('test-url 2x')
+ expect(vnode.children[6].data.attrs.srcset).toBe('test-url')
+ expect(vnode.children[8].data.attrs.srcset).toBe('test-url 2x')
// image tag with multiline srcset
- expect(vnode.children[8].data.attrs.srcset).toBe('test-url, test-url 2x')
- expect(vnode.children[10].data.attrs.srcset).toBe('test-url 2x, test-url')
- expect(vnode.children[12].data.attrs.srcset).toBe('test-url 2x, test-url 3x')
- expect(vnode.children[14].data.attrs.srcset).toBe(
+ expect(vnode.children[10].data.attrs.srcset).toBe('test-url, test-url 2x')
+ expect(vnode.children[12].data.attrs.srcset).toBe('test-url 2x, test-url')
+ expect(vnode.children[14].data.attrs.srcset).toBe('test-url 2x, test-url 3x')
+ expect(vnode.children[16].data.attrs.srcset).toBe(
'test-url, test-url 2x, test-url 3x'
)
- expect(vnode.children[16].data.attrs.srcset).toBe('test-url 2x, test-url 3x')
+ expect(vnode.children[18].data.attrs.srcset).toBe('test-url 2x, test-url 3x')
})