mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #36537 -- Ensured unique HTML IDs for geometry widget option scripts in the admin.
This work amends the code from f2f6046c0f
where multiple geometry widgets rendered `<script>` elements in the
admin with the same HTML `id`, resulting in invalid HTML and fragile
JavaScript selectors. Refs #25706.
This change uses the widget's textarea ID to generate a unique `id` for
each JSON options `<script>`, ensuring valid and robust markup.
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
This commit is contained in:
committed by
nessita
parent
2013092b69
commit
0a262c8407
@@ -214,7 +214,7 @@ class GeometryFieldTest(SimpleTestCase):
|
||||
"id": "id_p",
|
||||
"geom_name": "Point",
|
||||
}
|
||||
expected = json_script(attrs, "mapwidget-options")
|
||||
expected = json_script(attrs, "id_p_mapwidget_options")
|
||||
self.assertInHTML(expected, rendered)
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ class SpecializedFieldTest(SimpleTestCase):
|
||||
"id": map_field.id_for_label,
|
||||
"geom_name": geom_name,
|
||||
}
|
||||
expected = json_script(attrs, "mapwidget-options")
|
||||
expected = json_script(attrs, f"{map_field.id_for_label}_mapwidget_options")
|
||||
self.assertInHTML(expected, rendered)
|
||||
self.assertIn("gis/js/OLMapWidget.js", str(form_instance.media))
|
||||
|
||||
@@ -475,7 +475,7 @@ class OSMWidgetTest(SimpleTestCase):
|
||||
"id": "id_p",
|
||||
"geom_name": "Point",
|
||||
}
|
||||
expected = json_script(attrs, "mapwidget-options")
|
||||
expected = json_script(attrs, "id_p_mapwidget_options")
|
||||
self.assertInHTML(expected, rendered)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user