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

Component slots #154

Open
4 of 7 tasks
Tracked by #4
Ubugeeei opened this issue Mar 17, 2024 · 6 comments
Open
4 of 7 tasks
Tracked by #4

Component slots #154

Ubugeeei opened this issue Mar 17, 2024 · 6 comments

Comments

@Ubugeeei
Copy link
Member

Ubugeeei commented Mar 17, 2024

@LittleSound
Copy link
Member

I am trying to implement this issue, I noticed that currently slot outlets need to be obtained through the instance, do we need to create a createSlot function to handle this?

function render(_ctx) {
 // some codess

  const n3 = _createSlot('default', {
    foo: ()=> _ctx.bar
  }, () => {
    return _template('<div>fallback content</div>')
  })

 // some codes
}

@Ubugeeei
Copy link
Member Author

I see. Is this similar to the discussion here?
#84
#74 (comment)

Is it not good to directly reference currentInstance or use getCurrentInstance?

@Ubugeeei
Copy link
Member Author

Considering props and attrs as well, it might be better to have a function that directly references the instance or a function for accessing parts of it, rather than creating createSlot. 🤔
getCurrentInstance, or getSlots, getAttrs, getProps, .... 🤔 🤔

What do you think? cc @sxzz

@LittleSound
Copy link
Member

LittleSound commented Mar 26, 2024

I think it is necessary, because for complex requirements such as dynamic slot outlets (<slot :name="foo" />), encapsulating functions can reduce the complexity of generating code.

@Ubugeeei
Copy link
Member Author

Indeed. That might be better.

@sxzz
Copy link
Member

sxzz commented Apr 12, 2024

I think createSlots is a proper abstraction considering scope slot is a pretty complex feature.

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