audiobookshelf/client/.nuxt/components/utils.js

31 lines
662 B
JavaScript
Raw Normal View History

2021-08-18 00:01:11 +02:00
// nuxt/nuxt.js#8607
export function wrapFunctional(options) {
if (!options || !options.functional) {
return options
}
const propKeys = Array.isArray(options.props) ? options.props : Object.keys(options.props || {})
return {
render(h) {
const attrs = {}
const props = {}
for (const key in this.$attrs) {
if (propKeys.includes(key)) {
props[key] = this.$attrs[key]
} else {
attrs[key] = this.$attrs[key]
}
}
return h(options, {
on: this.$listeners,
attrs,
props,
scopedSlots: this.$scopedSlots,
}, this.$slots.default)
}
}
}