yui / yui3

A library for building richly interactive web applications.
http://yuilibrary.com/
Other
4.13k stars 1.29k forks source link

[bz 6753689] Window onload blocks router event #1713

Open triptych opened 10 years ago

triptych commented 10 years ago

Original description: We encountered an issue when one image of the page could not be successfully loaded and this image blocks all pjax links from the page. This is because route waits for onload to start the routing: yuilibrary.com/yui/docs/api/files/app_js_router.js.html#l207

I suggest a threshold to fallback to normal page refresh if it takes too long for the onload so it won't block page navigation.

An additional comment:

It would also be helpful to get an explanation on why it waits for load to begin with.

rgrove commented 10 years ago

It would also be helpful to get an explanation on why it waits for load to begin with.

There's a comment explaining this at the exact line of code reported in the bug: https://github.com/yui/yui3/blob/master/src/app/js/router.js#L207-L215

Chrome fires an empty and useless popstate event shortly after onload, so we have to wait for that and ignore it to avoid duplicate route dispatches. This Chromium issue tracks the bug (which has apparently finally been fixed and should hit stable in Chrome 34): https://code.google.com/p/chromium/issues/detail?id=63040

Once the Chrome fix hits stable, we should retest all browsers and remove this workaround as long as none of them exhibit the initial popstate bug.

gzip commented 10 years ago

Any update here?

rgrove commented 10 years ago

Need someone to test all browsers with the workaround removed and verify that it's no longer necessary. I don't have time to tackle this right now, but if someone else does, that'd be great.

okuryu commented 10 years ago

I'll try to check.

gzip commented 10 years ago

Note that this presents a similar issue in that clicks do nothing prior to onload: http://yuilibrary.com/yui/docs/api/files/app_js_router.js.html#l791