Skip to content

Commit fdfc3b3

Browse files
authored
Snapshot internal observers before Subscriber iteration (#214)
1 parent 512f172 commit fdfc3b3

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

spec.bs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,13 @@ The <dfn attribute for=Subscriber><code>signal</code></dfn> getter steps are to
205205
1. If [=this=]'s [=relevant global object=] is a {{Window}} object, and its [=associated
206206
Document=] is not [=Document/fully active=], then return.
207207

208-
1. [=set/For each=] |observer| of [=this=]'s [=Subscriber/internal observers=]:
208+
1. Let |internal observers copy| be a copy of [=this=]'s [=Subscriber/internal observers=].
209+
210+
Note: We make a copy of the [=Subscriber/internal observers=] list and iterate over it so
211+
that if one of the [=internal observer=]'s [=internal observer/next steps=] below causes
212+
another subscription, the observer list does not mutate during iteration.
213+
214+
1. [=set/For each=] |observer| of |internal observers copy|:
209215

210216
1. Run |observer|'s [=internal observer/next steps=] given |value|.
211217

@@ -234,7 +240,9 @@ The <dfn attribute for=Subscriber><code>signal</code></dfn> getter steps are to
234240

235241
1. [=close a subscription|Close=] [=this=].
236242

237-
1. [=set/For each=] |observer| of [=this=]'s [=Subscriber/internal observers=]:
243+
1. Let |internal observers copy| be a copy of [=this=]'s [=Subscriber/internal observers=].
244+
245+
1. [=set/For each=] |observer| of |internal observers copy|:
238246

239247
1. Run |observer|'s [=internal observer/error steps=] given |error|.
240248

@@ -253,7 +261,9 @@ The <dfn attribute for=Subscriber><code>signal</code></dfn> getter steps are to
253261

254262
1. [=close a subscription|Close=] [=this=].
255263

256-
1. [=set/For each=] |observer| of [=this=]'s [=Subscriber/internal observers=]:
264+
1. Let |internal observers copy| be a copy of [=this=]'s [=Subscriber/internal observers=].
265+
266+
1. [=set/For each=] |observer| of |internal observers copy|:
257267

258268
1. Run |observer|'s [=internal observer/complete steps=].
259269

0 commit comments

Comments
 (0)