Skip to content

Commit 4064d33

Browse files
committed
fix: return empty string if no script block exists
1 parent ce9c913 commit 4064d33

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

lib/process.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const extractPropsFromFunctionalTemplate = require('./extract-props')
1111
const splitRE = /\r?\n/g
1212

1313
function processScript (scriptPart) {
14+
if (!scriptPart) {
15+
return { code: '' }
16+
}
17+
1418
if (/^typescript|tsx?$/.test(scriptPart.lang)) {
1519
return compileTypescript(scriptPart.content)
1620
}

test/NoScript.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { mount } from 'vue-test-utils'
2+
import NoScript from './resources/NoScript.vue'
3+
4+
describe('NoScript', () => {
5+
it('renders', () => {
6+
const wrapper = mount(NoScript)
7+
expect(wrapper.contains('footer'))
8+
})
9+
})

test/resources/NoScript.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<template>
2+
<footer class="footer">I'm footer!</footer>
3+
</template>
4+
5+
<style>
6+
.footer {
7+
padding: 15px;
8+
border: 1px dashed red;
9+
text-align: center;
10+
margin-top: 30px;
11+
}
12+
</style>

0 commit comments

Comments
 (0)