Javascript template literals (backticks) not working in Internet Explorer
A simple Marker with a simple tooltip (same problem for popup) avoid Internet Explorer to render the map:
import folium
m = folium.Map(
location=[45.372, -121.6972],
tiles='Mapbox Bright')
folium.Marker([45.3288, -121.6625], tooltip='Tooltip').add_to(m)
m.save('tooltip_issue.html')
The map doesn't show up in Internet Explorer (Version 11).
This issue seems to be related with the backticks contained in the generated html for the Popup or Tootip elements: replacing backticks with normal quotes solved the problem.
Backticks are used in Popup class template as well as in Tooltip class template.
Do you see any concern replacing then with simple quotes ?
Sorry but folium and leaflet itself have some IE incompatibilities and there is no promise to work on that browser. PRs are welcomed though.
We changed to backticks to be more robust to certain characters in user input. You can see the related PRs and issues for what happened. I think we won’t go back to simple quotes unless someone has a convincing plan for an alternative.
I think at the time we looked up that all modern browsers support backticks.
@Conengmo ok, seems related to GH-962 and GH-955 then.
I understand that these PR have solved the problem of single quotes being part of a legend or tooltip, but are there any other advantages ? Replacing the single quotes with its escape sequence in Javascript wouldn't have solved the problem as well ? (and would allow to load the generated map into IE, even if it is an old browser).
For example, in the template of Tooltip class:
{{ this._parent.get_name() }}.bindTooltip(
'<div{% if this.style %} style="{{ this.style }}"{% endif %}>'
+ '{{ this.text|replace("'", "'") }}' + '</div>',
{{ this.options }}
);
What if this.text contains html with single quotes, for example:
<div style='color:red;'>bla</div>
If you were to change those quotes into ' would the html still work?
Or suppose someone passes this.text with Javascript in it:
<script>document.write('hi there');</script>
I'm pretty sure replacing the single quotes with ' will break this.
So the problem is that if we want to escape them sometimes they should become ' and sometimes \' depending on the context.