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(#7913): Prevent erroneous warning when using <slot> inside slot-scope #8250

Closed
wants to merge 1 commit into from

Conversation

mpbarlow
Copy link

@mpbarlow mpbarlow commented May 26, 2018

Because slotNodes inside a slot-scope context are already set to _rendered = true after initial
render, the warning for duplicate slot presence always fires when a slot-scope prop change triggers
a re-render. With this change, the compiler tracks whether any slot-scoped elements have been
encountered yet at the point the slot is compiled. If so, the direct ancestors of the slot are checked
for slot-scope presence, and if one is found, the warning is supressed.

This is admittedly not a perfect solution, as within a slot-scope context the warning now does not fire even when there are duplicate slots, but I couldn't find a good way to get around that.

fix #7913

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

…lot-scope

Because slotNodes inside a slot-scope context are already set to _rendered = true after initial
render, the warning for duplicate slot presence always fires when a slot-scope prop change triggers
a re-render. With this change, the compiler tracks whether any slot-scoped elements have been
encountered at the point the slot is compiled. If so, the direct ancestors of the slot are checked
for slot-scope presence, and if found, the warning is supressed. This is admittedly not a perfect
solution, as within a slot-scope context the warning now does not fire even when there _are_
duplicate slots, but I couldn't find a good way to get around that.

fix vuejs#7913
@yyx990803
Copy link
Member

Thanks for the PR! I managed to completely remove the "no duplicated slots" restrictions in 530ca1b, so the warning is no longer necessary.

@yyx990803 yyx990803 closed this Dec 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected "duplicate presence of slot"
2 participants