QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.82k stars 1.3k forks source link

[BUG] Qwik-Partytown demo is broken #415

Closed mhevery closed 2 years ago

mhevery commented 2 years ago

https://discord.com/channels/842438759945601056/937421500879867994/967628243962310748

Has anybody gotten the partytown starter to work properly? While debugging I've run into multiple odd issues regarding event handling (onDocument event handlers don't work, onWindow handler for a custom event doesn't work, etc)

Reproduction steps:

From what I could test, it actually seems like only very specific events are listened for at the window/document level, and handlers for custom events are not supported. For example, window:scroll cannot have a handler registered. Also, the onDocumentEventName$ syntax appears to be broken. The attribute applied to the element is on:documenteventname, which doesn't work. Changing the attribute name to on-document:eventname causes the handler to work - as long as eventname is scroll or some other standard event.

Further testing suggests that custom events such as element.dispatchEvent(new Event('foo')) are not supported via the <div onFoo$={...} /> syntax - is there a correct way to use custom events? It seems like the partytown starter not only doesn't work, it can't work.

jcuffe commented 2 years ago

Thank you for creating this issue! I think when I posted this in Discord I was reporting a few separate issues:

  1. The partytown starter does not include the packages and scripts needed to successfully run partytown
  2. The jsx onDocumentEventName$ syntax is not being transformed correctly, resulting in DOM nodes with on:documenteventname attributes (should be on-document:eventname)
  3. on-window and on-document event listeners only fire handlers for specific arbitrary events, so the expensiveComputationDone event fired by the partytown starter can't be listened for using Qwik syntax.

They just all happened to come up in the context of getting the starter to run 😅 Love the idea, by the way!

naveedahmed1 commented 2 years ago

Adding this for reference:

partytown

With console log the environments[msgValue] undefined

partytown1

manucorporat commented 2 years ago

Fixed!