raty
raty copied to clipboard
Chrome: Uncaught TypeError: Cannot set property 'src' of undefined
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
@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)];
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 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.
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)]