Inside buildState event handler, there is now no way to distinguish between new state being pushed, or initial state being replaced. You might distinguish initial state replace, if the window.history.state === null, but that doesn't always work.
Let's say you have a page and click an Naja link there. Initial state is being replaced by Naja state, ajax request is made and a new Naja state is pushed. Then if you refresh the page, there already is window.history.state with some Naja properties. When another Naja link is clicked, replaceInitialState is called, leading to buildState handler. There I have no idea if I'm pushing new state or replacing current state. But it does matter for me, because if latter, I need to preserve some options from window.history.state. At the same time, those options must not be preserved if new state is being pushed (because they obviously belong to now previous state).
For some objective reasons I can't build those options again inside buildState handler when replaceInitialState is being called. It would be very helpful, if I can tell, what led to buildState handler - if it was replaceInitialState or pushNewState call.
Inside
buildState
event handler, there is now no way to distinguish between new state being pushed, or initial state being replaced. You might distinguish initial state replace, if thewindow.history.state === null
, but that doesn't always work.Let's say you have a page and click an Naja link there. Initial state is being replaced by Naja state, ajax request is made and a new Naja state is pushed. Then if you refresh the page, there already is
window.history.state
with some Naja properties. When another Naja link is clicked,replaceInitialState
is called, leading tobuildState
handler. There I have no idea if I'm pushing new state or replacing current state. But it does matter for me, because if latter, I need to preserve some options fromwindow.history.state
. At the same time, those options must not be preserved if new state is being pushed (because they obviously belong to now previous state).For some objective reasons I can't build those options again inside
buildState
handler whenreplaceInitialState
is being called. It would be very helpful, if I can tell, what led tobuildState
handler - if it wasreplaceInitialState
orpushNewState
call.