pull/9617/head
Dominic Gannaway 3 years ago
parent 99652d6199
commit 6214326535

@ -2,7 +2,6 @@ import { DEV } from 'esm-env';
import {
append_child,
child,
child_frag,
clone_node,
create_element,
init_operations,
@ -61,7 +60,8 @@ import {
push,
current_component_context,
pop,
schedule_task
schedule_task,
managed_render_effect
} from './runtime.js';
import {
current_hydration_fragment,
@ -79,18 +79,11 @@ const all_registerd_events = new Set();
/** @type {Set<(events: Array<string>) => void>} */
const root_event_handles = new Set();
/** @type {any[] | null} */
export let bind_this_context = null;
/** @returns {Text} */
export function empty() {
return document.createTextNode('');
}
export function clear_bind_this_context() {
bind_this_context = null;
}
/**
* @param {string} html
* @param {boolean} is_fragment
@ -1237,19 +1230,10 @@ export function bind_prop(props, prop, value) {
*/
export function bind_this(element_or_component, update, binding) {
untrack(() => {
// If a bind_this is shared across multple targets, then we
// need to ensure we correctly assign the value rather than
// only setting `null` for when they unmount.
if (is_signal(binding)) {
if (bind_this_context === null) {
bind_this_context = [];
}
bind_this_context.push(binding);
}
update(element_or_component);
render_effect(() => () => {
untrack(() => {
if (bind_this_context === null || !bind_this_context.includes(binding)) {
managed_render_effect(() => {
if (!is_signal(binding) || binding.v === element_or_component) {
update(null);
}
});

@ -1,7 +1,7 @@
import { DEV } from 'esm-env';
import { subscribe_to_store } from '../../store/utils.js';
import { EMPTY_FUNC, run_all } from '../common.js';
import { bind_this_context, clear_bind_this_context, unwrap } from './render.js';
import { unwrap } from './render.js';
import { is_array } from './utils.js';
export const SOURCE = 1;
@ -478,9 +478,6 @@ function flush_queued_effects(effects) {
}
}
}
if (bind_this_context !== null) {
clear_bind_this_context();
}
effects.length = 0;
}
}

Loading…
Cancel
Save