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

Performance: compile default slots to functions #9756

Open
KaelWD opened this issue Mar 22, 2019 · 4 comments
Open

Performance: compile default slots to functions #9756

KaelWD opened this issue Mar 22, 2019 · 4 comments

Comments

@KaelWD
Copy link
Contributor

KaelWD commented Mar 22, 2019

What problem does this feature solve?

The original v-slot implementation was not available in this.$slots, but that was added in 2.6.4. Scoped slots reduce unnecessary re-renders with nested slots, so this change would hopefully provide a performance improvement for component libraries.

What does the proposed API look like?

<foo>default slot</foo>

should output

_c('foo',{scopedSlots:_u([{key:"default",fn:function(){return [_v("default slot")]},proxy:true}])})

Equivalent to <foo v-slot>default slot</foo>


Note #9580 could be a problem if lots of people rely on that behaviour.

@lbennett-stacki
Copy link
Contributor

lbennett-stacki commented Apr 3, 2019

I've got a working version of this locally but I'd like to test it further over the weekend, it's my first look here so have probably naturally oversimplified. I also auto-prettified codegen/index which is a bit of a pain.

WIP: lbennett-stacki@677ac91

@vuejs vuejs deleted a comment from houfeng0923 Apr 11, 2019
@lbennett-stacki
Copy link
Contributor

After running the tests and seeing many failures, my suspicions were confirmed 😛 I corrected for a lot of them and I seem to have the general compilation of the function together but am struggling to handle cases like the following...

  <foo>
    default-slot-content
    <span slot="test">
      test-slot-content
    </span>
  </foo>

With my current changes, foo is the same as <foo v-slot> and this breaks the test slot as no default slot placeholder is declared. Without v-slot, default-slot-content is ignored. I hope to put some more time into this as its beneficial to look around but let me know if you wanted to take it off me for a release.

@KaelWD
Copy link
Contributor Author

KaelWD commented Apr 13, 2019

Hmm that could be a problem, maybe why it wasn't done originally. I'm not familiar with the vue compiler but my first thought is to just filter anything without slotTarget

@lbennett-stacki
Copy link
Contributor

lbennett-stacki commented Apr 13, 2019

Hmm that could be a problem, maybe why it wasn't done originally. I'm not familiar with the vue compiler but my first thought is to just filter anything without slotTarget

@KaelWD I thought the same! It seems this isn't (always?) available but it has to be at some point so I'll keep digging, the behaviour might not even be in the same ground I've already covered 🔍 Maybe its impossible or leads to some tough patterns and we leave it :)

Thought: Anyone know if there is a significantly rewritten compiler for 3.0?

Update: No progress thus far. May end up in the wind.

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

No branches or pull requests

3 participants