diff options
Diffstat (limited to 'node_modules/swup/src/modules/getAnchorElement.ts')
| -rwxr-xr-x | node_modules/swup/src/modules/getAnchorElement.ts | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/node_modules/swup/src/modules/getAnchorElement.ts b/node_modules/swup/src/modules/getAnchorElement.ts deleted file mode 100755 index b25de2bc..00000000 --- a/node_modules/swup/src/modules/getAnchorElement.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { query } from '../utils.js'; - -/** - * Find the anchor element for a given hash. - * - * @param hash Hash with or without leading '#' - * @returns The element, if found, or null. - * - * @see https://html.spec.whatwg.org/#find-a-potential-indicated-element - */ -export const getAnchorElement = (hash?: string): Element | null => { - if (hash && hash.charAt(0) === '#') { - hash = hash.substring(1); - } - - if (!hash) { - return null; - } - - const decoded = decodeURIComponent(hash); - let element = - document.getElementById(hash) || - document.getElementById(decoded) || - query(`a[name='${CSS.escape(hash)}']`) || - query(`a[name='${CSS.escape(decoded)}']`); - - if (!element && hash === 'top') { - element = document.body; - } - - return element; -}; |
