Skip to content

Commit f033aa1

Browse files
committed
Make djdt-{{ panel.panel_id }} a DOM ID instead of DOM class
This string represents a unique element on the page, therefore it should be a DOM ID. No two panels should have the same panel_id. This makes it a tiny bit simpler to query for a specific Django Debug Toolbar button when using automated tools.
1 parent 7ecd3c1 commit f033aa1

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

debug_toolbar/templates/debug_toolbar/includes/panel_button.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% load i18n %}
22

3-
<li class="djDebugPanelButton djdt-{{ panel.panel_id }}">
3+
<li id="djdt-{{ panel.panel_id }}" class="djDebugPanelButton">
44
<input type="checkbox" data-cookie="djdt{{ panel.panel_id }}" {% if panel.enabled %}checked title="{% trans "Disable for next and successive requests" %}"{% else %}title="{% trans "Enable for next and successive requests" %}"{% endif %}>
55
{% if panel.has_content and panel.enabled %}
66
<a href="#" title="{{ panel.title }}" class="{{ panel.panel_id }}">

tests/panels/test_custom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_escapes_panel_title(self):
1919
self.assertContains(
2020
response,
2121
"""
22-
<li class="djDebugPanelButton djdt-CustomPanel">
22+
<li id="djdt-CustomPanel" class="djDebugPanelButton">
2323
<input type="checkbox" checked title="Disable for next and successive requests" data-cookie="djdtCustomPanel">
2424
<a class="CustomPanel" href="#" title="Title with special chars &amp;&quot;&#39;&lt;&gt;">
2525
Title with special chars &amp;&quot;&#39;&lt;&gt;

tests/panels/test_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_panel_title(self):
1212
self.assertContains(
1313
response,
1414
"""
15-
<li class="djDebugPanelButton djdt-SettingsPanel">
15+
<li id="djdt-SettingsPanel" class="djDebugPanelButton">
1616
<input type="checkbox" checked title="Disable for next and successive requests" data-cookie="djdtSettingsPanel">
1717
<a class="SettingsPanel" href="#" title="Settings from None">Settings</a>
1818
</li>

0 commit comments

Comments
 (0)