From 9d69be4c613ae77d532a686424d69f3e3b491b5b Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sat, 29 Jul 2017 21:10:48 -0400 Subject: [PATCH] Fixing failing tests --- spec/parser/javascript/charset_spec.js | 2 +- src/js/parser/javascript/node.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/spec/parser/javascript/charset_spec.js b/spec/parser/javascript/charset_spec.js index 2e74b50..12ca677 100644 --- a/spec/parser/javascript/charset_spec.js +++ b/spec/parser/javascript/charset_spec.js @@ -99,7 +99,7 @@ describe('parser/javascript/charset.js', function() { this.node.elements[1].render.and.returnValue(this.elementDeferred[1].promise); this.node.elements[2].render.and.returnValue(this.elementDeferred[2].promise); - this.node.container = Snap(document.createElement('svg')); + this.node.container = Snap(document.createElement('svg')).group(); this.partContainer = this.node.container.group(); spyOn(this.node.container, 'group').and.returnValue(this.partContainer); spyOn(this.partContainer, 'group').and.callFake(function() { diff --git a/src/js/parser/javascript/node.js b/src/js/parser/javascript/node.js index 48d3b06..77cb366 100644 --- a/src/js/parser/javascript/node.js +++ b/src/js/parser/javascript/node.js @@ -164,7 +164,9 @@ export default class Node { return this.deferredStep() .then(() => { let labelBox = label.getBBox(), - contentBox = content.getBBox(); + contentBox = content.getBBox(), + boxWidth = Math.max(contentBox.width + options.padding * 2, labelBox.width), + boxHeight = contentBox.height + options.padding * 2; label.transform(Snap.matrix() .translate(0, labelBox.height)); @@ -173,12 +175,12 @@ export default class Node { .transform(Snap.matrix() .translate(0, labelBox.height)) .attr({ - width: Math.max(contentBox.width + options.padding * 2, labelBox.width), - height: contentBox.height + options.padding * 2 + width: boxWidth, + height: boxHeight }); content.transform(Snap.matrix() - .translate(box.getBBox().cx - contentBox.cx, labelBox.height + options.padding)); + .translate(boxWidth / 2 - contentBox.cx, labelBox.height + options.padding)); }); } };