Use useSlots().default method to determine whether the slot is in doubt after the contents of the slot have been commented out
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 54.4k
- Forks
- 9.2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 140
Description
Vue version
^3.2.13
Link to minimal reproduction
Steps to reproduce
SlotTag Component:
html:
script: const slotDefault = !!useSlots().default; console.log("default exists: " + slotDefault);App.vue:
html:
browser console output:
default exists: (...args) => {
// If a user calls a compiled slot inside a template expression (#1745), it
// can mess up block tracking, so by default we disable block tracking and
// force bail out whe…
What is expected?
the code for the annotation should not be detected, expecting a undefined value to be returned
Expect the output to be log below:
default exists: false
What is actually happening?
I'm furiously reading the vue design and implementation book, trying to figure out what's going on
System Info
No response
Any additional comments?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked SFC minimal reproduction and inspect how useSlots().default is produced for the commented-out slot content. Trace the slot behavior in the Vue core implementation and verify that the reproduction logs false rather than a slot function when the annotation is commented out.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100