mirror of https://github.com/vuejs/core.git
fix(compiler-sfc): fix using imported ref as template ref during dev (#7593)
close #7567
This commit is contained in:
parent
201c46df07
commit
776ebf25b2
|
@ -775,6 +775,21 @@ return { get FooBaz() { return FooBaz }, get Last() { return Last } }
|
|||
})"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> > dev mode import usage check > template ref 1`] = `
|
||||
"import { defineComponent as _defineComponent } from 'vue'
|
||||
import { foo, bar, Baz } from './foo'
|
||||
|
||||
export default /*#__PURE__*/_defineComponent({
|
||||
setup(__props, { expose: __expose }) {
|
||||
__expose();
|
||||
|
||||
|
||||
return { get foo() { return foo }, get bar() { return bar }, get Baz() { return Baz } }
|
||||
}
|
||||
|
||||
})"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> > dev mode import usage check > vue interpolations 1`] = `
|
||||
"import { defineComponent as _defineComponent } from 'vue'
|
||||
import { x, y, z, x$y } from './x'
|
||||
|
|
|
@ -513,6 +513,23 @@ describe('SFC compile <script setup>', () => {
|
|||
</template>
|
||||
`)
|
||||
})
|
||||
|
||||
test('template ref', () => {
|
||||
const { content } = compile(`
|
||||
<script setup lang="ts">
|
||||
import { foo, bar, Baz } from './foo'
|
||||
</script>
|
||||
<template>
|
||||
<div ref="foo"></div>
|
||||
<div ref=""></div>
|
||||
<Baz ref="bar" />
|
||||
</template>
|
||||
`)
|
||||
expect(content).toMatch(
|
||||
'return { get foo() { return foo }, get bar() { return bar }, get Baz() { return Baz } }'
|
||||
)
|
||||
assertCode(content)
|
||||
})
|
||||
})
|
||||
|
||||
describe('inlineTemplate mode', () => {
|
||||
|
|
|
@ -57,6 +57,9 @@ function resolveTemplateUsageCheckString(sfc: SFCDescriptor) {
|
|||
)}`
|
||||
}
|
||||
}
|
||||
if (prop.type === NodeTypes.ATTRIBUTE && prop.name === 'ref' && prop.value?.content) {
|
||||
code += `,${prop.value.content}`
|
||||
}
|
||||
}
|
||||
} else if (node.type === NodeTypes.INTERPOLATION) {
|
||||
code += `,${processExp(
|
||||
|
|
Loading…
Reference in New Issue