|
@@ -48,7 +48,8 @@ import {
|
|
|
KEEP_ALIVE,
|
|
KEEP_ALIVE,
|
|
|
SUSPENSE,
|
|
SUSPENSE,
|
|
|
UNREF,
|
|
UNREF,
|
|
|
- GUARD_REACTIVE_PROPS
|
|
|
|
|
|
|
+ GUARD_REACTIVE_PROPS,
|
|
|
|
|
+ IS_REF
|
|
|
} from '../runtimeHelpers'
|
|
} from '../runtimeHelpers'
|
|
|
import {
|
|
import {
|
|
|
getInnerRange,
|
|
getInnerRange,
|
|
@@ -61,7 +62,7 @@ import {
|
|
|
} from '../utils'
|
|
} from '../utils'
|
|
|
import { buildSlots } from './vSlot'
|
|
import { buildSlots } from './vSlot'
|
|
|
import { getConstantType } from './hoistStatic'
|
|
import { getConstantType } from './hoistStatic'
|
|
|
-import { BindingMetadata, BindingTypes } from '../options'
|
|
|
|
|
|
|
+import { BindingTypes } from '../options'
|
|
|
import {
|
|
import {
|
|
|
checkCompatEnabled,
|
|
checkCompatEnabled,
|
|
|
CompilerDeprecationTypes,
|
|
CompilerDeprecationTypes,
|
|
@@ -475,7 +476,7 @@ export function buildProps(
|
|
|
if (!__BROWSER__ && context.inline && value?.content) {
|
|
if (!__BROWSER__ && context.inline && value?.content) {
|
|
|
valueNode = createFunctionExpression(['_value', '_refs'])
|
|
valueNode = createFunctionExpression(['_value', '_refs'])
|
|
|
valueNode.body = createBlockStatement(
|
|
valueNode.body = createBlockStatement(
|
|
|
- processInlineRef(context.bindingMetadata, value.content)
|
|
|
|
|
|
|
+ processInlineRef(context, value.content)
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -894,15 +895,28 @@ function isComponentTag(tag: string) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function processInlineRef(
|
|
function processInlineRef(
|
|
|
- bindings: BindingMetadata,
|
|
|
|
|
|
|
+ context: TransformContext,
|
|
|
raw: string
|
|
raw: string
|
|
|
): JSChildNode[] {
|
|
): JSChildNode[] {
|
|
|
const body = [createSimpleExpression(`_refs['${raw}'] = _value`)]
|
|
const body = [createSimpleExpression(`_refs['${raw}'] = _value`)]
|
|
|
- const type = bindings[raw]
|
|
|
|
|
|
|
+ const { bindingMetadata, helperString } = context
|
|
|
|
|
+ const type = bindingMetadata[raw]
|
|
|
if (type === BindingTypes.SETUP_REF) {
|
|
if (type === BindingTypes.SETUP_REF) {
|
|
|
body.push(createSimpleExpression(`${raw}.value = _value`))
|
|
body.push(createSimpleExpression(`${raw}.value = _value`))
|
|
|
|
|
+ } else if (type === BindingTypes.SETUP_MAYBE_REF) {
|
|
|
|
|
+ body.push(
|
|
|
|
|
+ createSimpleExpression(
|
|
|
|
|
+ `${helperString(IS_REF)}(${raw}) && (${raw}.value = _value)`
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
} else if (type === BindingTypes.SETUP_LET) {
|
|
} else if (type === BindingTypes.SETUP_LET) {
|
|
|
- body.push(createSimpleExpression(`${raw} = _value`))
|
|
|
|
|
|
|
+ body.push(
|
|
|
|
|
+ createSimpleExpression(
|
|
|
|
|
+ `${helperString(
|
|
|
|
|
+ IS_REF
|
|
|
|
|
+ )}(${raw}) ? ${raw}.value = _value : ${raw} = _value`
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
return body
|
|
return body
|
|
|
}
|
|
}
|