| 4912 | } |
| 4913 | |
| 4914 | function transition_end() { |
| 4915 | var on0, on1, that = this, id = that._id, size = that.size(); |
| 4916 | return new Promise(function(resolve, reject) { |
| 4917 | var cancel = {value: reject}, |
| 4918 | end = {value: function() { if (--size === 0) resolve(); }}; |
| 4919 | |
| 4920 | that.each(function() { |
| 4921 | var schedule = set(this, id), |
| 4922 | on = schedule.on; |
| 4923 | |
| 4924 | // If this node shared a dispatch with the previous node, |
| 4925 | // just assign the updated shared dispatch and we’re done! |
| 4926 | // Otherwise, copy-on-write. |
| 4927 | if (on !== on0) { |
| 4928 | on1 = (on0 = on).copy(); |
| 4929 | on1._.cancel.push(cancel); |
| 4930 | on1._.interrupt.push(cancel); |
| 4931 | on1._.end.push(end); |
| 4932 | } |
| 4933 | |
| 4934 | schedule.on = on1; |
| 4935 | }); |
| 4936 | |
| 4937 | // The selection was empty, resolve end immediately |
| 4938 | if (size === 0) resolve(); |
| 4939 | }); |
| 4940 | } |
| 4941 | |
| 4942 | var id = 0; |
| 4943 | |