Skip to content

Commit 6c7b0ed

Browse files
committed
add support for <b>, <i> and <em> in "name" hover labels
1 parent 3d937d0 commit 6c7b0ed

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Diff for: src/components/fx/hover.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ function createHoverText(hoverData, opts, gd) {
927927
if(d.name) {
928928
name = svgTextUtils.plainText(d.name || '', {
929929
len: d.nameLength,
930-
allowedTags: ['br', 'sub', 'sup']
930+
allowedTags: ['br', 'sub', 'sup', 'b', 'i', 'em']
931931
});
932932
}
933933

Diff for: test/jasmine/tests/svg_text_utils_test.js

+8
Original file line numberDiff line numberDiff line change
@@ -504,5 +504,13 @@ describe('svg+text utils', function() {
504504
expect(fn(sIn, {allowedTags: ['sup']})).toBe('ThisIsDATA<sup>300</sup>');
505505
expect(fn(sIn, {allowedTags: ['br', 'sup']})).toBe('ThisIs<br>DATA<sup>300</sup>');
506506
});
507+
508+
it('should work in various cases w/ <b>, <i> and <em>', function() {
509+
var sIn = '<i>ThisIs</i><b>DATA</b><em>300</em>';
510+
511+
expect(fn(sIn)).toBe('ThisIsDATA300');
512+
expect(fn(sIn, {allowedTags: ['i', 'b', 'em']})).toBe('<i>ThisIs</i><b>DATA</b><em>300</em>');
513+
expect(fn(sIn, {len: 10, allowedTags: ['i', 'b', 'em']})).toBe('<i>ThisIs</i>D...');
514+
});
507515
});
508516
});

0 commit comments

Comments
 (0)