fix: ensure tilelayer attribution with smart text is displayed as HMTL

This commit is contained in:
Yohan Boniface 2024-04-30 20:02:13 +02:00
parent 45812432fc
commit cdb46752a9
2 changed files with 14 additions and 4 deletions

View file

@ -73,7 +73,7 @@ L.DomUtil.add = (tagName, className, container, content) => {
if (content.nodeType && content.nodeType === 1) { if (content.nodeType && content.nodeType === 1) {
el.appendChild(content) el.appendChild(content)
} else { } else {
el.textContent = content el.innerHTML = content
} }
} }
return el return el

View file

@ -101,9 +101,9 @@ def test_map_should_display_custom_tilelayer(map, live_server, tilelayers, page)
url_pattern = re.compile( url_pattern = re.compile(
r"https://[abc]{1}.basemaps.cartocdn.com/rastertiles/voyager/\d+/\d+/\d+.png" r"https://[abc]{1}.basemaps.cartocdn.com/rastertiles/voyager/\d+/\d+/\d+.png"
) )
map.settings["properties"]["tilelayer"]["url_template"] = ( map.settings["properties"]["tilelayer"][
"https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png" "url_template"
) ] = "https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png"
map.settings["properties"]["tilelayersControl"] = True map.settings["properties"]["tilelayersControl"] = True
map.save() map.save()
page.goto(f"{live_server.url}{map.get_absolute_url()}") page.goto(f"{live_server.url}{map.get_absolute_url()}")
@ -112,3 +112,13 @@ def test_map_should_display_custom_tilelayer(map, live_server, tilelayers, page)
iconTiles = page.locator(".leaflet-iconLayers .leaflet-iconLayers-layer") iconTiles = page.locator(".leaflet-iconLayers .leaflet-iconLayers-layer")
# The second of the list should be the current # The second of the list should be the current
expect(iconTiles.nth(1)).to_have_css("background-image", url_pattern) expect(iconTiles.nth(1)).to_have_css("background-image", url_pattern)
def test_can_have_smart_text_in_attribution(tilelayer, map, live_server, page):
map.settings["properties"]["tilelayer"][
"attribution"
] = "© [[http://www.openstreetmap.org/copyright|OpenStreetMap]] contributors"
map.save()
page.goto(f"{live_server.url}{map.get_absolute_url()}")
expect(page.get_by_text("© OpenStreetMap contributors")).to_be_visible()
expect(page.get_by_role("link", name="OpenStreetMap")).to_be_visible()