I'm implementing social auth. When the user clicks on a button, I send a command so I can call window.open().
Looking at this call-stack, we can see that the port handler is called in the next event loop:

Since window.open is not being called within the click event lifecycle, browsers like safari do not allow for the popup to show up.
What is your approach?
It's not super pretty, but you can do something like
a
[ Html.Attributes.attribute "onClick" "window.open(this.href, this.target, 'width=800,height=600'); return false;" ]
[ text "Click me" ]
It's an underhanded way to handle this, and not 100% strictly guaranteed to continue working in future elm releases but I've done this more than once in a pinch:
https://medium.com/@prozacchiwawa/the-i-m-stupid-elm-language-nugget-7-8d3efd525e3e
A property getter on the DOM node type can be triggered by a json decoder during event handling. You can run whatever code you want as a side effect of accessing it. The object being accessed by the json decoder is the real event object on the event handler stack as things are now.
来源:https://stackoverflow.com/questions/43295502/calling-window-open-through-port