@@ -34,35 +34,15 @@ window.addEventListener('load', function() {
3434
3535 if (!currentAnchor) return;
3636
37- const targetElement = document.getElementById(currentAnchor);
38-
39- const targetByName = targetElement || document.querySelector(`[name="${currentAnchor}"]`);
40-
41- let targetH2;
42-
43- if (targetByName && targetByName.tagName === 'H2') {
44- targetH2 = targetByName;
45- } else if (targetByName) {
46- const h2InTarget = targetByName.querySelector('h2');
47- if (h2InTarget) {
48- targetH2 = h2InTarget;
49- }
50- } else {
51- const allH2s = document.querySelectorAll('h2');
52- for (const h2 of allH2s) {
53- if (h2.id === currentAnchor || h2.getAttribute('name') === currentAnchor) {
54- targetH2 = h2;
55- break;
56- }
57- }
58- }
37+ const allMatching = document.querySelectorAll(`h2#${currentAnchor}`);
38+ const targetH2 = allMatching[allMatching.length - 1];
5939
6040 if (targetH2) {
61- const parentElement = targetH2.parentElement;
41+ const parentElement: any = targetH2.parentElement;
6242
6343 if (parentElement) {
6444 const originalBorder = parentElement.style.border;
65- const originalBorderRadius = parentElement.style.borderRadius ;
45+ const originalBackground = parentElement.style.background ;
6646
6747 let blinkCount = 0;
6848 const maxBlinks = 5;
@@ -71,7 +51,7 @@ window.addEventListener('load', function() {
7151 function toggleBorder() {
7252 if (blinkCount >= maxBlinks * 2) {
7353 parentElement.style.border = originalBorder;
74- parentElement.style.back = originalBorder ;
54+ parentElement.style.background = originalBackground ;
7555 return;
7656 }
7757
@@ -80,7 +60,7 @@ window.addEventListener('load', function() {
8060 parentElement.style.background = 'white';
8161 } else {
8262 parentElement.style.border = originalBorder;
83- parentElement.style.background = originalBorder ;
63+ parentElement.style.background = originalBackground ;
8464 }
8565
8666 blinkCount++;
0 commit comments