* * @param {Effect} effect
(effect)
| 919 | * @param {Effect} effect |
| 920 | */ |
| 921 | schedule(effect) { |
| 922 | last_scheduled_effect = effect; |
| 923 | |
| 924 | // defer render effects inside a pending boundary |
| 925 | // TODO the `REACTION_RAN` check is only necessary because of legacy `$:` effects AFAICT — we can remove later |
| 926 | if ( |
| 927 | effect.b?.is_pending && |
| 928 | (effect.f & (EFFECT | RENDER_EFFECT | MANAGED_EFFECT)) !== 0 && |
| 929 | (effect.f & REACTION_RAN) === 0 |
| 930 | ) { |
| 931 | effect.b.defer_effect(effect); |
| 932 | return; |
| 933 | } |
| 934 | |
| 935 | var e = effect; |
| 936 | |
| 937 | while (e.parent !== null) { |
| 938 | e = e.parent; |
| 939 | var flags = e.f; |
| 940 | |
| 941 | // if the effect is being scheduled because a parent (each/await/etc) block |
| 942 | // updated an internal source, or because a branch is being unskipped, |
| 943 | // bail out or we'll cause a second flush |
| 944 | if (collected_effects !== null && e === active_effect) { |
| 945 | if (async_mode_flag) return; |
| 946 | |
| 947 | // in sync mode, render effects run during traversal. in an extreme edge case |
| 948 | // — namely that we're setting a value inside a derived read during traversal — |
| 949 | // they can be made dirty after they have already been visited, in which |
| 950 | // case we shouldn't bail out. we also shouldn't bail out if we're |
| 951 | // updating a store inside a `$:`, since this might invalidate |
| 952 | // effects that were already visited |
| 953 | if ( |
| 954 | (active_reaction === null || (active_reaction.f & DERIVED) === 0) && |
| 955 | !legacy_is_updating_store |
| 956 | ) { |
| 957 | return; |
| 958 | } |
| 959 | } |
| 960 | |
| 961 | if ((flags & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) { |
| 962 | if ((flags & CLEAN) === 0) { |
| 963 | // branch is already dirty, bail |
| 964 | return; |
| 965 | } |
| 966 | |
| 967 | e.f ^= CLEAN; |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | this.#roots.push(e); |
| 972 | } |
| 973 | |
| 974 | #unlink() { |
| 975 | // #merge calls #unlink, discard later on does it again - prevent |
no test coverage detected