Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Initial load error when location hash isn't a selector #516

Closed
aubergene opened this issue Nov 7, 2018 · 2 comments
Closed

Initial load error when location hash isn't a selector #516

aubergene opened this issue Nov 7, 2018 · 2 comments

Comments

@aubergene
Copy link
Contributor

I'm using the location hash to store state, in order to make it shareable.

I get the following error when loading as Sapper is trying to find an element on the page with the id of the hash so that it can scroll to it.

Demo: https://sapper.svelte.technology/guide#asdasd&&

client.354c98f5.js:1 Uncaught (in promise) DOMException: Failed to execute 'querySelector' on 'Document': '#asdasd&&' is not a valid selector.
    at X (https://sapper.svelte.technology/client/client.354c98f5.js:1:7630)
    at J.n.then (https://sapper.svelte.technology/client/client.354c98f5.js:1:7116)
@lukeed
Copy link
Member

lukeed commented Nov 7, 2018

Hey~!

That error comes from the browser because #asdasd&& is not a valid selector.

The && is causing the error for you. See here for more info

Hope that helps 👍

@lukeed lukeed closed this as completed Nov 7, 2018
@thgh
Copy link
Contributor

thgh commented Nov 8, 2018

If querySelector would be replaced here by getElementById there would be no error.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants