Let’s understand a bit what is going on.
When you declare an inline event handler, that code will only run when that handler is invoked. As far as I know, it will always run asynchronously on a different JavaScript stack than the one rendering to the HTML. So, as far as I can see, this code is completely isolated from the Elm runtime, the same way that ports invoked code is (I’m not sure about custom elements as they are new for me).
For example, see https://ellie-app.com/9nYTC2635a1/0 If you click the button, an exception is thrown in JS land (it shows in ellie because it has an onerror handler attached). If you click it again, the alert shows again, so the world didn’t break, both Elm and JavaScript continue to work fine.
As far as I can see, this approach seems safe to use, comparing with the other approaches of running JS code, so I wouldn’t consider these programs any unsafer or different that a program that sends a message through a port asynchronously and then in JS an exception is thrown.
If I’m missing something please chime in, I’d love to be corrected!