Skip to content

Commit

Permalink
fix: check both $slots and $scopedSlots, normalise slot case
Browse files Browse the repository at this point in the history
fixes #8676
closes #15293
  • Loading branch information
KaelWD committed Feb 12, 2024
1 parent d6c19b1 commit 7d67046
Show file tree
Hide file tree
Showing 46 changed files with 121 additions and 100 deletions.
7 changes: 4 additions & 3 deletions packages/vuetify/src/components/VAlert/VAlert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Transitionable from '../../mixins/transitionable'
// Utilities
import mixins from '../../util/mixins'
import { breaking } from '../../util/console'
import { getSlot } from '../../util/helpers'

// Types
import { VNodeData } from 'vue'
Expand Down Expand Up @@ -188,10 +189,10 @@ export default mixins(
methods: {
genWrapper (): VNode {
const children = [
this.$slots.prepend || this.__cachedIcon,
getSlot(this, 'prepend') || this.__cachedIcon,
this.genContent(),
this.__cachedBorder,
this.$slots.append,
getSlot(this, 'append'),
this.$scopedSlots.close
? this.$scopedSlots.close({ toggle: this.toggle })
: this.__cachedDismissible,
Expand All @@ -206,7 +207,7 @@ export default mixins(
genContent (): VNode {
return this.$createElement('div', {
staticClass: 'v-alert__content',
}, this.$slots.default)
}, getSlot(this))
},
genAlert (): VNode {
let data: VNodeData = {
Expand Down
3 changes: 2 additions & 1 deletion packages/vuetify/src/components/VApp/VApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Themeable from '../../mixins/themeable'

// Utilities
import mixins from '../../util/mixins'
import { getSlot } from '../../util/helpers'

/* @vue/component */
export default mixins(
Expand Down Expand Up @@ -41,7 +42,7 @@ export default mixins(
},

render (h) {
const wrapper = h('div', { staticClass: 'v-application--wrap' }, this.$slots.default)
const wrapper = h('div', { staticClass: 'v-application--wrap' }, getSlot(this))

return h('div', {
staticClass: 'v-application',
Expand Down
6 changes: 3 additions & 3 deletions packages/vuetify/src/components/VAppBar/VAppBarTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ExtractVue } from '../../util/mixins'
import VAppBar from './VAppBar'

// Utilities
import { convertToUnit } from '../../util/helpers'
import { convertToUnit, getSlot } from '../../util/helpers'
import { easeInOutCubic } from '../../services/goto/easing-patterns'

const base = inject<'VAppBar', typeof VAppBar>('VAppBar', 'v-app-bar-title', 'v-app-bar')
Expand Down Expand Up @@ -67,14 +67,14 @@ export default base.extend<options>().extend({
class: 'v-app-bar-title__content',
style: this.styles,
ref: 'content',
}, [this.$slots.default]),
}, getSlot(this)),
h('div', {
class: 'v-app-bar-title__placeholder',
style: {
visibility: this.VAppBar.scrollRatio ? 'hidden' : 'visible',
},
ref: 'placeholder',
}, [this.$slots.default]),
}, getSlot(this)),
])
},
})
4 changes: 2 additions & 2 deletions packages/vuetify/src/components/VAvatar/VAvatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Measurable from '../../mixins/measurable'
import Roundable from '../../mixins/roundable'

// Utilities
import { convertToUnit } from '../../util/helpers'
import { convertToUnit, getSlot } from '../../util/helpers'

// Types
import { VNode } from 'vue'
Expand Down Expand Up @@ -55,6 +55,6 @@ export default mixins(
on: this.$listeners,
}

return h('div', this.setBackgroundColor(this.color, data), this.$slots.default)
return h('div', this.setBackgroundColor(this.color, data), getSlot(this))
},
})
11 changes: 4 additions & 7 deletions packages/vuetify/src/components/VBanner/VBanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ import Toggleable from '../../mixins/toggleable'

// Utilities
import mixins from '../../util/mixins'
import {
convertToUnit,
getSlot,
} from '../../util/helpers'
import { convertToUnit, getSlot } from '../../util/helpers'

// Typeslint
import { VNode } from 'vue'
Expand Down Expand Up @@ -56,7 +53,7 @@ export default mixins(
}
},
hasIcon (): boolean {
return Boolean(this.icon || this.$slots.icon)
return Boolean(this.icon || this.$slots.icon || this.$scopedSlots.icon)
},
isSticky (): boolean {
return this.sticky || this.app
Expand Down Expand Up @@ -99,7 +96,7 @@ export default mixins(
},
}, [this.icon])
} else {
content = this.$slots.icon
content = getSlot(this, 'icon')
}

