Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The use of specific quotation marks in the tooltip.formatter() affect parsing to the DOM element. #17627

Closed
magdalena-gut opened this issue Aug 19, 2022 · 4 comments · Fixed by #17634

Comments

@magdalena-gut
Copy link
Member

magdalena-gut commented Aug 19, 2022

Behaviour

Using the following code in the tooltip.formatter() doesn't change the circle colour as expected.
return '<span style="color: " + this.series.color + ";"">\u25CF</span>;

Received DOM element:
<tspan style="color: #7cb5ec;">●</tspan>

Demo:
https://jsfiddle.net/BlackLabel/51ho6by0/

Workaround:

Works correctly with proper quotation marks configuration:
return '<span style="color: ' + this.series.color + ';">\u25CF</span>';

Received DOM element:
<tspan style="color: rgb(124, 181, 236); fill: rgb(124, 181, 236);">●</tspan>

Demo:
https://jsfiddle.net/BlackLabel/Lrv5p9o0/

Last working version

In the last working version (9.3.3), color property was parsed to fill independently of quotation marks.

Demo:
https://jsfiddle.net/BlackLabel/t1e84sho/

Caused by the following PR:

https://github.com/highcharts/highcharts/pull/16871/files

@magdalena-gut
Copy link
Member Author

@TorsteinHonsi should we treat it as a bug?

@TorsteinHonsi
Copy link
Collaborator

@magdalena-gut, yes, I think it's a bug. It basically fails to parse style attributes with single quotes.

Simplified demo, and inspiration for integration test: https://jsfiddle.net/highcharts/dmb7t143/

The problem is this line:

https://github.com/highcharts/highcharts/pull/16871/files#diff-bf1c4abb15f5c305c4275368881a707d5667a2c0a45623950a87eea9b2a0e7bbR527

By taking the possibility of single quotes into consideration, it should work as expected:

.replace(/ style=(["'])/g, ' data-style=$1');

@magdalena-gut
Copy link
Member Author

@TorsteinHonsi thanks for clarifying!

@raf18seb
Copy link
Contributor

raf18seb commented Aug 22, 2022

I was about to create a similar ticket (injection of a custom CSS attribute, demo: https://jsfiddle.net/BlackLabel/h063ndty/), but it will also be solved by this ticket here so I'm just leaving a demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants