[whatwg/dom] AbortSignal "signal abort" ordering (#493)

https://dom.spec.whatwg.org/#abortsignal-signal-abort

Currently the order is:

1. If signal’s aborted flag is set, then return.
1. Set signal’s aborted flag.
1. **For each algorithm in signal’s abort algorithms: run algorithm.**
1. Empty signal’s abort algorithms.
1. **Fire an event named abort at signal.**

If you want to create a new signal that copies another signal, you do something like this:

1. Let *originalSignal* be a signal we got from somewhere.
1. Let *signal* be a new `AbortSignal`.
1. [Add](https://dom.spec.whatwg.org/#abortsignal-add) the following steps to *originalSignal*:
    1. [Signal abort](https://dom.spec.whatwg.org/#abortsignal-signal-abort) on *signal*.
1. Return *signal*.

A side effect of this, is the "abort" event will despatch on signal before originalSignal.

```js
const controller = new AbortController();
const signal = controller.signal;
const request = new Request('.', {signal});
const requestClone = request.clone(); // this copies the signal as above.

request.signal.addEventListener('abort', () => console.log('original'));
requestClone.signal.addEventListener('abort', () => console.log('clone'));

controller.abort();
```

In the code above, "clone" is logged before "original". Is this a problem?

cc @domenic @annevk @wycats @mikewest @bterlson @jyasskin 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/493

Received on Monday, 14 August 2017 10:53:14 UTC