return this.$createElement(VAvatar, {
Expand All @@ -116,7 +113,7 @@ export default mixins(
genText () {
return this.$createElement('div', {
staticClass: 'v-banner__text',
}, this.$slots.default)
}, getSlot(this))
},
genActions () {
const children = getSlot(this, 'actions', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { factory as ToggleableFactory } from '../../mixins/toggleable'
// Utilities
import mixins from '../../util/mixins'
import { breaking } from '../../util/console'
import { getSlot } from '../../util/helpers'

// Types
import { VNode } from 'vue'
Expand Down Expand Up @@ -152,6 +153,6 @@ export default mixins(
})
}

return h(ButtonGroup, this.setTextColor(this.color, data), this.$slots.default)
return h(ButtonGroup, this.setTextColor(this.color, data), getSlot(this))
},
})
3 changes: 2 additions & 1 deletion packages/vuetify/src/components/VBreadcrumbs/VBreadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Themeable from '../../mixins/themeable'

// Utils
import mixins from '../../util/mixins'
import { getSlot } from '../../util/helpers'

export default mixins(
Themeable
Expand Down Expand Up @@ -67,7 +68,7 @@ export default mixins(
},

render (h): VNode {
const children = this.$slots.default || this.genItems()
const children = getSlot(this) || this.genItems()

return h('ul', {
staticClass: 'v-breadcrumbs',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Routable from '../../mixins/routable'

import mixins from '../../util/mixins'
import { getSlot } from '../../util/helpers'
import { VNode } from 'vue'

/* @vue/component */
Expand Down Expand Up @@ -39,7 +40,7 @@ export default mixins(Routable).extend({
...data.attrs,
'aria-current': this.isActive && this.isLink ? 'page' : undefined,
},
}, this.$slots.default),
}, getSlot(this)),
])
},
})
5 changes: 3 additions & 2 deletions packages/vuetify/src/components/VBtn/VBtn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Sizeable from '../../mixins/sizeable'
// Utilities
import mixins, { ExtractVue } from '../../util/mixins'
import { breaking } from '../../util/console'
import { getSlot } from '../../util/helpers'

// Types
import { VNode } from 'vue'
Expand Down Expand Up @@ -167,12 +168,12 @@ export default baseMixins.extend<options>().extend({
genContent (): VNode {
return this.$createElement('span', {
staticClass: 'v-btn__content',
}, this.$slots.default)
}, getSlot(this))
},
genLoader (): VNode {
return this.$createElement('span', {
class: 'v-btn__loader',
}, this.$slots.loader || [this.$createElement(VProgressCircular, {
}, getSlot(this, 'loader') || [this.$createElement(VProgressCircular, {
props: {
indeterminate: true,
size: 23,
Expand Down
3 changes: 2 additions & 1 deletion packages/vuetify/src/components/VCard/VCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Routable from '../../mixins/routable'

// Helpers
import mixins from '../../util/mixins'
import { getSlot } from '../../util/helpers'

// Types
import { VNode } from 'vue'
Expand Down Expand Up @@ -86,7 +87,7 @@ export default mixins(

return h(tag, this.setBackgroundColor(this.color, data), [
this.genProgress(),
this.$slots.default,
getSlot(this),
])
},
})
3 changes: 2 additions & 1 deletion packages/vuetify/src/components/VChip/VChip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Sizeable from '../../mixins/sizeable'

// Utilities
import { breaking } from '../../util/console'
import { getSlot } from '../../util/helpers'

// Types
import { PropValidator, PropType } from 'vue/types/options'
Expand Down Expand Up @@ -169,7 +170,7 @@ export default mixins(
staticClass: 'v-chip__content',
}, [
this.filter && this.genFilter(),
this.$slots.default,
getSlot(this),
this.hasClose && this.genClose(),
])
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ export default mixins(
},
genEmpty (originalItemsLength: number, filteredItemsLength: number) {
if (originalItemsLength === 0 && this.loading) {
const loading = this.$slots.loading || this.$vuetify.lang.t(this.loadingText)
const loading = getSlot(this, 'loading') || this.$vuetify.lang.t(this.loadingText)
return this.genEmptyWrapper(loading)
} else if (originalItemsLength === 0) {
const noData = this.$slots['no-data'] || this.$vuetify.lang.t(this.noDataText)
const noData = getSlot(this, 'noData') || this.$vuetify.lang.t(this.noDataText)
return this.genEmptyWrapper(noData)
} else if (filteredItemsLength === 0) {
const noResults = this.$slots['no-results'] || this.$vuetify.lang.t(this.noResultsText)
const noResults = getSlot(this, 'noResults') || this.$vuetify.lang.t(this.noResultsText)
return this.genEmptyWrapper(noResults)
}

Expand Down
6 changes: 3 additions & 3 deletions packages/vuetify/src/components/VDataTable/VEditDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Returnable from '../../mixins/returnable'
import Themeable from '../../mixins/themeable'

// Utils
import { keyCodes } from '../../util/helpers'
import { getSlot, keyCodes } from '../../util/helpers'

// Component
import VBtn from '../VBtn'
Expand Down Expand Up @@ -96,7 +96,7 @@ export default mixins(Returnable, Themeable).extend({
},
},
ref: 'content',
}, [this.$slots.input])
}, getSlot(this, 'input'))
},
},

