Commit dfcf0d5
committed
The `afterRender` hooks currently run after `ApplicationRef.tick` but
also run after any call to `ChangeDetectorRef.detectChanges`. This is
problematic because code which uses `afterRender` cannot expect the
component it's registered from to be rendered when the callback
executes. If there is a call to `ChangeDetectorRef.detectChanges` before
the global change detection, that will cause the hooks to run earlier
than expected.
This behavior is somewhat of a blocker for the zoneless project. There
is plenty of application code that do things like `setTimeout(() =>
doSomethingThatExpectsComponentToBeRendered())`, `NgZone.onStable(() =>
...)` or `ApplicationRef.onStable...`. `ApplicationRef.onStable` is a
should likely work similarly, but all of these are really wanting an API
that is `afterRender` with the requirement that the hook runs after the
global render, not an individual CDRef instance.
This change updates the `afterRender` hooks to only run when
`ApplicationRef.tick` happens.
fixes angular#52429
fixes angular#53232
PR Close angular#52455
1 parent a5a9b40 commit dfcf0d5
File tree
10 files changed
+233
-218
lines changed- goldens/public-api/core
- packages/core
- src
- application
- defer
- render3
- instructions
- testing/src
- test/acceptance
10 files changed
+233
-218
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
122 | 120 | | |
123 | 121 | | |
124 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
323 | 324 | | |
324 | 325 | | |
325 | 326 | | |
| 327 | + | |
326 | 328 | | |
327 | 329 | | |
328 | 330 | | |
| |||
555 | 557 | | |
556 | 558 | | |
557 | 559 | | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
558 | 572 | | |
559 | 573 | | |
560 | 574 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | 86 | | |
90 | 87 | | |
91 | 88 | | |
| |||
120 | 117 | | |
121 | 118 | | |
122 | 119 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | 120 | | |
127 | 121 | | |
128 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | 352 | | |
360 | 353 | | |
361 | 354 | | |
| |||
367 | 360 | | |
368 | 361 | | |
369 | 362 | | |
370 | | - | |
| 363 | + | |
371 | 364 | | |
372 | | - | |
| 365 | + | |
373 | 366 | | |
374 | 367 | | |
375 | 368 | | |
| |||
392 | 385 | | |
393 | 386 | | |
394 | 387 | | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | 388 | | |
406 | 389 | | |
407 | 390 | | |
| |||
414 | 397 | | |
415 | 398 | | |
416 | 399 | | |
417 | | - | |
| 400 | + | |
| 401 | + | |
418 | 402 | | |
419 | 403 | | |
420 | 404 | | |
| 405 | + | |
421 | 406 | | |
422 | 407 | | |
423 | 408 | | |
| |||
427 | 412 | | |
428 | 413 | | |
429 | 414 | | |
| 415 | + | |
430 | 416 | | |
431 | 417 | | |
432 | 418 | | |
| |||
442 | 428 | | |
443 | 429 | | |
444 | 430 | | |
445 | | - | |
446 | | - | |
447 | 431 | | |
448 | 432 | | |
449 | 433 | | |
450 | 434 | | |
451 | 435 | | |
452 | 436 | | |
453 | 437 | | |
454 | | - | |
455 | | - | |
| 438 | + | |
456 | 439 | | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
479 | 448 | | |
| 449 | + | |
| 450 | + | |
480 | 451 | | |
481 | 452 | | |
482 | 453 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | | - | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
| |||
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | 57 | | |
63 | 58 | | |
64 | 59 | | |
| |||
0 commit comments