(container, targetId)
| 49 | } |
| 50 | |
| 51 | function getTargetElement(container, targetId) { |
| 52 | const decodedId = decodeURIComponent(targetId || ""); |
| 53 | if (!decodedId) return null; |
| 54 | |
| 55 | const elements = container.querySelectorAll("[id], [name]"); |
| 56 | return ( |
| 57 | Array.from(elements).find( |
| 58 | (element) => |
| 59 | element.getAttribute("id") === decodedId || |
| 60 | element.getAttribute("name") === decodedId, |
| 61 | ) || null |
| 62 | ); |
| 63 | } |
| 64 | |
| 65 | function getOffsetTopWithinContainer(target, container) { |
| 66 | let top = 0; |