48227fb1888615c6ab19d026d341f90fca08b4cfc8e7f8f916018dfcafe1db81f3277f6f48960caf888910697dea1e89f6c824d5633bee7c471faae7839ab5 889 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* @flow */
  2. import { extend, warn, isObject } from 'core/util/index'
  3. /**
  4. * Runtime helper for rendering <slot>
  5. */
  6. export function renderSlot (
  7. name: string,
  8. fallback: ?Array<VNode>,
  9. props: ?Object,
  10. bindObject: ?Object
  11. ): ?Array<VNode> {
  12. const scopedSlotFn = this.$scopedSlots[name]
  13. let nodes
  14. if (scopedSlotFn) { // scoped slot
  15. props = props || {}
  16. if (bindObject) {
  17. if (process.env.NODE_ENV !== 'production' && !isObject(bindObject)) {
  18. warn(
  19. 'slot v-bind without argument expects an Object',
  20. this
  21. )
  22. }
  23. props = extend(extend({}, bindObject), props)
  24. }
  25. nodes = scopedSlotFn(props) || fallback
  26. } else {
  27. nodes = this.$slots[name] || fallback
  28. }
  29. const target = props && props.slot
  30. if (target) {
  31. return this.$createElement('template', { slot: target }, nodes)
  32. } else {
  33. return nodes
  34. }
  35. }