Skip to content

$slots include empty vnodes #5329

@yujiaze

Description

@yujiaze

Version

2.2.6

Reproduction link

https://jsbin.com/mugosexini/edit?html,css,js,output

Steps to reproduce

const child = {
	name: "child",
	render: function () {
  	        console.log(this.$slots.default)
  	        return 1
	}
}

const parent = {
	template: "<div>\
                             <child>\
  	                           <p>1</p>\
                                   <p>2</p>\
                            </child>\
                         </div>",
	components: {
  	       child: child
        }
}

the child component console the $slots.default is a vnodes list which length is 3.

It also reproduce when I wrote parent template in <template> element

What is expected?

this.$slots.default DO NOT INCLUDE empty vnodes

What is actually happening?

this.$slots.default include a empty vnode between two <p> element


this.$slots.default seems different from React's this.props.children...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions