Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/templates/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ <h3 class="sidebar-card-title">📊 Portfolio Diversity</h3>
</div>
</footer>

<button id="scroll-top-btn" aria-label="Back to top" title="Back to top">↑</button>
{% include 'partials/scroll_top_btn.html' %}

<script>
Expand Down
32 changes: 32 additions & 0 deletions tests/test_html_template_duplicate_ids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# tests/test_html_template_duplicate_ids.py
# Regression test for issue #1878: element IDs must be unique within a template.
# Duplicate IDs are invalid HTML and break getElementById() lookups (dead UI).

import glob
import os
import re

ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATES_DIR = os.path.join(ROOT, "src", "templates")

ID_RE = re.compile(r'\bid="([^"]+)"')


def _template_files():
return sorted(glob.glob(os.path.join(TEMPLATES_DIR, "**", "*.html"), recursive=True))


def test_no_duplicate_ids_in_templates():
"""Each template may define an element ID only once."""
dupes = {}
for path in _template_files():
with open(path, encoding="utf-8") as f:
content = f.read()
ids = ID_RE.findall(content)
duplicated = {i for i in ids if ids.count(i) > 1}
if duplicated:
dupes[os.path.relpath(path, TEMPLATES_DIR)] = sorted(duplicated)
assert not dupes, (
"duplicate element IDs found in templates (issue #1878): "
f"{dupes}"
)
Loading