Skip to content

Commit e7928ab

Browse files
fix: re-enable lazy-loading capabilities (#28)
This has been fixed by the latest svg-to-vue-component version
1 parent 622c77e commit e7928ab

File tree

5 files changed

+38
-5
lines changed

5 files changed

+38
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"scripts": {
2323
"dev": "nuxt --config-file test/fixture/configs/default.js",
2424
"lint": "eslint lib test",
25-
"test": "yarn run lint && jest",
25+
"test": "yarn run lint && jest --detectOpenHandles",
2626
"release": "standard-version && git push --follow-tags && npm publish",
2727
"commitlint": "commitlint -e $GIT_PARAMS",
2828
"coverage": "codecov"

test/__snapshots__/module.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`ssr correctly register SVG loader and load SVG correctly 1`] = `
3+
exports[`ssr correctly load two lazy-loaded SVGs 1`] = `
44
"<!doctype html>
55
<html data-n-head-ssr data-n-head=\\"\\">
66
<head data-n-head=\\"\\">
77
<title data-n-head=\\"true\\"></title><style data-vue-ssr-id=\\"17cfdfa9:0\\">.nuxt-progress{position:fixed;top:0;left:0;right:0;height:2px;width:0;opacity:1;transition:width .1s,opacity .4s;background-color:#000;z-index:999999}.nuxt-progress.nuxt-progress-notransition{transition:none}.nuxt-progress-failed{background-color:red}</style>
88
</head>
99
<body data-n-head=\\"\\">
10-
<div data-server-rendered=\\"true\\" id=\\"__nuxt\\"><!----><div id=\\"__layout\\"><svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"1 2 3 4\\" width=\\"100\\"><g id=\\"Nuxt_svg__nuxt\\"><path d=\\"M317.9 852H3.7l408.1-704 408.1 704H507.7\\" fill=\\"#41b883\\"></path><path d=\\"M779.8 852h216.5l-354-608.5-351 608.5h216.5\\" fill=\\"#328170\\"></path><path d=\\"M651.2 852h159.5L549.9 403.8 291.3 852h159.5\\" fill=\\"#35495e\\"></path></g></svg></div></div><script>window.__NUXT__={layout:\\"default\\",data:[{}],error:null,serverRendered:true};</script><script src=\\"/_nuxt/runtime.js\\" defer></script><script src=\\"/_nuxt/pages/index.js\\" defer></script><script src=\\"/_nuxt/commons.app.js\\" defer></script><script src=\\"/_nuxt/app.js\\" defer></script>
10+
<div data-server-rendered=\\"true\\" id=\\"__nuxt\\"><!----><div id=\\"__layout\\"><div><svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"1 2 3 4\\" width=\\"100\\"><g id=\\"Nuxt_svg__nuxt\\"><path d=\\"M317.9 852H3.7l408.1-704 408.1 704H507.7\\" fill=\\"#41b883\\"></path><path d=\\"M779.8 852h216.5l-354-608.5-351 608.5h216.5\\" fill=\\"#328170\\"></path><path d=\\"M651.2 852h159.5L549.9 403.8 291.3 852h159.5\\" fill=\\"#35495e\\"></path></g></svg> <svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 1000 1000\\"><g id=\\"NuxtTwo_svg__nuxt\\"><path d=\\"M317.9 852H3.7l408.1-704 408.1 704H507.7\\" fill=\\"#41b883\\"></path><path d=\\"M779.8 852h216.5l-354-608.5-351 608.5h216.5\\" fill=\\"#328170\\"></path><path d=\\"M651.2 852h159.5L549.9 403.8 291.3 852h159.5\\" fill=\\"#35495e\\"></path></g></svg></div></div></div><script>window.__NUXT__={layout:\\"default\\",data:[{}],error:null,serverRendered:true};</script><script src=\\"/_nuxt/runtime.js\\" defer></script><script src=\\"/_nuxt/pages/two.js\\" defer></script><script src=\\"/_nuxt/6.js\\" defer></script><script src=\\"/_nuxt/commons.app.js\\" defer></script><script src=\\"/_nuxt/app.js\\" defer></script>
1111
</body>
1212
</html>
1313
"

test/fixture/components/NuxtTwo.svg

Lines changed: 17 additions & 0 deletions
Loading

test/fixture/pages/two.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<template>
2+
<div>
3+
<nuxt-logo viewBox="1 2 3 4" width="100" />
4+
<nuxt-logo-two />
5+
</div>
6+
</template>
7+
8+
<script>
9+
export default {
10+
loading: false,
11+
components: {
12+
NuxtLogo: () => import('../components/Nuxt.svg'),
13+
NuxtLogoTwo: () => import('../components/NuxtTwo.svg')
14+
}
15+
}
16+
</script>

test/module.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ describe('ssr', () => {
2121
Error('Never reach this state')
2222
})
2323

24-
test('correctly register SVG loader and load SVG correctly', async () => {
24+
test('correctly load two lazy-loaded SVGs', async () => {
2525
const nuxt = await setupNuxt(require('./fixture/configs/default'))
26-
const { html } = await nuxt.renderRoute('/')
26+
const { html } = await nuxt.renderRoute('/two')
2727
expect(html).toMatchSnapshot()
2828
})
2929

0 commit comments

Comments
 (0)