Cocktail icon indicating copy to clipboard operation
Cocktail copied to clipboard

document.onload doesn't trigger with browser cache enabled

Open clemos opened this issue 12 years ago • 3 comments

When browser cache is enabled (and thus, the loaded .html document is loaded from cache), Browser.document.addEventListener('load',foo) never triggers foo...

clemos avatar Nov 28 '13 19:11 clemos

Ok, the load event is dispatched from here : https://github.com/silexlabs/Cocktail/blob/master/cocktail/core/html/HTMLDocument.hx#LC591

Do you add the event listener before setting the document content ?

yanhick avatar Nov 29 '13 09:11 yanhick

Yes, I'm still using Cocktail.boot( url ).

The problem is, before that, Browser.window is null so I just can't add the event listener (It was Browser.window and not Browser.document BTW)

It seems actually impossible to access either window or document before loading the file, so I guess if the file is loaded synchronously, the 'load' event cannot be used...

I guess both window and document should be created in the constructor, and never reinitialized...

What do you think ?

clemos avatar Nov 29 '13 10:11 clemos

I couldn't see what's wrong by looking at cocktail's code. The samples also add the onload callback after calling "boot". I remember I fixed bugs similar to yours months ago, but I probably didn't fix everything.

If you can share a sample reproducing the bug, I can take a look this weekend

yanhick avatar Nov 29 '13 12:11 yanhick