Skip to content

Commit 3019508

Browse files
committed
wip: fix binding type fallback
1 parent 886ed76 commit 3019508

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

packages/compiler-core/src/codegen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export function generate(
227227
if (genScopeId) {
228228
push(`${PURE_ANNOTATION}_withId(`)
229229
}
230-
push(`() => {`)
230+
push(`(_ctx, _cache${optimizeSources}) => {`)
231231
} else {
232232
if (genScopeId) {
233233
push(`const render = ${PURE_ANNOTATION}_withId(`)

packages/compiler-core/src/transforms/transformExpression.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,17 @@ export function processExpression(
100100

101101
const { inline, inlinePropsIdentifier, bindingMetadata } = context
102102
const prefix = (raw: string) => {
103+
const type = hasOwn(bindingMetadata, raw) && bindingMetadata[raw]
103104
if (inline) {
104-
// setup inline mode, it's either props or setup
105-
if (bindingMetadata[raw] !== 'setup') {
105+
// setup inline mode
106+
if (type === 'props') {
106107
return `${inlinePropsIdentifier}.${raw}`
107-
} else {
108+
} else if (type === 'setup') {
108109
return `${context.helperString(UNREF)}(${raw})`
109110
}
110-
} else {
111-
const source = hasOwn(bindingMetadata, raw)
112-
? `$` + bindingMetadata[raw]
113-
: `_ctx`
114-
return `${source}.${raw}`
115111
}
112+
// fallback to normal
113+
return `${type ? `$${type}` : `_ctx`}.${raw}`
116114
}
117115

118116
// fast path if expression is a simple identifier.

packages/compiler-sfc/src/compileScript.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ export function compileScript(
685685
if (script) {
686686
if (startOffset < scriptStartOffset!) {
687687
// <script setup> before <script>
688+
s.remove(0, startOffset)
688689
s.remove(endOffset, scriptStartOffset!)
689690
s.remove(scriptEndOffset!, source.length)
690691
} else {

0 commit comments

Comments
 (0)