QwikLoader initialized more than once
Basic Info
- Qwik Version 0.0.113
- macOS Monterey (Chrome v.105)
Which component is affected?
Qwik Runtime
Description of the Issue
It seems like the qwikLoader gets initialized multiple times, thus accumulating eventListeners and causing unwanted behaviours.
I have a project in which I am using different Qwik fragments loaded dynamically, and there I can see that each time a new fragment is loaded I get extra duplicate events from Qwik.
I don't think this is the expected behaviour since it makes working with isolated Qwik fragments quite problematic.
I think the bug has been introduced in PR #1212, as you can see from these changes:

As you can see in the changes before there was a check, making sure that the qR field was falsy, and if it were then it would be initialized to 1 (thus preventing additional initializations of the qwikLoader for that specific document), now this qR field is only getting checked and not initialized.
By a quick regex search I also think that this qR field is not being initialized anywhere else:

From the PR I can also see that the eventListeners are added to the document instead of adding them to doc is that correct? shouldn't they be added to doc?