v135 · miscellaneous

NavigateEvent sourceElement

When a navigation is initiated by an Element (i.e., a link click or a form submission), the sourceElement property on the NavigateEvent will be the initiating element.

concepts

  1. NavigateEvent.sourceElement

    Single-link demo: click and watch the property report the originating <a>.

  2. Form vs link source

    The View-Transitions use case: a real form alongside a list of links; sourceElement disambiguates which submit button or anchor fired the nav.

  3. Navigation source detective

    Five different initiators on one page — link, button, form, hash fragment, programmatic navigation.navigate(). The event log reports sourceElement, navigationType, and target URL for each.

  4. Navigation Source Logger

    Every navigation is intercepted by the Navigation API and its sourceElement logged to a table — tag name, id/name, navigation type, and whether it can be intercepted. Includes link clicks, form submits, JS navigation.navigate(), and synthetic link.click() calls.

why it shipped

This was requested by web developers. It provides an easy way to disambiguate which of several possible elements initiated a navigation.

references