Commit 447db31
authored
Chrome 134+ emits a deprecation warning for window `unload` listeners.
The connect handler in state.js registered three lifecycle listeners
(pagehide, beforeunload, unload), with `unload` and `beforeunload` both
calling the same disconnect routine.
- Remove the deprecated `unload` add/remove listeners.
- Update `pagehideHandler` to disconnect on every page-hide event (not
only the bfcache `event.persisted` case), since `pagehide` is the
canonical replacement for `unload` per the Web Page Lifecycle API
and fires reliably on tab close, navigation, and bfcache.
- Keep `beforeunload` as a non-deprecated synchronous disconnect
fallback for browsers where pagehide ordering differs.
Adds a unit regression test that asserts the template no longer
registers a `unload` listener while retaining `pagehide` and
`beforeunload`.
1 parent 70bd785 commit 447db31
2 files changed
Lines changed: 52 additions & 5 deletions
File tree
- packages/reflex-base/src/reflex_base/.templates/web/utils
- tests/units/compiler
Lines changed: 8 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
618 | 618 | | |
619 | 619 | | |
620 | 620 | | |
621 | | - | |
| 621 | + | |
622 | 622 | | |
623 | 623 | | |
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | | - | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
628 | 631 | | |
629 | | - | |
| 632 | + | |
| 633 | + | |
630 | 634 | | |
| 635 | + | |
631 | 636 | | |
632 | 637 | | |
633 | 638 | | |
| |||
636 | 641 | | |
637 | 642 | | |
638 | 643 | | |
639 | | - | |
640 | 644 | | |
641 | 645 | | |
642 | 646 | | |
| |||
666 | 670 | | |
667 | 671 | | |
668 | 672 | | |
669 | | - | |
670 | 673 | | |
671 | 674 | | |
672 | 675 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
0 commit comments