Expand Down Expand Up @@ -127,7 +127,7 @@ export default mixins(Returnable, Themeable).extend({
}, [
h('span', {
staticClass: 'v-small-dialog__activator__content',
}, this.$slots.default),
}, getSlot(this)),
])
},
},
Expand Down
8 changes: 4 additions & 4 deletions packages/vuetify/src/components/VDataTable/VSimpleTable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './VSimpleTable.sass'

import { convertToUnit } from '../../util/helpers'
import { convertToUnit, getSlot } from '../../util/helpers'
import Themeable from '../../mixins/themeable'
import mixins from '../../util/mixins'
import { VNode } from 'vue'
Expand Down Expand Up @@ -35,7 +35,7 @@ export default mixins(Themeable).extend({
height: convertToUnit(this.height),
},
}, [
this.$createElement('table', this.$slots.default),
this.$createElement('table', getSlot(this)),
])
},
},
Expand All @@ -45,9 +45,9 @@ export default mixins(Themeable).extend({
staticClass: 'v-data-table',
class: this.classes,
}, [
this.$slots.top,
getSlot(this, 'top'),
this.genWrapper(),
this.$slots.bottom,
getSlot(this, 'bottom'),
])
},
})
6 changes: 3 additions & 3 deletions packages/vuetify/src/components/VDataTable/VVirtualTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { PropValidator } from 'vue/types/options'
import mixins from '../../util/mixins'

// Utiltiies
import { convertToUnit, debounce } from '../../util/helpers'
import { convertToUnit, debounce, getSlot } from '../../util/helpers'

// Types
const baseMixins = mixins(VSimpleTable)
Expand Down Expand Up @@ -155,9 +155,9 @@ export default baseMixins.extend<options>().extend({
staticClass: 'v-data-table v-virtual-table',
class: this.classes,
}, [
this.$slots.top,
getSlot(this, 'top'),
this.genWrapper(),
this.$slots.bottom,
getSlot(this, 'bottom'),
])
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Themeable from '../../mixins/themeable'
// Utils
import { createNativeLocaleFormatter, monthChange } from './util'
import mixins from '../../util/mixins'
import { getSlot } from '../../util/helpers'

// Types
import { VNode, PropType } from 'vue'
Expand Down Expand Up @@ -117,7 +118,7 @@ export default mixins(
on: {
click: () => this.$emit('toggle'),
},
}, [this.$slots.default || this.formatter(String(this.value))])])
}, getSlot(this) || [this.formatter(String(this.value))])])

const transition = this.$createElement('transition', {
props: {
Expand Down
4 changes: 2 additions & 2 deletions packages/vuetify/src/components/VFooter/VFooter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SSRBootable from '../../mixins/ssr-bootable'

// Utilities
import mixins from '../../util/mixins'
import { convertToUnit } from '../../util/helpers'
import { convertToUnit, getSlot } from '../../util/helpers'

// Types
import { VNode } from 'vue/types/vnode'
Expand Down Expand Up @@ -110,6 +110,6 @@ export default mixins(
style: this.styles,
})

return h(this.tag, data, this.$slots.default)
return h(this.tag, data, getSlot(this))
},
})
3 changes: 2 additions & 1 deletion packages/vuetify/src/components/VForm/VForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { provide as RegistrableProvide } from '../../mixins/registrable'

// Helpers
import { VNode } from 'vue'
import { getSlot } from '../../util/helpers'

type ErrorBag = Record<number, boolean>
type VInputInstance = InstanceType<typeof VInput>
Expand Down Expand Up @@ -139,6 +140,6 @@ export default mixins(
on: {
submit: (e: Event) => this.$emit('submit', e),
},
}, this.$slots.default)
}, getSlot(this))
},
})
4 changes: 2 additions & 2 deletions packages/vuetify/src/components/VInput/VInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default baseMixins.extend<options>().extend({
genDefaultSlot () {
return [
this.genLabel(),
this.$slots.default,
getSlot(this),
]
},
genIcon (
Expand Down Expand Up @@ -251,7 +251,7 @@ export default baseMixins.extend<options>().extend({
for: this.computedId,
light: this.light,
},
}, this.$slots.label || this.label)
}, getSlot(this, 'label') || this.label)
},
genMessages () {
if (!this.showDetails) return null
Expand Down
Loading

0 comments on commit 7d67046

Please sign in to comment.