Skip to content

Commit c89a8d1

Browse files
committed
fix(Consumer): Render child content when slot-scope isn't defined. Provide a warning.
If slot slot-scoped isn't defined then this.$scopedSlots.default will be undefined. Calling in in that scenario would result in an error. If it's undefined, fall back to render the default slot while giving an error that slot-scope should be defined
1 parent 399e341 commit c89a8d1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Consumer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ export default function Consumer(context) {
44
context
55
}),
66
render(h) {
7+
if (!this.$scopedSlots.default) {
8+
console.warn("Context consumer expected to define slot-scope");
9+
return this.$slots.default[0];
10+
}
711
return this.$scopedSlots.default(this.context.value);
812
}
913
};

0 commit comments

Comments
 (0)