Skip to content

Commit

Permalink
refactor(compiler-core): add in buildProps an auxiliary variable hasVFor
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Kruglov committed Apr 18, 2024
1 parent ad64013 commit 9104300
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/compiler-core/src/transforms/transformElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ export function buildProps(
const mergeArgs: PropsExpression[] = []
const runtimeDirectives: DirectiveNode[] = []
const hasChildren = children.length > 0
const hasVFor = context.scopes.vFor > 0
let shouldUseBlock = false

// patchFlag analysis
Expand Down Expand Up @@ -502,7 +503,7 @@ export function buildProps(
let isStatic = true
if (name === 'ref') {
hasRef = true
if (context.scopes.vFor > 0) {
if (hasVFor) {
properties.push(
createObjectProperty(
createSimpleExpression('ref_for', true),
Expand Down Expand Up @@ -601,7 +602,7 @@ export function buildProps(
shouldUseBlock = true
}

if (isVBind && isStaticArgOf(arg, 'ref') && context.scopes.vFor > 0) {
if (isVBind && isStaticArgOf(arg, 'ref') && hasVFor) {
properties.push(
createObjectProperty(
createSimpleExpression('ref_for', true),
Expand All @@ -617,7 +618,7 @@ export function buildProps(
if (isVBind) {
// if in v-bind object will have a ref we should set ref_for to true
// otherwise the ref will be set to a random element in the list
if (context.scopes.vFor > 0) properties.push(
if (hasVFor) properties.push(
createObjectProperty(
createSimpleExpression('ref_for', true),
createSimpleExpression('true'),
Expand Down

0 comments on commit 9104300

Please sign in to comment.