Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-vapor): properly handle dynamic slot work with v-if #12660

Open
wants to merge 1 commit into
base: vapor
Choose a base branch
from

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Jan 8, 2025

  • template code
  <Comp>
    <template v-slot:[slotName] v-if="count <10">
      <h1>{{ count * 2 }}</h1>
    </template>
  </Comp>
  • compiled code
  const n3 = _createComponent(_ctx.Comp, null, {
    $: [
      () => (_ctx.count < 10
        ? {
          name: _ctx.slotName, 
          fn: () => {
            const n1 = t1()
            _renderEffect(() => _setText(n1, _ctx.count * 2))
            return n1
          }
        }
        : void 0)
    ]
  })

the dynamic slot source result will be undefined if _ctx.count > 10, so we should ensure it is valid, otherwise slot.name will throw an error.

@edison1105 edison1105 added the scope: vapor related to vapor mode label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: vapor related to vapor mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant