Open bakulf opened 1 month ago
What if you end up calling set()
multiple times? I wonder if this relates to #230 somehow.
Naively:
set()
Not sure if that's ideal though. I feel like the order between events and promises is still something we haven't really settled in general. cc @jakearchibald @domenic
https://w3ctag.github.io/design-principles/#promises-and-events
- It now queues a task to a) resolve the promise and b) fire a change event.
- As there is no JS on the stack, the event callbacks run before the promise callbacks?
That's true for the first event callback, since events are dispatched synchronously. But since there's a microtask checkpoint after invoking a callback, the promise reaction callbacks are called after the first listener, but before the second (and third etc etc).
If you fire the event before resolving the promise, all event callbacks are called consistently before any of the promise reaction callbacks. That's why it's important to do events first.
What's the correct sequence of console log messages? The spec needs to be clarified. On Chrome, sometimes you see CHANGE+RESOLVED, and sometimes RESOLVED+CHANGE, which is confusing for developers.
In Firefox, the promise is always resolved before dispatching the
CookieChangeEvent
.