Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:visible components throw error #110

Closed
ThatJoeMoore opened this issue Apr 19, 2021 · 0 comments · Fixed by #112
Closed

:visible components throw error #110

ThatJoeMoore opened this issue Apr 19, 2021 · 0 comments · Fixed by #112

Comments

@ThatJoeMoore
Copy link

Reproduction

Modify /examples/kitchen-sink/astro/pages/index.astro to add :visible to any component.

When the page loads, the following error will occur:

Uncaught TypeError: document.querySelector(...).item is not a function

Issue

Here's the generated JS that's breaking:

Array.from(document.querySelector('[data-astro-id="2245226923414180"]').item(0).children).forEach(child => o.observe(child))

It looks like #72 changed how the IntersectionObserver gets set up to support having multiple components:

https://github.com/snowpackjs/astro/blob/188541260acad5ccd6699f0a21d6da600860e74c/src/frontend/render/renderer.ts#L58

It's now expecting root to be a call to querySelectorAll instead of querySelector, but it's still querySelector:

https://github.com/snowpackjs/astro/blob/188541260acad5ccd6699f0a21d6da600860e74c/src/frontend/render/renderer.ts#L23

As far as I can tell, all of the renderers are expecting root to be a call to querySelector, and the IntersectionObserver bit is the only part of the generated code that expects querySelectorAll. It seems like reverting the change to this line would fix :visible, but as I don't really know the context of the previous change, I don't know what else that might break.

@matthewp matthewp added the bug label Apr 19, 2021
@natemoo-re natemoo-re linked a pull request Apr 19, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants