Skip to content

Commit 8e3d4fa

Browse files
committed
don't recalculate nodehash for recursive bBox
1 parent 8305c02 commit 8e3d4fa

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/components/drawing/index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ drawing.savedBBoxes = {};
619619
var savedBBoxesCount = 0;
620620
var maxSavedBBoxes = 10000;
621621

622-
drawing.bBox = function(node) {
622+
drawing.bBox = function(node, hash) {
623623
/*
624624
* Cache elements we've already measured so we don't have to
625625
* remeasure the same thing many times
@@ -628,16 +628,16 @@ drawing.bBox = function(node) {
628628
* These will not generate a hash (unless we figure out an appropriate
629629
* hash key for them) and thus we will not hash them.
630630
*/
631-
var hash = nodeHash(node);
631+
if(!hash) hash = nodeHash(node);
632632
var out;
633633
if(hash) {
634634
out = drawing.savedBBoxes[hash];
635635
if(out) return Lib.extendFlat({}, out);
636636
}
637637
else if(node.children.length === 1) {
638638
/*
639-
* If we have only one child element, make a new hash from this element
640-
* plus its x,y,transform
639+
* If we have only one child element, which is itself hashable, make
640+
* a new hash from this element plus its x,y,transform
641641
* These bounding boxes *include* x,y,transform - mostly for use by
642642
* callers trying to avoid overlaps (ie titles)
643643
*/
@@ -647,12 +647,12 @@ drawing.bBox = function(node) {
647647
if(hash) {
648648
var x = +innerNode.getAttribute('x') || 0;
649649
var y = +innerNode.getAttribute('y') || 0;
650-
var transform = innerNode.getAttribute('transform') || '';
650+
var transform = innerNode.getAttribute('transform');
651651

652652
if(!transform) {
653653
// in this case, just varying x and y, don't bother caching
654-
// because the alteration is simple.
655-
var innerBB = drawing.bBox(innerNode);
654+
// the final bBox because the alteration is quick.
655+
var innerBB = drawing.bBox(innerNode, hash);
656656
if(x) {
657657
innerBB.left += x;
658658
innerBB.right += x;

0 commit comments

Comments
 (0)