raty icon indicating copy to clipboard operation
raty copied to clipboard

Chrome: Uncaught TypeError: Cannot set property 'src' of undefined

Open rsardak opened this issue 9 years ago • 4 comments

It seems the issue is related to this one https://github.com/wbotelhos/raty/issues/177 But in the current version I don't see that fix ( if(star)... ) _setIcon: function(star, icon) { star[this.opt.starType === 'img' ? 'src' : 'className'] = this.opt.path + icon; }, Thanks in advance

rsardak avatar Jun 15 '16 11:06 rsardak

@wbotelhos This issue comes from this line : star = this.stars[Math.ceil(score) - 1];

When the option 'half' is true and the cursor is before the first star it looks for a negative index in the array. It can be easly fixed with : star = this.stars[Math.max( Math.ceil(score) - 1,0)];

YeskaNova avatar Jan 19 '17 22:01 YeskaNova

The problem exist and without cancel enabled. What I need to change with this line star = this.stars[Math.max( Math.ceil(score) - 1,0)]; ? This was the solution for me: https://github.com/mbrainiac/raty/commit/958b92dcabcbc342a041e4073f6c0e216f36ac45

ghost avatar Feb 16 '18 16:02 ghost

It can be reproduced very easly : Go to : https://wbotelhos.com/raty Go to the example for "Half" and try to select 0 star ( put the cursor before any star ) in the console you will see errors adding up.

YeskaNova avatar Feb 25 '18 10:02 YeskaNova

The problem exist and without cancel enabled. What I need to change with this line star = this.stars[Math.max( Math.ceil(score) - 1,0)]; ? This was the solution for me: https://github.com/mbrainiac/raty/commit/958b92dcabcbc342a041e4073f6c0e216f36ac45

it should also in this section _setTitle:function() change the line star = this.stars[Math.max( integer - 1,0)]

hevyfly avatar Dec 11 '18 16:12 hevyfly