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

Not able to specify slot name inside render function (createElement) #5774

Closed
mind0n opened this issue May 28, 2017 · 3 comments
Closed

Not able to specify slot name inside render function (createElement) #5774

mind0n opened this issue May 28, 2017 · 3 comments

Comments

@mind0n
Copy link

mind0n commented May 28, 2017

What problem does this feature solve?

Specify slot name within render function like below:

return createElement(rootcmp, { default: [ createElement(childCmp) ], temp: [ createElement(childCmp2) ] } );

What does the proposed API look like?

From within the render function, specify the slot name such as 'default', 'temp' when creating child elements.

return createElement(rootcmp, { default: [ createElement(childCmp) ], temp: [ createElement(childCmp2) ] } );

Full code below:

@Component({
    props:[]
})
export class TestComponent extends Widget{
    items:any[];
    render(createElement:any){
        const rootcmp = {
            template:`<div>
                Temp:<slot name="temp"></slot>
                Default:<slot></slot>
            </div>`
            , data:()=>{
                return {};
            }
        }
        const childcmp = {
            template:'<div slot="default">This is child</div>'
            , data:()=>{
                return {};
            }
        }
        const childcmp2 = {
            template:'<div slot="temp">This is child</div>'
            , data:()=>{
                return {};
            }
        }
        return createElement(rootcmp
             , { default: [ createElement(childcmp) ], temp:[ createElement(childcmp2) ]);
    }
}

Expected behavior:

<div>
      Temp:<div>This is child</div>
      Default:<div>This is child</div>
</div>
@mind0n mind0n changed the title Not able to specify slot name inside render function Not able to specify slot name inside render function (createElement) May 28, 2017
@yyx990803
Copy link
Member

Use createElement(childcmp, { slot: 'temp' }).

@y-nk
Copy link

y-nk commented Feb 12, 2019

@yyx990803 is there a technical reason why we need to proceed as is ? this way is highly unpractical when dealing with recursively generated nodes in a large batch, i wonder if there's any good reason why we can't do better.

@avxkim
Copy link

avxkim commented Jul 15, 2020

Actually this createElement(childcmp, { slot: 'temp' }) has no effect on a slot.

Created a bug report: #11519

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

No branches or pull requests

4 participants