Commit d0d586b3 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Escape special characters for class suffix - #665

parent 5d107636
......@@ -5490,7 +5490,7 @@
return CLASS.chartArc + this.classTarget(d.data.id);
};
c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) {
return targetId || targetId === 0 ? ('-' + targetId).replace(/\s/g, '-') : '';
return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s!@#$%^&*()_+,<>]/g, '-') : '';
};
c3_chart_internal_fn.selectorTarget = function (id, prefix) {
return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -46,6 +46,13 @@ describe('c3 chart class', function () {
expect(suffix).toBe(expected);
});
it('should replace special charactors to "-"', function () {
var input = 'data1 !@#$%^&*()_+,<>',
expected = '-data1----------------',
suffix = chart.internal.getTargetSelectorSuffix(input);
expect(suffix).toBe(expected);
});
});
describe('multibyte characters on chart', function () {
......
......@@ -155,7 +155,7 @@ c3_chart_internal_fn.classChartArc = function (d) {
return CLASS.chartArc + this.classTarget(d.data.id);
};
c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) {
return targetId || targetId === 0 ? ('-' + targetId).replace(/\s/g, '-') : '';
return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s!@#$%^&*()_+,<>]/g, '-') : '';
};
c3_chart_internal_fn.selectorTarget = function (id, prefix) {
return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment