@vitarx/plugin-vite 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -109,6 +109,10 @@ function processChildExpression(expr, ctx) {
|
|
|
109
109
|
if (isMemberExpression(expr)) {
|
|
110
110
|
return handleMemberExpression(expr, ctx);
|
|
111
111
|
}
|
|
112
|
+
// 可选链初始可能为空,必须延迟读取,才能在信号变化后重新建立依赖。
|
|
113
|
+
if (t.isOptionalMemberExpression(expr) || t.isOptionalCallExpression(expr)) {
|
|
114
|
+
return wrapWithExpr(expr, ctx);
|
|
115
|
+
}
|
|
112
116
|
// 如果是条件表达式(如 ternary operator),递归处理条件表达式
|
|
113
117
|
if (isConditionalExpression(expr)) {
|
|
114
118
|
return processConditionalExpression(expr, ctx);
|
|
@@ -108,13 +108,14 @@ ctx // 转换上下文,包含转换过程中的相关信息
|
|
|
108
108
|
if (isStaticValue(value)) {
|
|
109
109
|
return t.objectProperty(keyNode, value);
|
|
110
110
|
}
|
|
111
|
+
// 绑定目标必须保留引用本身,成员访问和调用结果也不能按普通属性解包。
|
|
112
|
+
if (key === 'ref') {
|
|
113
|
+
return t.objectProperty(keyNode, value);
|
|
114
|
+
}
|
|
111
115
|
// 如果是标识符(变量名)
|
|
112
116
|
if (t.isIdentifier(value)) {
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
// - ref: ref 绑定需要 ref 对象本身,运行时通过 isRef() 判定后赋值 .value
|
|
116
|
-
// 若此处 unref/.value 解包,popProperty 取到解包值(如 null),isRef 失败
|
|
117
|
-
if (key === 'children' || key === 'ref') {
|
|
117
|
+
// children 允许 ref 作为可变渲染源,保持引用本身。
|
|
118
|
+
if (key === 'children') {
|
|
118
119
|
return t.objectProperty(keyNode, value);
|
|
119
120
|
}
|
|
120
121
|
// 已知非 ref 变量(函数声明、箭头函数等):静态分析确定非 ref,直接赋值无需 unref
|