question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vue slots after v-if are not showing in props table of Addon Docs.

See original GitHub issue

Slots after v-if are not shown in props table of the addon “Docs”.

This example will produce a table props without the slots adolescent neither adult.

<slot v-if="age<=12" name="child">
  <!-- something for children -->
</slot>
<slot v-else-if="age<=19" name="adolescent">
  <!-- something for adolescents -->
</slot>
<slot v-else name="adult">
  <!-- something for adults -->
</slot>

My real code is the following:

<!--
  @slot Dynamic slot for individual body cell. X is the column and Y is the row.
  <span class="d-block mt-3">Example: <pre class="mt-2"><code>body-x0y1</code></pre> will set the slot
  for the cell in the column at index 0 and the row at index 1</span>
  -->
<slot
  v-if="$scopedSlots[`body-x${columnIndex}y${rowIndex}`]"
  :name="`body-x${columnIndex}y${rowIndex}`"
  :cell-data="cell">
  {{ cell }}
</slot>

<!--
  @slot Dynamic slot for all cells in a column of the table body.
  <span class="d-block mt-3">Example: <pre class="mt-2"><code>body-column-0</code></pre> will set
  all the cells of the column with index 0</span>
  -->
<slot
  v-else
  :name="`body-column-${columnIndex}`"
  :cell-data="cell">
  {{ cell }}
</slot>

The documentation props result:

Screen Shot 2020-07-29 at 22 10 55

As you can see there isn’t the slot description for body-column-${columnIndex}

Is this a bug or am I missing something?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
elevatebartcommented, Aug 22, 2020

Hey @ecarrera can you check that this issue still appears. version 4.31.1 of vue-docgen-api now uses the v3 parser.

1reaction
elevatebartcommented, Jul 31, 2020

Hello @ecarrera

Thank you for reporting. This is indeed a known issue.

https://github.com/vue-styleguidist/vue-styleguidist/issues/430

And ultimately this

https://github.com/vuejs/vue/pull/10286

In other words, the parser from vue 2 removes all comments between if and else. It makes them disappear from the parsed documentation.

I proposed a fix but it seems long forgotten now.

I will try and upgrade vue-docgen-api to the v3 compiler/parser to see if we can do better.

Read more comments on GitHub >

github_iconTop Results From Across the Web

storybook code preview doesn't show the usage of slots in ...
I solved this by removing the slot from the $props variable and simply passing it into the template with args.default ( default is...
Read more >
Slots | Vue.js
Slot content is not just limited to text. It can be any valid template content. For example, we can pass in multiple elements,...
Read more >
Select
The QSelect Vue component has two types of selection - single or multiple. This component opens up a menu for the selection list...
Read more >
Using Slots In Vue.js
You can pass functions to scoped slots too. Many libraries use this to provide reusable functional components as you'll see later. v-slot has...
Read more >
Nuxt - Built-in Components
The <Nuxt> component is the component you use to display your page components. ... To learn more about keep-alive and keep-alive-props see the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found