Skip to content

Rendering a Single Node in a Portal #20

@johndugan

Description

@johndugan

Hi Linus,

I'm not sure if this is a bug. I'm new to Vue, so bare with me. I am using simple portal as a local component, and passing it a single child component, like below.

<Portal selector="#site-footer">
    <AppStatusbar
        document-type="order"
        :pending-count="pendingCount"
        :is-sending="false"
        :is-success="false"
        :is-error="false"
    />
</Portal>

^ This will not render.

<Portal selector="#site-footer">
    &nbsp;
    <AppStatusbar
        document-type="order"
        :pending-count="pendingCount"
        :is-sending="false"
        :is-success="false"
        :is-error="false"
    />
</Portal>

^ This will render.

If I remove the ternary condition in your render function as shown below, my first example renders.

render: function render(h) {
    var nodes = this.updatedNodes && this.updatedNodes();
    if (!nodes) return h();
    // return nodes.length < 2 && !nodes[0].text ? nodes : h(this.tag || 'DIV', nodes);
    return h(this.tag || 'DIV', nodes);
}

So, wondering what the purpose of the ternary check is?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions