Keep relative anchors in inherited docs that still point to an existing element ID.

This commit is contained in:
Samuel Guerra 2024-02-09 20:17:31 -03:00
parent 3b355f1838
commit 1c478bca6c
2 changed files with 5 additions and 6 deletions

View File

@ -1,9 +1,5 @@
# Documentation
* Check if anchor href in `insertedDocs` is just an anchor for an ID that exists in the current document.
- If not, patch to go to the page + #anchor (already implemented).
- If ID is found, do not patch.
* Relative links in "Properties from" imported section are not patched.
- See `zero_ui/button/struct.Button.html` the `child_insert` link.

View File

@ -383,8 +383,11 @@
insertedDocs.forEach(function (e) {
e.el.querySelectorAll('a').forEach(function (a) {
let url = new URL(a.getAttribute('href'), e.url);
a.setAttribute('href', url.href);
let href_str = a.getAttribute('href');
if (!href_str.startsWith('#') || this.document.getElementById(href_str.slice(1)) === null) {
let url = new URL(href_str, e.url);
a.setAttribute('href', url.href);
}
});
});
}