From fa40c59cf540362f5a6e5c5f3a8579f420868b9b Mon Sep 17 00:00:00 2001 From: Pavel Gruba Date: Tue, 20 Feb 2018 18:23:09 +0300 Subject: [PATCH] Fix several viz widgets exporting in FF and IE (T606164) (#3028) --- js/viz/core/renderers/renderer.js | 17 ++++++- .../Renderer.tests.js | 44 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/js/viz/core/renderers/renderer.js b/js/viz/core/renderers/renderer.js index 867a9d095d09..a1a8ffc5a7c5 100644 --- a/js/viz/core/renderers/renderer.js +++ b/js/viz/core/renderers/renderer.js @@ -1558,6 +1558,18 @@ Renderer.prototype = { } }, + removePlacementFix: function() { + if(!browser.mozilla && !browser.msie) { + return; + } + + if(browser.msie) { + this.root.css({ transform: "" }); + } else if(browser.mozilla) { + this.root.attr({ transform: null }); + } + }, + setOptions: function(options) { var that = this; that.rtl = !!options.rtl; @@ -1642,7 +1654,10 @@ Renderer.prototype = { }, svg: function() { - return this.root.markup(); + this.removePlacementFix(); + var markup = this.root.markup(); + this.fixPlacement(); + return markup; }, getRootOffset: function() { diff --git a/testing/tests/DevExpress.viz.renderers/Renderer.tests.js b/testing/tests/DevExpress.viz.renderers/Renderer.tests.js index 815bb0ce20ac..7df54c155f11 100644 --- a/testing/tests/DevExpress.viz.renderers/Renderer.tests.js +++ b/testing/tests/DevExpress.viz.renderers/Renderer.tests.js @@ -484,6 +484,50 @@ QUnit.test('Compensate root coordinates on fixPlacement call', function(assert) } }); +QUnit.test('Remove compensation before getting markup, compensate again after', function(assert) { + //arrange + var renderer = new Renderer({ + container: this.container + }); + this.boundingRect = { left: 123.34, top: 2.5 }; + renderer.root.stub("attr").reset(); + renderer.root.stub("css").reset(); + renderer.root.stub("markup").reset(); + renderer.root.stub("move").reset(); + + //act + renderer.svg(); + + //assert + if(browser.mozilla) { + assert.deepEqual(renderer.root.attr.callCount, 1); + assert.deepEqual(renderer.root.attr.getCall(0).args, [{ transform: null }]); + + assert.strictEqual(renderer.root.markup.callCount, 1); + assert.ok(renderer.root.markup.getCall(0).calledAfter(renderer.root.attr.getCall(0))); + + assert.deepEqual(renderer.root.move.callCount, 1); + assert.deepEqual(renderer.root.move.getCall(0).args, [-0.34, -0.5]); + assert.ok(renderer.root.move.getCall(0).calledAfter(renderer.root.markup.getCall(0))); + + } else if(browser.msie) { + assert.deepEqual(renderer.root.css.callCount, 2); + assert.deepEqual(renderer.root.css.getCall(0).args, [{ transform: "" }]); + + assert.strictEqual(renderer.root.markup.callCount, 1); + assert.ok(renderer.root.markup.getCall(0).calledAfter(renderer.root.css.getCall(0))); + + assert.deepEqual(renderer.root.css.getCall(1).args, [{ + transform: "translate(-0.34px,-0.5px)" + }]); + assert.ok(renderer.root.css.getCall(1).calledAfter(renderer.root.markup.getCall(0))); + } else { + assert.deepEqual(renderer.root.stub("move").callCount, 0); + assert.deepEqual(renderer.root.stub("css").callCount, 0); + assert.strictEqual(renderer.root.markup.callCount, 1); + } +}); + QUnit.module('Renderer drawing API', { before: setMockElements,