demo · v134 · navigation
Form Router
Three forms posting to the same handler. Without sourceElement you'd have to encode the form's intent in its action URL. With it, the handler reads off the actual <form> instance and routes by id, name, or data attribute.
waiting…
what the handler does
One navigation.addEventListener("navigate", ...) handler intercepts all four. From e.sourceElement it reads the form id and data-intent, then prevents the actual GET / POST and routes to in-app logic instead. Pre-sourceElement, you'd have to listen on each form's submit separately, or encode intent in the action URL.