diff --git a/js/viz/core/renderers/renderer.js b/js/viz/core/renderers/renderer.js
index 649f0d9f0b02..ecabe3daa9ac 100644
--- a/js/viz/core/renderers/renderer.js
+++ b/js/viz/core/renderers/renderer.js
@@ -704,14 +704,15 @@ function adjustLineHeights(items) {
}
function removeExtraAttrs(html) {
- var findTagAttrs = /(?:<[a-z0-9])+(?:[\s\S]*?>)/gi,
- findStyleAttrWithValue = /(\S*\s*)=\s*(["'])(?:(?!\2).)*\2\s?/gi;
+ var findTagAttrs = /(?:(<[a-z0-9]+\s*))([\s\S]*?)(>|\/>)/gi,
+ findStyleAndClassAttrs = /(style|class)\s*=\s*(["'])(?:(?!\2).)*\2\s?/gi;
- return html.replace(findTagAttrs, function(allTagAttrs) {
- return allTagAttrs.replace(findStyleAttrWithValue, function(currentAttr, attrName) {
- var lowerCaseAttrName = attrName.toLowerCase();
- return lowerCaseAttrName === "style" || lowerCaseAttrName === "class" ? currentAttr : "";
- });
+ return html.replace(findTagAttrs, function(allTagAttrs, p1, p2, p3) {
+ p2 = (p2 && p2.match(findStyleAndClassAttrs) || []).map(function(str) {
+ return str;
+ }).join(" ");
+
+ return p1 + p2 + p3;
});
}
diff --git a/testing/tests/DevExpress.viz.renderers/SvgElement.tests.js b/testing/tests/DevExpress.viz.renderers/SvgElement.tests.js
index d5eae90ca2bc..dd480900277d 100644
--- a/testing/tests/DevExpress.viz.renderers/SvgElement.tests.js
+++ b/testing/tests/DevExpress.viz.renderers/SvgElement.tests.js
@@ -5489,9 +5489,12 @@ function checkDashStyle(assert, elem, result, style, value) {
}),
mixedQuotesWithStyle4 = this.createText().attr({
text: "aa", x: 20, y: 30
+ }),
+ withoutQuotes = this.createText().attr({
+ text: "", x: 20, y: 30
});
- assert.strictEqual(withoutClosingTags.DEBUG_parsedHtml, "text >with without closing");
+ assert.strictEqual(withoutClosingTags.DEBUG_parsedHtml, "text >with without closing");
assert.strictEqual(withClosing.DEBUG_parsedHtml, "text angle brackets closing");
assert.strictEqual(withSimpleMarkup.DEBUG_parsedHtml, "text with markup1");
assert.strictEqual(withSimpleStyleTag.DEBUG_parsedHtml, 'aa');
@@ -5501,5 +5504,6 @@ function checkDashStyle(assert, elem, result, style, value) {
assert.strictEqual(mixedQuotesWithStyle2.DEBUG_parsedHtml, 'aa');
assert.strictEqual(mixedQuotesWithStyle3.DEBUG_parsedHtml, " ");
assert.strictEqual(mixedQuotesWithStyle4.DEBUG_parsedHtml, "aa");
+ assert.strictEqual(withoutQuotes.DEBUG_parsedHtml, "");
});
})();