Is there a way to temporarily JS.set_attribute?

Is there a way to get LiveView to add an attribute and then automatically remove it after a timeout?

I want to do something like this:

<button phx-click={JS.set_attribute({"data-foo", true}, remove_after: 1500)}>Click Me</button>

I don’t think you can acheive this with JS commands alone right now. In cases like these I usually just JS.dispatch("some-event" and implement the rest in JavaScript.