Skip to content

Commit

Permalink
Fix several viz widgets exporting in FF and IE (T606164) (#3028)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Gruba authored Feb 20, 2018
1 parent ef37493 commit fa40c59
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
17 changes: 16 additions & 1 deletion js/viz/core/renderers/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
44 changes: 44 additions & 0 deletions testing/tests/DevExpress.viz.renderers/Renderer.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down

0 comments on commit fa40c59

Please sign in to comment.