From 089be7c92af1b5555f43e065651c543e2cf4def0 Mon Sep 17 00:00:00 2001 From: "Grigorii K. Shartsev" Date: Tue, 23 Jan 2024 14:04:40 +0100 Subject: [PATCH] fix(NcActions): use new slots api - Since Vue 2.6 with new slots api, it is guaranteed that $scopedSlots has render function for all slots passed any way, while $slots only has value when using deprecated API or short-hand syntax - It also closer to Vue 3 API - `before` method is removed, there is no such lifecycle hook --- src/mixins/actionGlobal.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/mixins/actionGlobal.js b/src/mixins/actionGlobal.js index 96015d31a9..f0b50e82a0 100644 --- a/src/mixins/actionGlobal.js +++ b/src/mixins/actionGlobal.js @@ -22,16 +22,6 @@ import Vue from 'vue' export default { - before() { - // all actions requires a valid text content - // if none, forbid the component mount and throw error - if (!this.$slots.default || this.text.trim() === '') { - Vue.util.warn(`${this.$options.name} cannot be empty and requires a meaningful text content`, this) - this.$destroy() - this.$el.remove() - } - }, - beforeUpdate() { this.text = this.getText() }, @@ -52,7 +42,7 @@ export default { methods: { getText() { - return this.$slots.default ? this.$slots.default[0].text.trim() : '' + return this.$scopedSlots.default ? this.$scopedSlots.default()?.[0].text.trim() : '' }, }, }