Closed pYr0x closed 7 years ago
What should can-zone do with addEventListener? Wait for the event to occur?
Not generically. Perhaps some plugins can set this up, but hard to know which specific events should be waited on, and which shouldn't.
i dont know what we can do.
if you remove the addEventListener
on the steal-css
plugin and use the polling onloadCss
can-zone will not fail.
maybe register event listener through a proxy on can-zone
I don't understand what you mean when you say can-zone will fail? Do you mean it will throw an error?
no, it will not resolve. while debugging, javascript will never reached this line https://github.com/donejs/autorender/blob/master/src/template.txt#L136 or that line https://github.com/donejs/autorender/blob/master/src/template.txt#L102
Looked more into this. What's happening is that a setTimeout is created and then later gets cleared. Because clearTimeout is inside of the event handler, it is not deducted from the Zone's counter.
The fix is to make sure that event handlers are run within the Zone. It won't increment the counter, but it will just make sure that it is Zone wrapped. We do this already for MutationObserver. https://github.com/canjs/can-zone/blob/master/lib/tasks.js#L182
but that mean, that steal-css will depend on can-zone?
how can we wrap addEventListener
?
steal-css doesn't depend on can-zone, done-autorender does. I'm working on a fix for this.
This is fixed in can-zone 0.6.3, tested your app and its working now @pYr0x
there is a problem with
done-autorender
. the problem seems to be insteal-css
where we usingaddEventListener
to know when the css is injected. https://github.com/stealjs/steal-css/blob/master/css.js#L110-L112