shakee93 / vue-toasted

🖖 Responsive Touch Compatible Toast plugin for VueJS 2+
https://shakee93.github.io/vue-toasted/
MIT License
2.21k stars 194 forks source link

Fixes error which is manipulating the existing object.className Array resulting in wrong css properties of toast in nuxt #195

Closed simonneutert closed 1 year ago

simonneutert commented 3 years ago

version "@nuxtjs/toast": "^3.3.1",

cannot tell whether the problem exists in plain vue.js, too, but in nuxt the error can be reproduced by:

  toast: {
    position: 'top-center',
    className: ['my-custom-toast'],
    action: {
      text: 'X',
      onClick: (e, toastObject) => {
        toastObject.goAway(0)
      },
    },
  },

Looking at the source code, I assume it happened because of an array shallow copy bug.

https://github.com/shakee93/vue-toasted/blob/db5ccc47b9b7b27f097dde0943d67f4269c6be0d/src/js/show.js#L79

When String was used, options.className was reassigned to a new Array, but underlying options.className had items pushed to it, modifying in place.