vojtech-dobes / history.nette.ajax.js

Adds History API support to nette.ajax.js addon!
30 stars 27 forks source link

initialPop detection in Safari fails after refresh #29

Closed zipper closed 8 years ago

zipper commented 9 years ago

As known, Safari triggers popstate event on window after page has been loaded. Current detection of initialPop (popstate not caused by history manipulation - back/forward button) works fine only for the first page load and traversing using links. But when the current page is refreshed, the initialPop is not recognized and its value here is false.

Because of that, updateSnippets function is called (via handleUI from history extension) after refresh and some JS could break as the DOM changes (attached events are lost for instance). This happens only in Safari (specifically tested Safari 8.0.4 on OS X Yosemite, but the bug could be reproduced on El Capitan aswell) as no other browser triggers popstate on page load.

JanMikes commented 9 years ago

+1 I have same issue and it can be pretty frustrating sometimes since i use safari as my main browser, sometimes it is hard to debug because i usually forget about this issue and wonder what is wrong etc. when dynamic elements are used inside of snippets and those are removed instantly, because snippets redraws instantly after page refresh.