BinarCode / vue-notifyjs

Minimalist 1kb Notification component
MIT License
170 stars 28 forks source link

Avoid using object as key, use primitive instead #5

Closed riker09 closed 7 years ago

riker09 commented 7 years ago

Great plugin, I enjoy using it. However, I installed a fresh copy directly from npm (npm install --save vue-notifyjs) and it fetched version 0.1.7. I was getting warnings in my browsers console that stated the key should not be a complex but a primitive type like string or integer.

Looking in the source code of the module in my node_modules/vue-notifyjs/dist I could find the culprit rather easy:

                        component: notification.component,
                        timestamp: notification.timestamp
                    },
                    key: notification, on: {
                        'close': function close() {
                            return _this.removeNotification(index);
                        }
                    }

I've manually changed key: notification to key: index and the error was gone. Now the funky bits click in: I forked your repo on GitHub and tried to create a pull request. But then I saw that your source code already contains a fix: You use the timestamp value of the notification to create a unique key. Very nice, but why is this not included on the NPM repo? I have never published anything on NPM so I can only assume that maybe you've uploaded the wrong version?

cristijora commented 7 years ago

Thanks for pointing that out @riker09 It seems that I didn't update the version after my latest changes 🦆 Just published a new version 0.1.8

riker09 commented 7 years ago

I can confirm that the error is now gone. Thank you! 👍