Skip to content

Commit 5ac4ef1

Browse files
Chart: fix export error by enforcing jquery wrapping (T1266360) (#28644)
1 parent d5fe718 commit 5ac4ef1

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/devextreme/js/viz/core/export.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ export let combineMarkups = function(widgets, options = { }) {
308308
const rowInfo = row.reduce((r, item, colIndex) => {
309309
const size = item.getSize();
310310
const backgroundColor = item.option('backgroundColor') || getTheme(item.option('theme')).backgroundColor;
311-
const node = item.element()
311+
const node = $(item.element())
312312
.find('svg')
313313
.get(0)
314314
.cloneNode(true);

packages/devextreme/testing/tests/DevExpress.viz.core/export.tests.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,31 @@ QUnit.test('exportFromMarkup. backgroundColor from current theme', function(asse
737737
}
738738
});
739739

740+
QUnit.test('exportWidgets method should be able export plain DOM element (T1266360)', function(assert) {
741+
const optionMock = () => {
742+
return {
743+
fileName: 'chart',
744+
format: 'PNG',
745+
};
746+
};
747+
748+
const widgets = [
749+
createMockWidget({ height: 25, width: 10 }, optionMock),
750+
];
751+
752+
widgets.forEach(widget => {
753+
const originalElement = widget.element();
754+
widget.element = sinon.stub().returns(originalElement[0]); // Get native DOM
755+
});
756+
757+
try {
758+
exportModule.exportWidgets(widgets);
759+
assert.strictEqual(clientExporter.export.getCall(0).args[0].nodeName, 'svg', 'combineMarkups should pass to export DOM node');
760+
} catch(error) {
761+
assert.ok(false, 'exportWidgets doesnt work when plain DOM is passed as argument');
762+
}
763+
});
764+
740765
QUnit.test('exportWidgets method should pass to export markup as DOM node', function(assert) {
741766
const optionMock = (param) => {
742767
if(param === 'theme') return 'someTheme.light';

0 commit comments

Comments
 (0)