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(slots): filter out compiler marker from resolved slots #1472

Closed

Conversation

underfin
Copy link
Member

@underfin underfin commented Jun 30, 2020

fix #1470

Bug Reason

It caused by #1451. The pre fix filter out the '_' marker caused the patchflags to PatchFlags.BAIL (fragment withBaseComponent) -> the pre dynamicChildren is null.

slots._ ? PatchFlags.STABLE_FRAGMENT : PatchFlags.BAIL
if (n2.patchFlag === PatchFlags.BAIL) {
      optimized = false
      n2.dynamicChildren = null
    }

@yyx990803
Copy link
Member

Good catch. Although it's too expensive to call Object.defineProperty like this. We can simply make the initial slot marker non-enumberable. See 062835d

@yyx990803 yyx990803 closed this Jun 30, 2020
@underfin underfin deleted the fix-mark-not-enumerable-in-slots branch June 30, 2020 13:55
@underfin
Copy link
Member Author

There places maybe should prevent assign new '_' enumberable flag because it is readonly.
https://github.com/vuejs/vue-next/blob/062835d45aaf4168ddf2e39a5c7e162b3a18ccae/packages/runtime-core/src/componentSlots.ts#L133-L145

@underfin
Copy link
Member Author

underfin commented Jun 30, 2020

=.= I'm curious about why use _ flag make marker compilered slots.Why not add a new static_slots patchFlags instead of it(we has already dynamic_slots flag and them can represent all compiled case)?

The compiled code is clear and we don't nedd process edge case.

@yyx990803
Copy link
Member

Because _ already exists and is writable, the new defined property will also be writable.

The reason we don't use a vnode flag is because the slots object may get passed down in a render function. If we only check the vnode's flag, then it is treated as manual/dynamic once passed down. But if we keep the information on the slots object itself, then the optimization can be kept no matter where it is passed to.

@underfin
Copy link
Member Author

underfin commented Jul 1, 2020

Thanks a lot for your explain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slot inside v-for not working
2 participants