I have a Browser.application setup with the usual code around UrlRequests: if there is an Internal URL request, the URL in the browser should change without executing a page load.
It works as expected, except with links that are part of the contents of a custom element I’m using. That custom element simply allows me to embed raw html (because it’s full of errors and parsing it presents some issues).
It’s because elm/virtual-dom adds a click listener to every <a> element that it creates. That click listener is what results in onUrlRequest rather than a browser standard page load.
You can see how that _VirtualDom_divertHrefToApp function is set up here:
If elm/virtual-dom instead had listened for the click event on the whole document and checked if the click came from inside an <a> element, your case should have just worked. Not sure if that approach could have downsides. But patching the JS output to try to achieve this might be a workaround (unless someone comes up with some easier idea).
Edit: It might be easier to use html-parser 2.4.0 to parse the raw HTML into elm/virtual-dom nodes and render those. Then you get the link click listeners for free.