caleb531 / jcanvas

A jQuery plugin that makes the HTML5 canvas easy to work with.
https://projects.calebevans.me/jcanvas/
MIT License
626 stars 192 forks source link

drawText converting the 'text' param to a number #165

Closed dmfilho closed 9 years ago

dmfilho commented 10 years ago

When using the $(canvas).drawText() function, jcanvas is converting the 'text' parameter to a number, so, for instance, if I want to write the string '012345' the 0 is removed as a "leading zero" when the conversion to number takes place.

As a simple fix, I replaced the line 193, on the function '_coerceNumericProps' by the following one: if (propType === 'string' && propValue !== '' && !isNaN( propValue) && propName != 'text') {

However, I believe that you would like to make a broader correction that also works for other similar cases if there are any.

Thank you!

nickw444 commented 9 years ago

This is believable similar to this

An empty string causes the NaN error.

caleb531 commented 9 years ago

This issue should be fixed now (as of v14.10.16).

Caleb