peckadesign / pd-naja

1 stars 0 forks source link

fix: Correctly dispatching the `load` event on `popstate` after snippets are restored by Naja #22

Closed zipper closed 4 months ago

zipper commented 4 months ago

When popstate occurs and snippets are loaded from the snippet cache, we need to manually dispatch the load event. This used to be dispatched immediately after popstate, which resulted in the load event being dispatched before the snippets were actually restored from the cache by Naja. Now we schedule the dispatch after the snippets have been restored using the setTimeout method.