Skip to content

Commit

Permalink
fix(NcActions): use new slots api
Browse files Browse the repository at this point in the history
- 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

Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
  • Loading branch information
ShGKme committed Jan 23, 2024
1 parent 99aebc3 commit 49d4233
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/mixins/actionGlobal.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
import Vue from 'vue'

Check failure on line 22 in src/mixins/actionGlobal.js

View workflow job for this annotation

GitHub Actions / eslint

'Vue' is defined but never used

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()
},
Expand All @@ -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() : ''
},
},
}

0 comments on commit 49d4233

Please sign in to comment.