refactor: remove deprecated scopeId codegen

BREAKING CHANGE: Output of SFC using `<style scoped>` generated by 3.2+
will be incompatible w/ runtime <3.2.
This commit is contained in:
Evan You
2021-07-14 10:04:35 -04:00
parent 1c7d737cc8
commit f596e008ef
7 changed files with 12 additions and 82 deletions

View File

@@ -326,7 +326,6 @@ return (_ctx, _cache) => {
exports[`SFC compile <script setup> inlineTemplate mode should not wrap render fn with withId when having scoped styles 1`] = `
"import { toDisplayString as _toDisplayString, openBlock as _openBlock, createElementBlock as _createElementBlock, withScopeId as _withScopeId } from \\"vue\\"
const _withId = /*#__PURE__*/_withScopeId(\\"data-v-xxxxxxxx\\")
export default {

View File

@@ -476,32 +476,6 @@ defineExpose({ foo: 123 })
expect(content).toMatch(`ssrInterpolate`)
assertCode(content)
})
// _withId is only generated for backwards compat and is a noop when called
// in module scope.
// when inside setup(), currentInstance will be non-null and _withId will
// no longer be noop and cause scopeId errors.
// TODO: this test should no longer be necessary if we remove _withId
// codegen in 3.1
test('should not wrap render fn with withId when having scoped styles', async () => {
const { content } = compile(
`
<script setup>
const msg = 1
</script>
<template><h1>{{ msg }}</h1></template>
<style scoped>
h1 { color: red; }
</style>
`,
{
inlineTemplate: true
}
)
expect(content).toMatch(`return (_ctx, _cache`)
expect(content).not.toMatch(`_withId(`)
assertCode(content)
})
})
describe('with TypeScript', () => {

View File

@@ -148,15 +148,6 @@ export function compileScript(
)
}
// TODO remove on 3.2
if (sfc.template && sfc.template.attrs['inherit-attrs'] === 'false') {
warnOnce(
`Experimental support for <template inherit-attrs="false"> support has ` +
`been removed. Use a <script> block with \`export default\` to ` +
`declare options.`
)
}
const scopeId = options.id ? options.id.replace(/^data-v-/, '') : ''
const cssVars = sfc.cssVars
const scriptLang = script && script.lang