pathBBox() returns reference to cached bbox #543

motownread opened this Issue Mar 21, 2012 · 14 comments


None yet

pathBBox() is returning a reference rather than a copy of the cached bbox value, which means the value can be accidentally written over.

Because this function is also used internally for Element.getBBox(), it's causing weird bugs like:

console.log(paper.text(0,0,"hello").getBBox().x); // => -11 Correct!
var a = paper.text(0,0,"hello");
console.log(a.getBBox().x); // => -11 Correct!
console.log(paper.text(0,0,"hello").getBBox().x); // => -1 Wrong!

Simple fix:

-            return pth.bbox;
-           return clone(pth.bbox);
@alerizzo alerizzo added a commit to alerizzo/raphael that referenced this issue Mar 22, 2012
@alerizzo alerizzo Added fix from issue #543 to my fork dcdb673

I ran into this same issue and I can confirm that this fix worked for me.


Will read here from now on. Encountered same issue, spent a couple days on it and come here to post fix, and it's solved :P

m1ch4ls commented May 17, 2012

Thanks for fix... works great

Aukhan commented May 30, 2012

hey Thanks for the fix :) was stuck in the same issue and alot was depending on the BBox .....
Good Job :)

And Thanks to Dimitry for a remarkable Library ... Brilliant peice of work !!

awcab commented Jun 21, 2012

Same problem. Lost a day on this - thanks for the fix!

kentz commented Jun 29, 2012

I lost a whole day for this too. Thanks a ton for the fix!


Thanks for the fix. Any idea when the patch will land?

zba commented Aug 6, 2012

@DmitryBaranovskiy It is really usefull patch, can you apply to main tree ?

jdb8 commented Aug 7, 2012

Fixed very strange bugs in text placement in my code, thanks!

ghost commented Sep 4, 2012

Also ran into this. Thanks for the fix, worked perfectly.


This patch fixed a problem I had where, when a perfectly functional operation was repeated 3 or 4 times, it would unpredictably give completely unexpected X and Y co-ordinates and send the path flying off the page. With this patch, it instantly worked perfectly.

rodweb commented Feb 8, 2013

Made my day! Thanks!
But I can't compress the library to it's size of 89kb, Closure Compiler and UglifyJS give only 124. What am I doing wrong?


Thanks a bunch for this fix!


Already merged in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment