Skip to content

[fix] bind:this works during onMount callback in manually-created component #6920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Dec 13, 2021
Prev Previous commit
Next Next commit
Don't need extra get_current_component variant
  • Loading branch information
rmunn committed Dec 5, 2021
commit 407213cd551f271db30b848b724cbe6430e385b1
4 changes: 0 additions & 4 deletions src/runtime/internal/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export function get_current_component() {
return current_component;
}

export function maybe_get_current_component() {
return current_component;
}

export function beforeUpdate(fn: () => any) {
get_current_component().$$.before_update.push(fn);
}
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/internal/scheduler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { run_all } from './utils';
import { maybe_get_current_component, set_current_component } from './lifecycle';
import { current_component, set_current_component } from './lifecycle';

export const dirty_components = [];
export const intros = { enabled: false };
Expand Down Expand Up @@ -35,7 +35,7 @@ const seen_callbacks = new Set();
let flushidx = 0; // Do *not* move this inside the flush() function
export function flush() {

const current_component = maybe_get_current_component();
const saved_component = current_component;

do {
// first, call beforeUpdate functions
Expand Down Expand Up @@ -70,7 +70,7 @@ export function flush() {
render_callbacks.length = 0;
} while (dirty_components.length);

set_current_component(current_component);
set_current_component(saved_component);

while (flush_callbacks.length) {
flush_callbacks.pop()();
Expand Down